023f11266694d1426be78facc86cb8d0bd19ccd8
[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 JNIEXPORT void Java_org_ldk_impl_bindings_init(JNIEnv * env, jclass _b, jclass enum_class) {
25         ordinal_meth = (*env)->GetMethodID(env, enum_class, "ordinal", "()I");
26         CHECK(ordinal_meth != NULL);
27 }
28
29 // We assume that CVec_u8Z and u8slice are the same size and layout (and thus pointers to the two can be mixed)
30 _Static_assert(sizeof(LDKCVec_u8Z) == sizeof(LDKu8slice), "Vec<u8> and [u8] need to have been mapped identically");
31 _Static_assert(offsetof(LDKCVec_u8Z, data) == offsetof(LDKu8slice, data), "Vec<u8> and [u8] need to have been mapped identically");
32 _Static_assert(offsetof(LDKCVec_u8Z, datalen) == offsetof(LDKu8slice, datalen), "Vec<u8> and [u8] need to have been mapped identically");
33
34 _Static_assert(sizeof(jlong) == sizeof(int64_t), "We assume that j-types are the same as C types");
35 _Static_assert(sizeof(jbyte) == sizeof(char), "We assume that j-types are the same as C types");
36 _Static_assert(sizeof(void*) <= 8, "Pointers must fit into 64 bits");
37
38 typedef jlongArray int64_tArray;
39 typedef jbyteArray int8_tArray;
40
41 static inline jstring str_ref_to_java(JNIEnv *env, const char* chars, size_t len) {
42         // Sadly we need to create a temporary because Java can't accept a char* without a 0-terminator
43         char* conv_buf = MALLOC(len + 1, "str conv buf");
44         memcpy(conv_buf, chars, len);
45         conv_buf[len] = 0;
46         jstring ret = (*env)->NewStringUTF(env, conv_buf);
47         FREE(conv_buf);
48         return ret;
49 }
50 static inline LDKStr java_to_owned_str(JNIEnv *env, jstring str) {
51         uint64_t str_len = (*env)->GetStringUTFLength(env, str);
52         char* newchars = MALLOC(str_len + 1, "String chars");
53         const char* jchars = (*env)->GetStringUTFChars(env, str, NULL);
54         memcpy(newchars, jchars, str_len);
55         newchars[str_len] = 0;
56         (*env)->ReleaseStringUTFChars(env, str, jchars);
57         LDKStr res = {
58                 .chars = newchars,
59                 .len = str_len,
60                 .chars_is_owned = true
61         };
62         return res;
63 }
64
65 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_get_1ldk_1c_1bindings_1version(JNIEnv *env, jclass _c) {
66         return str_ref_to_java(env, check_get_ldk_bindings_version(), strlen(check_get_ldk_bindings_version()));
67 }
68 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_get_1ldk_1version(JNIEnv *env, jclass _c) {
69         return str_ref_to_java(env, check_get_ldk_version(), strlen(check_get_ldk_version()));
70 }
71 #include "version.c"
72 static jclass arr_of_B_clz = NULL;
73 static jclass arr_of_J_clz = NULL;
74 JNIEXPORT void Java_org_ldk_impl_bindings_init_1class_1cache(JNIEnv * env, jclass clz) {
75         arr_of_B_clz = (*env)->FindClass(env, "[B");
76         CHECK(arr_of_B_clz != NULL);
77         arr_of_B_clz = (*env)->NewGlobalRef(env, arr_of_B_clz);
78         arr_of_J_clz = (*env)->FindClass(env, "[J");
79         CHECK(arr_of_J_clz != NULL);
80         arr_of_J_clz = (*env)->NewGlobalRef(env, arr_of_J_clz);
81 }
82 static inline struct LDKThirtyTwoBytes ThirtyTwoBytes_clone(const struct LDKThirtyTwoBytes *orig) { struct LDKThirtyTwoBytes ret; memcpy(ret.data, orig->data, 32); return ret; }
83
84 static inline void* untag_ptr(uint64_t ptr) {
85         if (ptr < 4096) return (void*)ptr;
86         if (sizeof(void*) == 4) {
87                 // For 32-bit systems, store pointers as 64-bit ints and use the 31st bit
88                 return (void*)(uintptr_t)ptr;
89         } else {
90                 // For 64-bit systems, assume the top byte is used for tagging, then
91                 // use bit 9 ^ bit 10.
92                 uint64_t tenth_bit = (((uintptr_t)ptr) & (1ULL << 54)) >> 54;
93                 uintptr_t p = (ptr & ~(1ULL << 55)) | (tenth_bit << 55);
94 #ifdef LDK_DEBUG_BUILD
95                 // On debug builds we also use the 11th bit as a debug flag
96                 uintptr_t eleventh_bit = (((uintptr_t)ptr) & (1ULL << 53)) >> 53;
97                 CHECK(tenth_bit != eleventh_bit);
98                 p ^= 1ULL << 53;
99 #endif
100                 return (void*)p;
101         }
102 }
103 static inline bool ptr_is_owned(uint64_t ptr) {
104         if(ptr < 4096) return true;
105         if (sizeof(void*) == 4) {
106                 return ptr & (1ULL << 32);
107         } else {
108                 uintptr_t ninth_bit = (((uintptr_t)ptr) & (1ULL << 55)) >> 55;
109                 uintptr_t tenth_bit = (((uintptr_t)ptr) & (1ULL << 54)) >> 54;
110 #ifdef LDK_DEBUG_BUILD
111                 // On debug builds we also use the 11th bit as a debug flag
112                 uintptr_t eleventh_bit = (((uintptr_t)ptr) & (1ULL << 53)) >> 53;
113                 CHECK(tenth_bit != eleventh_bit);
114 #endif
115                 return (ninth_bit ^ tenth_bit) ? true : false;
116         }
117 }
118 static inline uint64_t tag_ptr(const void* ptr, bool is_owned) {
119         if ((uintptr_t)ptr < 4096) return (uint64_t)ptr;
120         if (sizeof(void*) == 4) {
121                 return (((uint64_t)ptr) | ((is_owned ? 1ULL : 0) << 32));
122         } else {
123                 CHECK(sizeof(uintptr_t) == 8);
124                 uintptr_t tenth_bit = (((uintptr_t)ptr) & (1ULL << 54)) >> 54;
125                 uintptr_t t = (((uintptr_t)ptr) | (((is_owned ? 1ULL : 0ULL) ^ tenth_bit) << 55));
126 #ifdef LDK_DEBUG_BUILD
127                 uintptr_t ninth_bit = (((uintptr_t)ptr) & (1ULL << 55)) >> 55;
128                 uintptr_t eleventh_bit = (((uintptr_t)ptr) & (1ULL << 53)) >> 53;
129                 CHECK(ninth_bit == tenth_bit);
130                 CHECK(ninth_bit == eleventh_bit);
131                 t ^= 1ULL << 53;
132 #endif
133                 CHECK(ptr_is_owned(t) == is_owned);
134                 CHECK(untag_ptr(t) == ptr);
135                 return t;
136         }
137 }
138
139 static inline LDKAccessError LDKAccessError_from_java(JNIEnv *env, jclass clz) {
140         jint ord = (*env)->CallIntMethod(env, clz, ordinal_meth);
141         if (UNLIKELY((*env)->ExceptionCheck(env))) {
142                 (*env)->ExceptionDescribe(env);
143                 (*env)->FatalError(env, "A call to AccessError.ordinal() from rust threw an exception.");
144         }
145         switch (ord) {
146                 case 0: return LDKAccessError_UnknownChain;
147                 case 1: return LDKAccessError_UnknownTx;
148         }
149         (*env)->FatalError(env, "A call to AccessError.ordinal() from rust returned an invalid value.");
150         abort(); // Unreachable, but will let the compiler know we don't return here
151 }
152 static jclass AccessError_class = NULL;
153 static jfieldID AccessError_LDKAccessError_UnknownChain = NULL;
154 static jfieldID AccessError_LDKAccessError_UnknownTx = NULL;
155 JNIEXPORT void JNICALL Java_org_ldk_enums_AccessError_init (JNIEnv *env, jclass clz) {
156         AccessError_class = (*env)->NewGlobalRef(env, clz);
157         CHECK(AccessError_class != NULL);
158         AccessError_LDKAccessError_UnknownChain = (*env)->GetStaticFieldID(env, AccessError_class, "LDKAccessError_UnknownChain", "Lorg/ldk/enums/AccessError;");
159         CHECK(AccessError_LDKAccessError_UnknownChain != NULL);
160         AccessError_LDKAccessError_UnknownTx = (*env)->GetStaticFieldID(env, AccessError_class, "LDKAccessError_UnknownTx", "Lorg/ldk/enums/AccessError;");
161         CHECK(AccessError_LDKAccessError_UnknownTx != NULL);
162 }
163 static inline jclass LDKAccessError_to_java(JNIEnv *env, LDKAccessError val) {
164         switch (val) {
165                 case LDKAccessError_UnknownChain:
166                         return (*env)->GetStaticObjectField(env, AccessError_class, AccessError_LDKAccessError_UnknownChain);
167                 case LDKAccessError_UnknownTx:
168                         return (*env)->GetStaticObjectField(env, AccessError_class, AccessError_LDKAccessError_UnknownTx);
169                 default: abort();
170         }
171 }
172
173 static inline LDKCOption_NoneZ LDKCOption_NoneZ_from_java(JNIEnv *env, jclass clz) {
174         jint ord = (*env)->CallIntMethod(env, clz, ordinal_meth);
175         if (UNLIKELY((*env)->ExceptionCheck(env))) {
176                 (*env)->ExceptionDescribe(env);
177                 (*env)->FatalError(env, "A call to COption_NoneZ.ordinal() from rust threw an exception.");
178         }
179         switch (ord) {
180                 case 0: return LDKCOption_NoneZ_Some;
181                 case 1: return LDKCOption_NoneZ_None;
182         }
183         (*env)->FatalError(env, "A call to COption_NoneZ.ordinal() from rust returned an invalid value.");
184         abort(); // Unreachable, but will let the compiler know we don't return here
185 }
186 static jclass COption_NoneZ_class = NULL;
187 static jfieldID COption_NoneZ_LDKCOption_NoneZ_Some = NULL;
188 static jfieldID COption_NoneZ_LDKCOption_NoneZ_None = NULL;
189 JNIEXPORT void JNICALL Java_org_ldk_enums_COption_1NoneZ_init (JNIEnv *env, jclass clz) {
190         COption_NoneZ_class = (*env)->NewGlobalRef(env, clz);
191         CHECK(COption_NoneZ_class != NULL);
192         COption_NoneZ_LDKCOption_NoneZ_Some = (*env)->GetStaticFieldID(env, COption_NoneZ_class, "LDKCOption_NoneZ_Some", "Lorg/ldk/enums/COption_NoneZ;");
193         CHECK(COption_NoneZ_LDKCOption_NoneZ_Some != NULL);
194         COption_NoneZ_LDKCOption_NoneZ_None = (*env)->GetStaticFieldID(env, COption_NoneZ_class, "LDKCOption_NoneZ_None", "Lorg/ldk/enums/COption_NoneZ;");
195         CHECK(COption_NoneZ_LDKCOption_NoneZ_None != NULL);
196 }
197 static inline jclass LDKCOption_NoneZ_to_java(JNIEnv *env, LDKCOption_NoneZ val) {
198         switch (val) {
199                 case LDKCOption_NoneZ_Some:
200                         return (*env)->GetStaticObjectField(env, COption_NoneZ_class, COption_NoneZ_LDKCOption_NoneZ_Some);
201                 case LDKCOption_NoneZ_None:
202                         return (*env)->GetStaticObjectField(env, COption_NoneZ_class, COption_NoneZ_LDKCOption_NoneZ_None);
203                 default: abort();
204         }
205 }
206
207 static inline LDKChannelMonitorUpdateStatus LDKChannelMonitorUpdateStatus_from_java(JNIEnv *env, jclass clz) {
208         jint ord = (*env)->CallIntMethod(env, clz, ordinal_meth);
209         if (UNLIKELY((*env)->ExceptionCheck(env))) {
210                 (*env)->ExceptionDescribe(env);
211                 (*env)->FatalError(env, "A call to ChannelMonitorUpdateStatus.ordinal() from rust threw an exception.");
212         }
213         switch (ord) {
214                 case 0: return LDKChannelMonitorUpdateStatus_Completed;
215                 case 1: return LDKChannelMonitorUpdateStatus_InProgress;
216                 case 2: return LDKChannelMonitorUpdateStatus_PermanentFailure;
217         }
218         (*env)->FatalError(env, "A call to ChannelMonitorUpdateStatus.ordinal() from rust returned an invalid value.");
219         abort(); // Unreachable, but will let the compiler know we don't return here
220 }
221 static jclass ChannelMonitorUpdateStatus_class = NULL;
222 static jfieldID ChannelMonitorUpdateStatus_LDKChannelMonitorUpdateStatus_Completed = NULL;
223 static jfieldID ChannelMonitorUpdateStatus_LDKChannelMonitorUpdateStatus_InProgress = NULL;
224 static jfieldID ChannelMonitorUpdateStatus_LDKChannelMonitorUpdateStatus_PermanentFailure = NULL;
225 JNIEXPORT void JNICALL Java_org_ldk_enums_ChannelMonitorUpdateStatus_init (JNIEnv *env, jclass clz) {
226         ChannelMonitorUpdateStatus_class = (*env)->NewGlobalRef(env, clz);
227         CHECK(ChannelMonitorUpdateStatus_class != NULL);
228         ChannelMonitorUpdateStatus_LDKChannelMonitorUpdateStatus_Completed = (*env)->GetStaticFieldID(env, ChannelMonitorUpdateStatus_class, "LDKChannelMonitorUpdateStatus_Completed", "Lorg/ldk/enums/ChannelMonitorUpdateStatus;");
229         CHECK(ChannelMonitorUpdateStatus_LDKChannelMonitorUpdateStatus_Completed != NULL);
230         ChannelMonitorUpdateStatus_LDKChannelMonitorUpdateStatus_InProgress = (*env)->GetStaticFieldID(env, ChannelMonitorUpdateStatus_class, "LDKChannelMonitorUpdateStatus_InProgress", "Lorg/ldk/enums/ChannelMonitorUpdateStatus;");
231         CHECK(ChannelMonitorUpdateStatus_LDKChannelMonitorUpdateStatus_InProgress != NULL);
232         ChannelMonitorUpdateStatus_LDKChannelMonitorUpdateStatus_PermanentFailure = (*env)->GetStaticFieldID(env, ChannelMonitorUpdateStatus_class, "LDKChannelMonitorUpdateStatus_PermanentFailure", "Lorg/ldk/enums/ChannelMonitorUpdateStatus;");
233         CHECK(ChannelMonitorUpdateStatus_LDKChannelMonitorUpdateStatus_PermanentFailure != NULL);
234 }
235 static inline jclass LDKChannelMonitorUpdateStatus_to_java(JNIEnv *env, LDKChannelMonitorUpdateStatus val) {
236         switch (val) {
237                 case LDKChannelMonitorUpdateStatus_Completed:
238                         return (*env)->GetStaticObjectField(env, ChannelMonitorUpdateStatus_class, ChannelMonitorUpdateStatus_LDKChannelMonitorUpdateStatus_Completed);
239                 case LDKChannelMonitorUpdateStatus_InProgress:
240                         return (*env)->GetStaticObjectField(env, ChannelMonitorUpdateStatus_class, ChannelMonitorUpdateStatus_LDKChannelMonitorUpdateStatus_InProgress);
241                 case LDKChannelMonitorUpdateStatus_PermanentFailure:
242                         return (*env)->GetStaticObjectField(env, ChannelMonitorUpdateStatus_class, ChannelMonitorUpdateStatus_LDKChannelMonitorUpdateStatus_PermanentFailure);
243                 default: abort();
244         }
245 }
246
247 static inline LDKConfirmationTarget LDKConfirmationTarget_from_java(JNIEnv *env, jclass clz) {
248         jint ord = (*env)->CallIntMethod(env, clz, ordinal_meth);
249         if (UNLIKELY((*env)->ExceptionCheck(env))) {
250                 (*env)->ExceptionDescribe(env);
251                 (*env)->FatalError(env, "A call to ConfirmationTarget.ordinal() from rust threw an exception.");
252         }
253         switch (ord) {
254                 case 0: return LDKConfirmationTarget_Background;
255                 case 1: return LDKConfirmationTarget_Normal;
256                 case 2: return LDKConfirmationTarget_HighPriority;
257         }
258         (*env)->FatalError(env, "A call to ConfirmationTarget.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 ConfirmationTarget_class = NULL;
262 static jfieldID ConfirmationTarget_LDKConfirmationTarget_Background = NULL;
263 static jfieldID ConfirmationTarget_LDKConfirmationTarget_Normal = NULL;
264 static jfieldID ConfirmationTarget_LDKConfirmationTarget_HighPriority = NULL;
265 JNIEXPORT void JNICALL Java_org_ldk_enums_ConfirmationTarget_init (JNIEnv *env, jclass clz) {
266         ConfirmationTarget_class = (*env)->NewGlobalRef(env, clz);
267         CHECK(ConfirmationTarget_class != NULL);
268         ConfirmationTarget_LDKConfirmationTarget_Background = (*env)->GetStaticFieldID(env, ConfirmationTarget_class, "LDKConfirmationTarget_Background", "Lorg/ldk/enums/ConfirmationTarget;");
269         CHECK(ConfirmationTarget_LDKConfirmationTarget_Background != NULL);
270         ConfirmationTarget_LDKConfirmationTarget_Normal = (*env)->GetStaticFieldID(env, ConfirmationTarget_class, "LDKConfirmationTarget_Normal", "Lorg/ldk/enums/ConfirmationTarget;");
271         CHECK(ConfirmationTarget_LDKConfirmationTarget_Normal != NULL);
272         ConfirmationTarget_LDKConfirmationTarget_HighPriority = (*env)->GetStaticFieldID(env, ConfirmationTarget_class, "LDKConfirmationTarget_HighPriority", "Lorg/ldk/enums/ConfirmationTarget;");
273         CHECK(ConfirmationTarget_LDKConfirmationTarget_HighPriority != NULL);
274 }
275 static inline jclass LDKConfirmationTarget_to_java(JNIEnv *env, LDKConfirmationTarget val) {
276         switch (val) {
277                 case LDKConfirmationTarget_Background:
278                         return (*env)->GetStaticObjectField(env, ConfirmationTarget_class, ConfirmationTarget_LDKConfirmationTarget_Background);
279                 case LDKConfirmationTarget_Normal:
280                         return (*env)->GetStaticObjectField(env, ConfirmationTarget_class, ConfirmationTarget_LDKConfirmationTarget_Normal);
281                 case LDKConfirmationTarget_HighPriority:
282                         return (*env)->GetStaticObjectField(env, ConfirmationTarget_class, ConfirmationTarget_LDKConfirmationTarget_HighPriority);
283                 default: abort();
284         }
285 }
286
287 static inline LDKCreationError LDKCreationError_from_java(JNIEnv *env, jclass clz) {
288         jint ord = (*env)->CallIntMethod(env, clz, ordinal_meth);
289         if (UNLIKELY((*env)->ExceptionCheck(env))) {
290                 (*env)->ExceptionDescribe(env);
291                 (*env)->FatalError(env, "A call to CreationError.ordinal() from rust threw an exception.");
292         }
293         switch (ord) {
294                 case 0: return LDKCreationError_DescriptionTooLong;
295                 case 1: return LDKCreationError_RouteTooLong;
296                 case 2: return LDKCreationError_TimestampOutOfBounds;
297                 case 3: return LDKCreationError_InvalidAmount;
298                 case 4: return LDKCreationError_MissingRouteHints;
299         }
300         (*env)->FatalError(env, "A call to CreationError.ordinal() from rust returned an invalid value.");
301         abort(); // Unreachable, but will let the compiler know we don't return here
302 }
303 static jclass CreationError_class = NULL;
304 static jfieldID CreationError_LDKCreationError_DescriptionTooLong = NULL;
305 static jfieldID CreationError_LDKCreationError_RouteTooLong = NULL;
306 static jfieldID CreationError_LDKCreationError_TimestampOutOfBounds = NULL;
307 static jfieldID CreationError_LDKCreationError_InvalidAmount = NULL;
308 static jfieldID CreationError_LDKCreationError_MissingRouteHints = NULL;
309 JNIEXPORT void JNICALL Java_org_ldk_enums_CreationError_init (JNIEnv *env, jclass clz) {
310         CreationError_class = (*env)->NewGlobalRef(env, clz);
311         CHECK(CreationError_class != NULL);
312         CreationError_LDKCreationError_DescriptionTooLong = (*env)->GetStaticFieldID(env, CreationError_class, "LDKCreationError_DescriptionTooLong", "Lorg/ldk/enums/CreationError;");
313         CHECK(CreationError_LDKCreationError_DescriptionTooLong != NULL);
314         CreationError_LDKCreationError_RouteTooLong = (*env)->GetStaticFieldID(env, CreationError_class, "LDKCreationError_RouteTooLong", "Lorg/ldk/enums/CreationError;");
315         CHECK(CreationError_LDKCreationError_RouteTooLong != NULL);
316         CreationError_LDKCreationError_TimestampOutOfBounds = (*env)->GetStaticFieldID(env, CreationError_class, "LDKCreationError_TimestampOutOfBounds", "Lorg/ldk/enums/CreationError;");
317         CHECK(CreationError_LDKCreationError_TimestampOutOfBounds != NULL);
318         CreationError_LDKCreationError_InvalidAmount = (*env)->GetStaticFieldID(env, CreationError_class, "LDKCreationError_InvalidAmount", "Lorg/ldk/enums/CreationError;");
319         CHECK(CreationError_LDKCreationError_InvalidAmount != NULL);
320         CreationError_LDKCreationError_MissingRouteHints = (*env)->GetStaticFieldID(env, CreationError_class, "LDKCreationError_MissingRouteHints", "Lorg/ldk/enums/CreationError;");
321         CHECK(CreationError_LDKCreationError_MissingRouteHints != NULL);
322 }
323 static inline jclass LDKCreationError_to_java(JNIEnv *env, LDKCreationError val) {
324         switch (val) {
325                 case LDKCreationError_DescriptionTooLong:
326                         return (*env)->GetStaticObjectField(env, CreationError_class, CreationError_LDKCreationError_DescriptionTooLong);
327                 case LDKCreationError_RouteTooLong:
328                         return (*env)->GetStaticObjectField(env, CreationError_class, CreationError_LDKCreationError_RouteTooLong);
329                 case LDKCreationError_TimestampOutOfBounds:
330                         return (*env)->GetStaticObjectField(env, CreationError_class, CreationError_LDKCreationError_TimestampOutOfBounds);
331                 case LDKCreationError_InvalidAmount:
332                         return (*env)->GetStaticObjectField(env, CreationError_class, CreationError_LDKCreationError_InvalidAmount);
333                 case LDKCreationError_MissingRouteHints:
334                         return (*env)->GetStaticObjectField(env, CreationError_class, CreationError_LDKCreationError_MissingRouteHints);
335                 default: abort();
336         }
337 }
338
339 static inline LDKCurrency LDKCurrency_from_java(JNIEnv *env, jclass clz) {
340         jint ord = (*env)->CallIntMethod(env, clz, ordinal_meth);
341         if (UNLIKELY((*env)->ExceptionCheck(env))) {
342                 (*env)->ExceptionDescribe(env);
343                 (*env)->FatalError(env, "A call to Currency.ordinal() from rust threw an exception.");
344         }
345         switch (ord) {
346                 case 0: return LDKCurrency_Bitcoin;
347                 case 1: return LDKCurrency_BitcoinTestnet;
348                 case 2: return LDKCurrency_Regtest;
349                 case 3: return LDKCurrency_Simnet;
350                 case 4: return LDKCurrency_Signet;
351         }
352         (*env)->FatalError(env, "A call to Currency.ordinal() from rust returned an invalid value.");
353         abort(); // Unreachable, but will let the compiler know we don't return here
354 }
355 static jclass Currency_class = NULL;
356 static jfieldID Currency_LDKCurrency_Bitcoin = NULL;
357 static jfieldID Currency_LDKCurrency_BitcoinTestnet = NULL;
358 static jfieldID Currency_LDKCurrency_Regtest = NULL;
359 static jfieldID Currency_LDKCurrency_Simnet = NULL;
360 static jfieldID Currency_LDKCurrency_Signet = NULL;
361 JNIEXPORT void JNICALL Java_org_ldk_enums_Currency_init (JNIEnv *env, jclass clz) {
362         Currency_class = (*env)->NewGlobalRef(env, clz);
363         CHECK(Currency_class != NULL);
364         Currency_LDKCurrency_Bitcoin = (*env)->GetStaticFieldID(env, Currency_class, "LDKCurrency_Bitcoin", "Lorg/ldk/enums/Currency;");
365         CHECK(Currency_LDKCurrency_Bitcoin != NULL);
366         Currency_LDKCurrency_BitcoinTestnet = (*env)->GetStaticFieldID(env, Currency_class, "LDKCurrency_BitcoinTestnet", "Lorg/ldk/enums/Currency;");
367         CHECK(Currency_LDKCurrency_BitcoinTestnet != NULL);
368         Currency_LDKCurrency_Regtest = (*env)->GetStaticFieldID(env, Currency_class, "LDKCurrency_Regtest", "Lorg/ldk/enums/Currency;");
369         CHECK(Currency_LDKCurrency_Regtest != NULL);
370         Currency_LDKCurrency_Simnet = (*env)->GetStaticFieldID(env, Currency_class, "LDKCurrency_Simnet", "Lorg/ldk/enums/Currency;");
371         CHECK(Currency_LDKCurrency_Simnet != NULL);
372         Currency_LDKCurrency_Signet = (*env)->GetStaticFieldID(env, Currency_class, "LDKCurrency_Signet", "Lorg/ldk/enums/Currency;");
373         CHECK(Currency_LDKCurrency_Signet != NULL);
374 }
375 static inline jclass LDKCurrency_to_java(JNIEnv *env, LDKCurrency val) {
376         switch (val) {
377                 case LDKCurrency_Bitcoin:
378                         return (*env)->GetStaticObjectField(env, Currency_class, Currency_LDKCurrency_Bitcoin);
379                 case LDKCurrency_BitcoinTestnet:
380                         return (*env)->GetStaticObjectField(env, Currency_class, Currency_LDKCurrency_BitcoinTestnet);
381                 case LDKCurrency_Regtest:
382                         return (*env)->GetStaticObjectField(env, Currency_class, Currency_LDKCurrency_Regtest);
383                 case LDKCurrency_Simnet:
384                         return (*env)->GetStaticObjectField(env, Currency_class, Currency_LDKCurrency_Simnet);
385                 case LDKCurrency_Signet:
386                         return (*env)->GetStaticObjectField(env, Currency_class, Currency_LDKCurrency_Signet);
387                 default: abort();
388         }
389 }
390
391 static inline LDKHTLCClaim LDKHTLCClaim_from_java(JNIEnv *env, jclass clz) {
392         jint ord = (*env)->CallIntMethod(env, clz, ordinal_meth);
393         if (UNLIKELY((*env)->ExceptionCheck(env))) {
394                 (*env)->ExceptionDescribe(env);
395                 (*env)->FatalError(env, "A call to HTLCClaim.ordinal() from rust threw an exception.");
396         }
397         switch (ord) {
398                 case 0: return LDKHTLCClaim_OfferedTimeout;
399                 case 1: return LDKHTLCClaim_OfferedPreimage;
400                 case 2: return LDKHTLCClaim_AcceptedTimeout;
401                 case 3: return LDKHTLCClaim_AcceptedPreimage;
402                 case 4: return LDKHTLCClaim_Revocation;
403         }
404         (*env)->FatalError(env, "A call to HTLCClaim.ordinal() from rust returned an invalid value.");
405         abort(); // Unreachable, but will let the compiler know we don't return here
406 }
407 static jclass HTLCClaim_class = NULL;
408 static jfieldID HTLCClaim_LDKHTLCClaim_OfferedTimeout = NULL;
409 static jfieldID HTLCClaim_LDKHTLCClaim_OfferedPreimage = NULL;
410 static jfieldID HTLCClaim_LDKHTLCClaim_AcceptedTimeout = NULL;
411 static jfieldID HTLCClaim_LDKHTLCClaim_AcceptedPreimage = NULL;
412 static jfieldID HTLCClaim_LDKHTLCClaim_Revocation = NULL;
413 JNIEXPORT void JNICALL Java_org_ldk_enums_HTLCClaim_init (JNIEnv *env, jclass clz) {
414         HTLCClaim_class = (*env)->NewGlobalRef(env, clz);
415         CHECK(HTLCClaim_class != NULL);
416         HTLCClaim_LDKHTLCClaim_OfferedTimeout = (*env)->GetStaticFieldID(env, HTLCClaim_class, "LDKHTLCClaim_OfferedTimeout", "Lorg/ldk/enums/HTLCClaim;");
417         CHECK(HTLCClaim_LDKHTLCClaim_OfferedTimeout != NULL);
418         HTLCClaim_LDKHTLCClaim_OfferedPreimage = (*env)->GetStaticFieldID(env, HTLCClaim_class, "LDKHTLCClaim_OfferedPreimage", "Lorg/ldk/enums/HTLCClaim;");
419         CHECK(HTLCClaim_LDKHTLCClaim_OfferedPreimage != NULL);
420         HTLCClaim_LDKHTLCClaim_AcceptedTimeout = (*env)->GetStaticFieldID(env, HTLCClaim_class, "LDKHTLCClaim_AcceptedTimeout", "Lorg/ldk/enums/HTLCClaim;");
421         CHECK(HTLCClaim_LDKHTLCClaim_AcceptedTimeout != NULL);
422         HTLCClaim_LDKHTLCClaim_AcceptedPreimage = (*env)->GetStaticFieldID(env, HTLCClaim_class, "LDKHTLCClaim_AcceptedPreimage", "Lorg/ldk/enums/HTLCClaim;");
423         CHECK(HTLCClaim_LDKHTLCClaim_AcceptedPreimage != NULL);
424         HTLCClaim_LDKHTLCClaim_Revocation = (*env)->GetStaticFieldID(env, HTLCClaim_class, "LDKHTLCClaim_Revocation", "Lorg/ldk/enums/HTLCClaim;");
425         CHECK(HTLCClaim_LDKHTLCClaim_Revocation != NULL);
426 }
427 static inline jclass LDKHTLCClaim_to_java(JNIEnv *env, LDKHTLCClaim val) {
428         switch (val) {
429                 case LDKHTLCClaim_OfferedTimeout:
430                         return (*env)->GetStaticObjectField(env, HTLCClaim_class, HTLCClaim_LDKHTLCClaim_OfferedTimeout);
431                 case LDKHTLCClaim_OfferedPreimage:
432                         return (*env)->GetStaticObjectField(env, HTLCClaim_class, HTLCClaim_LDKHTLCClaim_OfferedPreimage);
433                 case LDKHTLCClaim_AcceptedTimeout:
434                         return (*env)->GetStaticObjectField(env, HTLCClaim_class, HTLCClaim_LDKHTLCClaim_AcceptedTimeout);
435                 case LDKHTLCClaim_AcceptedPreimage:
436                         return (*env)->GetStaticObjectField(env, HTLCClaim_class, HTLCClaim_LDKHTLCClaim_AcceptedPreimage);
437                 case LDKHTLCClaim_Revocation:
438                         return (*env)->GetStaticObjectField(env, HTLCClaim_class, HTLCClaim_LDKHTLCClaim_Revocation);
439                 default: abort();
440         }
441 }
442
443 static inline LDKIOError LDKIOError_from_java(JNIEnv *env, jclass clz) {
444         jint ord = (*env)->CallIntMethod(env, clz, ordinal_meth);
445         if (UNLIKELY((*env)->ExceptionCheck(env))) {
446                 (*env)->ExceptionDescribe(env);
447                 (*env)->FatalError(env, "A call to IOError.ordinal() from rust threw an exception.");
448         }
449         switch (ord) {
450                 case 0: return LDKIOError_NotFound;
451                 case 1: return LDKIOError_PermissionDenied;
452                 case 2: return LDKIOError_ConnectionRefused;
453                 case 3: return LDKIOError_ConnectionReset;
454                 case 4: return LDKIOError_ConnectionAborted;
455                 case 5: return LDKIOError_NotConnected;
456                 case 6: return LDKIOError_AddrInUse;
457                 case 7: return LDKIOError_AddrNotAvailable;
458                 case 8: return LDKIOError_BrokenPipe;
459                 case 9: return LDKIOError_AlreadyExists;
460                 case 10: return LDKIOError_WouldBlock;
461                 case 11: return LDKIOError_InvalidInput;
462                 case 12: return LDKIOError_InvalidData;
463                 case 13: return LDKIOError_TimedOut;
464                 case 14: return LDKIOError_WriteZero;
465                 case 15: return LDKIOError_Interrupted;
466                 case 16: return LDKIOError_Other;
467                 case 17: return LDKIOError_UnexpectedEof;
468         }
469         (*env)->FatalError(env, "A call to IOError.ordinal() from rust returned an invalid value.");
470         abort(); // Unreachable, but will let the compiler know we don't return here
471 }
472 static jclass IOError_class = NULL;
473 static jfieldID IOError_LDKIOError_NotFound = NULL;
474 static jfieldID IOError_LDKIOError_PermissionDenied = NULL;
475 static jfieldID IOError_LDKIOError_ConnectionRefused = NULL;
476 static jfieldID IOError_LDKIOError_ConnectionReset = NULL;
477 static jfieldID IOError_LDKIOError_ConnectionAborted = NULL;
478 static jfieldID IOError_LDKIOError_NotConnected = NULL;
479 static jfieldID IOError_LDKIOError_AddrInUse = NULL;
480 static jfieldID IOError_LDKIOError_AddrNotAvailable = NULL;
481 static jfieldID IOError_LDKIOError_BrokenPipe = NULL;
482 static jfieldID IOError_LDKIOError_AlreadyExists = NULL;
483 static jfieldID IOError_LDKIOError_WouldBlock = NULL;
484 static jfieldID IOError_LDKIOError_InvalidInput = NULL;
485 static jfieldID IOError_LDKIOError_InvalidData = NULL;
486 static jfieldID IOError_LDKIOError_TimedOut = NULL;
487 static jfieldID IOError_LDKIOError_WriteZero = NULL;
488 static jfieldID IOError_LDKIOError_Interrupted = NULL;
489 static jfieldID IOError_LDKIOError_Other = NULL;
490 static jfieldID IOError_LDKIOError_UnexpectedEof = NULL;
491 JNIEXPORT void JNICALL Java_org_ldk_enums_IOError_init (JNIEnv *env, jclass clz) {
492         IOError_class = (*env)->NewGlobalRef(env, clz);
493         CHECK(IOError_class != NULL);
494         IOError_LDKIOError_NotFound = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_NotFound", "Lorg/ldk/enums/IOError;");
495         CHECK(IOError_LDKIOError_NotFound != NULL);
496         IOError_LDKIOError_PermissionDenied = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_PermissionDenied", "Lorg/ldk/enums/IOError;");
497         CHECK(IOError_LDKIOError_PermissionDenied != NULL);
498         IOError_LDKIOError_ConnectionRefused = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_ConnectionRefused", "Lorg/ldk/enums/IOError;");
499         CHECK(IOError_LDKIOError_ConnectionRefused != NULL);
500         IOError_LDKIOError_ConnectionReset = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_ConnectionReset", "Lorg/ldk/enums/IOError;");
501         CHECK(IOError_LDKIOError_ConnectionReset != NULL);
502         IOError_LDKIOError_ConnectionAborted = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_ConnectionAborted", "Lorg/ldk/enums/IOError;");
503         CHECK(IOError_LDKIOError_ConnectionAborted != NULL);
504         IOError_LDKIOError_NotConnected = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_NotConnected", "Lorg/ldk/enums/IOError;");
505         CHECK(IOError_LDKIOError_NotConnected != NULL);
506         IOError_LDKIOError_AddrInUse = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_AddrInUse", "Lorg/ldk/enums/IOError;");
507         CHECK(IOError_LDKIOError_AddrInUse != NULL);
508         IOError_LDKIOError_AddrNotAvailable = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_AddrNotAvailable", "Lorg/ldk/enums/IOError;");
509         CHECK(IOError_LDKIOError_AddrNotAvailable != NULL);
510         IOError_LDKIOError_BrokenPipe = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_BrokenPipe", "Lorg/ldk/enums/IOError;");
511         CHECK(IOError_LDKIOError_BrokenPipe != NULL);
512         IOError_LDKIOError_AlreadyExists = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_AlreadyExists", "Lorg/ldk/enums/IOError;");
513         CHECK(IOError_LDKIOError_AlreadyExists != NULL);
514         IOError_LDKIOError_WouldBlock = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_WouldBlock", "Lorg/ldk/enums/IOError;");
515         CHECK(IOError_LDKIOError_WouldBlock != NULL);
516         IOError_LDKIOError_InvalidInput = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_InvalidInput", "Lorg/ldk/enums/IOError;");
517         CHECK(IOError_LDKIOError_InvalidInput != NULL);
518         IOError_LDKIOError_InvalidData = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_InvalidData", "Lorg/ldk/enums/IOError;");
519         CHECK(IOError_LDKIOError_InvalidData != NULL);
520         IOError_LDKIOError_TimedOut = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_TimedOut", "Lorg/ldk/enums/IOError;");
521         CHECK(IOError_LDKIOError_TimedOut != NULL);
522         IOError_LDKIOError_WriteZero = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_WriteZero", "Lorg/ldk/enums/IOError;");
523         CHECK(IOError_LDKIOError_WriteZero != NULL);
524         IOError_LDKIOError_Interrupted = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_Interrupted", "Lorg/ldk/enums/IOError;");
525         CHECK(IOError_LDKIOError_Interrupted != NULL);
526         IOError_LDKIOError_Other = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_Other", "Lorg/ldk/enums/IOError;");
527         CHECK(IOError_LDKIOError_Other != NULL);
528         IOError_LDKIOError_UnexpectedEof = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_UnexpectedEof", "Lorg/ldk/enums/IOError;");
529         CHECK(IOError_LDKIOError_UnexpectedEof != NULL);
530 }
531 static inline jclass LDKIOError_to_java(JNIEnv *env, LDKIOError val) {
532         switch (val) {
533                 case LDKIOError_NotFound:
534                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_NotFound);
535                 case LDKIOError_PermissionDenied:
536                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_PermissionDenied);
537                 case LDKIOError_ConnectionRefused:
538                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_ConnectionRefused);
539                 case LDKIOError_ConnectionReset:
540                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_ConnectionReset);
541                 case LDKIOError_ConnectionAborted:
542                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_ConnectionAborted);
543                 case LDKIOError_NotConnected:
544                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_NotConnected);
545                 case LDKIOError_AddrInUse:
546                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_AddrInUse);
547                 case LDKIOError_AddrNotAvailable:
548                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_AddrNotAvailable);
549                 case LDKIOError_BrokenPipe:
550                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_BrokenPipe);
551                 case LDKIOError_AlreadyExists:
552                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_AlreadyExists);
553                 case LDKIOError_WouldBlock:
554                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_WouldBlock);
555                 case LDKIOError_InvalidInput:
556                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_InvalidInput);
557                 case LDKIOError_InvalidData:
558                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_InvalidData);
559                 case LDKIOError_TimedOut:
560                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_TimedOut);
561                 case LDKIOError_WriteZero:
562                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_WriteZero);
563                 case LDKIOError_Interrupted:
564                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_Interrupted);
565                 case LDKIOError_Other:
566                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_Other);
567                 case LDKIOError_UnexpectedEof:
568                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_UnexpectedEof);
569                 default: abort();
570         }
571 }
572
573 static inline LDKLevel LDKLevel_from_java(JNIEnv *env, jclass clz) {
574         jint ord = (*env)->CallIntMethod(env, clz, ordinal_meth);
575         if (UNLIKELY((*env)->ExceptionCheck(env))) {
576                 (*env)->ExceptionDescribe(env);
577                 (*env)->FatalError(env, "A call to Level.ordinal() from rust threw an exception.");
578         }
579         switch (ord) {
580                 case 0: return LDKLevel_Gossip;
581                 case 1: return LDKLevel_Trace;
582                 case 2: return LDKLevel_Debug;
583                 case 3: return LDKLevel_Info;
584                 case 4: return LDKLevel_Warn;
585                 case 5: return LDKLevel_Error;
586         }
587         (*env)->FatalError(env, "A call to Level.ordinal() from rust returned an invalid value.");
588         abort(); // Unreachable, but will let the compiler know we don't return here
589 }
590 static jclass Level_class = NULL;
591 static jfieldID Level_LDKLevel_Gossip = NULL;
592 static jfieldID Level_LDKLevel_Trace = NULL;
593 static jfieldID Level_LDKLevel_Debug = NULL;
594 static jfieldID Level_LDKLevel_Info = NULL;
595 static jfieldID Level_LDKLevel_Warn = NULL;
596 static jfieldID Level_LDKLevel_Error = NULL;
597 JNIEXPORT void JNICALL Java_org_ldk_enums_Level_init (JNIEnv *env, jclass clz) {
598         Level_class = (*env)->NewGlobalRef(env, clz);
599         CHECK(Level_class != NULL);
600         Level_LDKLevel_Gossip = (*env)->GetStaticFieldID(env, Level_class, "LDKLevel_Gossip", "Lorg/ldk/enums/Level;");
601         CHECK(Level_LDKLevel_Gossip != NULL);
602         Level_LDKLevel_Trace = (*env)->GetStaticFieldID(env, Level_class, "LDKLevel_Trace", "Lorg/ldk/enums/Level;");
603         CHECK(Level_LDKLevel_Trace != NULL);
604         Level_LDKLevel_Debug = (*env)->GetStaticFieldID(env, Level_class, "LDKLevel_Debug", "Lorg/ldk/enums/Level;");
605         CHECK(Level_LDKLevel_Debug != NULL);
606         Level_LDKLevel_Info = (*env)->GetStaticFieldID(env, Level_class, "LDKLevel_Info", "Lorg/ldk/enums/Level;");
607         CHECK(Level_LDKLevel_Info != NULL);
608         Level_LDKLevel_Warn = (*env)->GetStaticFieldID(env, Level_class, "LDKLevel_Warn", "Lorg/ldk/enums/Level;");
609         CHECK(Level_LDKLevel_Warn != NULL);
610         Level_LDKLevel_Error = (*env)->GetStaticFieldID(env, Level_class, "LDKLevel_Error", "Lorg/ldk/enums/Level;");
611         CHECK(Level_LDKLevel_Error != NULL);
612 }
613 static inline jclass LDKLevel_to_java(JNIEnv *env, LDKLevel val) {
614         switch (val) {
615                 case LDKLevel_Gossip:
616                         return (*env)->GetStaticObjectField(env, Level_class, Level_LDKLevel_Gossip);
617                 case LDKLevel_Trace:
618                         return (*env)->GetStaticObjectField(env, Level_class, Level_LDKLevel_Trace);
619                 case LDKLevel_Debug:
620                         return (*env)->GetStaticObjectField(env, Level_class, Level_LDKLevel_Debug);
621                 case LDKLevel_Info:
622                         return (*env)->GetStaticObjectField(env, Level_class, Level_LDKLevel_Info);
623                 case LDKLevel_Warn:
624                         return (*env)->GetStaticObjectField(env, Level_class, Level_LDKLevel_Warn);
625                 case LDKLevel_Error:
626                         return (*env)->GetStaticObjectField(env, Level_class, Level_LDKLevel_Error);
627                 default: abort();
628         }
629 }
630
631 static inline LDKNetwork LDKNetwork_from_java(JNIEnv *env, jclass clz) {
632         jint ord = (*env)->CallIntMethod(env, clz, ordinal_meth);
633         if (UNLIKELY((*env)->ExceptionCheck(env))) {
634                 (*env)->ExceptionDescribe(env);
635                 (*env)->FatalError(env, "A call to Network.ordinal() from rust threw an exception.");
636         }
637         switch (ord) {
638                 case 0: return LDKNetwork_Bitcoin;
639                 case 1: return LDKNetwork_Testnet;
640                 case 2: return LDKNetwork_Regtest;
641                 case 3: return LDKNetwork_Signet;
642         }
643         (*env)->FatalError(env, "A call to Network.ordinal() from rust returned an invalid value.");
644         abort(); // Unreachable, but will let the compiler know we don't return here
645 }
646 static jclass Network_class = NULL;
647 static jfieldID Network_LDKNetwork_Bitcoin = NULL;
648 static jfieldID Network_LDKNetwork_Testnet = NULL;
649 static jfieldID Network_LDKNetwork_Regtest = NULL;
650 static jfieldID Network_LDKNetwork_Signet = NULL;
651 JNIEXPORT void JNICALL Java_org_ldk_enums_Network_init (JNIEnv *env, jclass clz) {
652         Network_class = (*env)->NewGlobalRef(env, clz);
653         CHECK(Network_class != NULL);
654         Network_LDKNetwork_Bitcoin = (*env)->GetStaticFieldID(env, Network_class, "LDKNetwork_Bitcoin", "Lorg/ldk/enums/Network;");
655         CHECK(Network_LDKNetwork_Bitcoin != NULL);
656         Network_LDKNetwork_Testnet = (*env)->GetStaticFieldID(env, Network_class, "LDKNetwork_Testnet", "Lorg/ldk/enums/Network;");
657         CHECK(Network_LDKNetwork_Testnet != NULL);
658         Network_LDKNetwork_Regtest = (*env)->GetStaticFieldID(env, Network_class, "LDKNetwork_Regtest", "Lorg/ldk/enums/Network;");
659         CHECK(Network_LDKNetwork_Regtest != NULL);
660         Network_LDKNetwork_Signet = (*env)->GetStaticFieldID(env, Network_class, "LDKNetwork_Signet", "Lorg/ldk/enums/Network;");
661         CHECK(Network_LDKNetwork_Signet != NULL);
662 }
663 static inline jclass LDKNetwork_to_java(JNIEnv *env, LDKNetwork val) {
664         switch (val) {
665                 case LDKNetwork_Bitcoin:
666                         return (*env)->GetStaticObjectField(env, Network_class, Network_LDKNetwork_Bitcoin);
667                 case LDKNetwork_Testnet:
668                         return (*env)->GetStaticObjectField(env, Network_class, Network_LDKNetwork_Testnet);
669                 case LDKNetwork_Regtest:
670                         return (*env)->GetStaticObjectField(env, Network_class, Network_LDKNetwork_Regtest);
671                 case LDKNetwork_Signet:
672                         return (*env)->GetStaticObjectField(env, Network_class, Network_LDKNetwork_Signet);
673                 default: abort();
674         }
675 }
676
677 static inline LDKRecipient LDKRecipient_from_java(JNIEnv *env, jclass clz) {
678         jint ord = (*env)->CallIntMethod(env, clz, ordinal_meth);
679         if (UNLIKELY((*env)->ExceptionCheck(env))) {
680                 (*env)->ExceptionDescribe(env);
681                 (*env)->FatalError(env, "A call to Recipient.ordinal() from rust threw an exception.");
682         }
683         switch (ord) {
684                 case 0: return LDKRecipient_Node;
685                 case 1: return LDKRecipient_PhantomNode;
686         }
687         (*env)->FatalError(env, "A call to Recipient.ordinal() from rust returned an invalid value.");
688         abort(); // Unreachable, but will let the compiler know we don't return here
689 }
690 static jclass Recipient_class = NULL;
691 static jfieldID Recipient_LDKRecipient_Node = NULL;
692 static jfieldID Recipient_LDKRecipient_PhantomNode = NULL;
693 JNIEXPORT void JNICALL Java_org_ldk_enums_Recipient_init (JNIEnv *env, jclass clz) {
694         Recipient_class = (*env)->NewGlobalRef(env, clz);
695         CHECK(Recipient_class != NULL);
696         Recipient_LDKRecipient_Node = (*env)->GetStaticFieldID(env, Recipient_class, "LDKRecipient_Node", "Lorg/ldk/enums/Recipient;");
697         CHECK(Recipient_LDKRecipient_Node != NULL);
698         Recipient_LDKRecipient_PhantomNode = (*env)->GetStaticFieldID(env, Recipient_class, "LDKRecipient_PhantomNode", "Lorg/ldk/enums/Recipient;");
699         CHECK(Recipient_LDKRecipient_PhantomNode != NULL);
700 }
701 static inline jclass LDKRecipient_to_java(JNIEnv *env, LDKRecipient val) {
702         switch (val) {
703                 case LDKRecipient_Node:
704                         return (*env)->GetStaticObjectField(env, Recipient_class, Recipient_LDKRecipient_Node);
705                 case LDKRecipient_PhantomNode:
706                         return (*env)->GetStaticObjectField(env, Recipient_class, Recipient_LDKRecipient_PhantomNode);
707                 default: abort();
708         }
709 }
710
711 static inline LDKSecp256k1Error LDKSecp256k1Error_from_java(JNIEnv *env, jclass clz) {
712         jint ord = (*env)->CallIntMethod(env, clz, ordinal_meth);
713         if (UNLIKELY((*env)->ExceptionCheck(env))) {
714                 (*env)->ExceptionDescribe(env);
715                 (*env)->FatalError(env, "A call to Secp256k1Error.ordinal() from rust threw an exception.");
716         }
717         switch (ord) {
718                 case 0: return LDKSecp256k1Error_IncorrectSignature;
719                 case 1: return LDKSecp256k1Error_InvalidMessage;
720                 case 2: return LDKSecp256k1Error_InvalidPublicKey;
721                 case 3: return LDKSecp256k1Error_InvalidSignature;
722                 case 4: return LDKSecp256k1Error_InvalidSecretKey;
723                 case 5: return LDKSecp256k1Error_InvalidSharedSecret;
724                 case 6: return LDKSecp256k1Error_InvalidRecoveryId;
725                 case 7: return LDKSecp256k1Error_InvalidTweak;
726                 case 8: return LDKSecp256k1Error_NotEnoughMemory;
727                 case 9: return LDKSecp256k1Error_InvalidPublicKeySum;
728                 case 10: return LDKSecp256k1Error_InvalidParityValue;
729         }
730         (*env)->FatalError(env, "A call to Secp256k1Error.ordinal() from rust returned an invalid value.");
731         abort(); // Unreachable, but will let the compiler know we don't return here
732 }
733 static jclass Secp256k1Error_class = NULL;
734 static jfieldID Secp256k1Error_LDKSecp256k1Error_IncorrectSignature = NULL;
735 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidMessage = NULL;
736 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidPublicKey = NULL;
737 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidSignature = NULL;
738 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidSecretKey = NULL;
739 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidSharedSecret = NULL;
740 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidRecoveryId = NULL;
741 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidTweak = NULL;
742 static jfieldID Secp256k1Error_LDKSecp256k1Error_NotEnoughMemory = NULL;
743 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidPublicKeySum = NULL;
744 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidParityValue = NULL;
745 JNIEXPORT void JNICALL Java_org_ldk_enums_Secp256k1Error_init (JNIEnv *env, jclass clz) {
746         Secp256k1Error_class = (*env)->NewGlobalRef(env, clz);
747         CHECK(Secp256k1Error_class != NULL);
748         Secp256k1Error_LDKSecp256k1Error_IncorrectSignature = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_IncorrectSignature", "Lorg/ldk/enums/Secp256k1Error;");
749         CHECK(Secp256k1Error_LDKSecp256k1Error_IncorrectSignature != NULL);
750         Secp256k1Error_LDKSecp256k1Error_InvalidMessage = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidMessage", "Lorg/ldk/enums/Secp256k1Error;");
751         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidMessage != NULL);
752         Secp256k1Error_LDKSecp256k1Error_InvalidPublicKey = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidPublicKey", "Lorg/ldk/enums/Secp256k1Error;");
753         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidPublicKey != NULL);
754         Secp256k1Error_LDKSecp256k1Error_InvalidSignature = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidSignature", "Lorg/ldk/enums/Secp256k1Error;");
755         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidSignature != NULL);
756         Secp256k1Error_LDKSecp256k1Error_InvalidSecretKey = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidSecretKey", "Lorg/ldk/enums/Secp256k1Error;");
757         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidSecretKey != NULL);
758         Secp256k1Error_LDKSecp256k1Error_InvalidSharedSecret = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidSharedSecret", "Lorg/ldk/enums/Secp256k1Error;");
759         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidSharedSecret != NULL);
760         Secp256k1Error_LDKSecp256k1Error_InvalidRecoveryId = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidRecoveryId", "Lorg/ldk/enums/Secp256k1Error;");
761         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidRecoveryId != NULL);
762         Secp256k1Error_LDKSecp256k1Error_InvalidTweak = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidTweak", "Lorg/ldk/enums/Secp256k1Error;");
763         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidTweak != NULL);
764         Secp256k1Error_LDKSecp256k1Error_NotEnoughMemory = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_NotEnoughMemory", "Lorg/ldk/enums/Secp256k1Error;");
765         CHECK(Secp256k1Error_LDKSecp256k1Error_NotEnoughMemory != NULL);
766         Secp256k1Error_LDKSecp256k1Error_InvalidPublicKeySum = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidPublicKeySum", "Lorg/ldk/enums/Secp256k1Error;");
767         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidPublicKeySum != NULL);
768         Secp256k1Error_LDKSecp256k1Error_InvalidParityValue = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidParityValue", "Lorg/ldk/enums/Secp256k1Error;");
769         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidParityValue != NULL);
770 }
771 static inline jclass LDKSecp256k1Error_to_java(JNIEnv *env, LDKSecp256k1Error val) {
772         switch (val) {
773                 case LDKSecp256k1Error_IncorrectSignature:
774                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_IncorrectSignature);
775                 case LDKSecp256k1Error_InvalidMessage:
776                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidMessage);
777                 case LDKSecp256k1Error_InvalidPublicKey:
778                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidPublicKey);
779                 case LDKSecp256k1Error_InvalidSignature:
780                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidSignature);
781                 case LDKSecp256k1Error_InvalidSecretKey:
782                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidSecretKey);
783                 case LDKSecp256k1Error_InvalidSharedSecret:
784                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidSharedSecret);
785                 case LDKSecp256k1Error_InvalidRecoveryId:
786                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidRecoveryId);
787                 case LDKSecp256k1Error_InvalidTweak:
788                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidTweak);
789                 case LDKSecp256k1Error_NotEnoughMemory:
790                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_NotEnoughMemory);
791                 case LDKSecp256k1Error_InvalidPublicKeySum:
792                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidPublicKeySum);
793                 case LDKSecp256k1Error_InvalidParityValue:
794                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidParityValue);
795                 default: abort();
796         }
797 }
798
799 static inline LDKSemanticError LDKSemanticError_from_java(JNIEnv *env, jclass clz) {
800         jint ord = (*env)->CallIntMethod(env, clz, ordinal_meth);
801         if (UNLIKELY((*env)->ExceptionCheck(env))) {
802                 (*env)->ExceptionDescribe(env);
803                 (*env)->FatalError(env, "A call to SemanticError.ordinal() from rust threw an exception.");
804         }
805         switch (ord) {
806                 case 0: return LDKSemanticError_NoPaymentHash;
807                 case 1: return LDKSemanticError_MultiplePaymentHashes;
808                 case 2: return LDKSemanticError_NoDescription;
809                 case 3: return LDKSemanticError_MultipleDescriptions;
810                 case 4: return LDKSemanticError_NoPaymentSecret;
811                 case 5: return LDKSemanticError_MultiplePaymentSecrets;
812                 case 6: return LDKSemanticError_InvalidFeatures;
813                 case 7: return LDKSemanticError_InvalidRecoveryId;
814                 case 8: return LDKSemanticError_InvalidSignature;
815                 case 9: return LDKSemanticError_ImpreciseAmount;
816         }
817         (*env)->FatalError(env, "A call to SemanticError.ordinal() from rust returned an invalid value.");
818         abort(); // Unreachable, but will let the compiler know we don't return here
819 }
820 static jclass SemanticError_class = NULL;
821 static jfieldID SemanticError_LDKSemanticError_NoPaymentHash = NULL;
822 static jfieldID SemanticError_LDKSemanticError_MultiplePaymentHashes = NULL;
823 static jfieldID SemanticError_LDKSemanticError_NoDescription = NULL;
824 static jfieldID SemanticError_LDKSemanticError_MultipleDescriptions = NULL;
825 static jfieldID SemanticError_LDKSemanticError_NoPaymentSecret = NULL;
826 static jfieldID SemanticError_LDKSemanticError_MultiplePaymentSecrets = NULL;
827 static jfieldID SemanticError_LDKSemanticError_InvalidFeatures = NULL;
828 static jfieldID SemanticError_LDKSemanticError_InvalidRecoveryId = NULL;
829 static jfieldID SemanticError_LDKSemanticError_InvalidSignature = NULL;
830 static jfieldID SemanticError_LDKSemanticError_ImpreciseAmount = NULL;
831 JNIEXPORT void JNICALL Java_org_ldk_enums_SemanticError_init (JNIEnv *env, jclass clz) {
832         SemanticError_class = (*env)->NewGlobalRef(env, clz);
833         CHECK(SemanticError_class != NULL);
834         SemanticError_LDKSemanticError_NoPaymentHash = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_NoPaymentHash", "Lorg/ldk/enums/SemanticError;");
835         CHECK(SemanticError_LDKSemanticError_NoPaymentHash != NULL);
836         SemanticError_LDKSemanticError_MultiplePaymentHashes = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_MultiplePaymentHashes", "Lorg/ldk/enums/SemanticError;");
837         CHECK(SemanticError_LDKSemanticError_MultiplePaymentHashes != NULL);
838         SemanticError_LDKSemanticError_NoDescription = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_NoDescription", "Lorg/ldk/enums/SemanticError;");
839         CHECK(SemanticError_LDKSemanticError_NoDescription != NULL);
840         SemanticError_LDKSemanticError_MultipleDescriptions = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_MultipleDescriptions", "Lorg/ldk/enums/SemanticError;");
841         CHECK(SemanticError_LDKSemanticError_MultipleDescriptions != NULL);
842         SemanticError_LDKSemanticError_NoPaymentSecret = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_NoPaymentSecret", "Lorg/ldk/enums/SemanticError;");
843         CHECK(SemanticError_LDKSemanticError_NoPaymentSecret != NULL);
844         SemanticError_LDKSemanticError_MultiplePaymentSecrets = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_MultiplePaymentSecrets", "Lorg/ldk/enums/SemanticError;");
845         CHECK(SemanticError_LDKSemanticError_MultiplePaymentSecrets != NULL);
846         SemanticError_LDKSemanticError_InvalidFeatures = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_InvalidFeatures", "Lorg/ldk/enums/SemanticError;");
847         CHECK(SemanticError_LDKSemanticError_InvalidFeatures != NULL);
848         SemanticError_LDKSemanticError_InvalidRecoveryId = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_InvalidRecoveryId", "Lorg/ldk/enums/SemanticError;");
849         CHECK(SemanticError_LDKSemanticError_InvalidRecoveryId != NULL);
850         SemanticError_LDKSemanticError_InvalidSignature = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_InvalidSignature", "Lorg/ldk/enums/SemanticError;");
851         CHECK(SemanticError_LDKSemanticError_InvalidSignature != NULL);
852         SemanticError_LDKSemanticError_ImpreciseAmount = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_ImpreciseAmount", "Lorg/ldk/enums/SemanticError;");
853         CHECK(SemanticError_LDKSemanticError_ImpreciseAmount != NULL);
854 }
855 static inline jclass LDKSemanticError_to_java(JNIEnv *env, LDKSemanticError val) {
856         switch (val) {
857                 case LDKSemanticError_NoPaymentHash:
858                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_NoPaymentHash);
859                 case LDKSemanticError_MultiplePaymentHashes:
860                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_MultiplePaymentHashes);
861                 case LDKSemanticError_NoDescription:
862                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_NoDescription);
863                 case LDKSemanticError_MultipleDescriptions:
864                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_MultipleDescriptions);
865                 case LDKSemanticError_NoPaymentSecret:
866                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_NoPaymentSecret);
867                 case LDKSemanticError_MultiplePaymentSecrets:
868                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_MultiplePaymentSecrets);
869                 case LDKSemanticError_InvalidFeatures:
870                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_InvalidFeatures);
871                 case LDKSemanticError_InvalidRecoveryId:
872                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_InvalidRecoveryId);
873                 case LDKSemanticError_InvalidSignature:
874                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_InvalidSignature);
875                 case LDKSemanticError_ImpreciseAmount:
876                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_ImpreciseAmount);
877                 default: abort();
878         }
879 }
880
881 static inline LDKSiPrefix LDKSiPrefix_from_java(JNIEnv *env, jclass clz) {
882         jint ord = (*env)->CallIntMethod(env, clz, ordinal_meth);
883         if (UNLIKELY((*env)->ExceptionCheck(env))) {
884                 (*env)->ExceptionDescribe(env);
885                 (*env)->FatalError(env, "A call to SiPrefix.ordinal() from rust threw an exception.");
886         }
887         switch (ord) {
888                 case 0: return LDKSiPrefix_Milli;
889                 case 1: return LDKSiPrefix_Micro;
890                 case 2: return LDKSiPrefix_Nano;
891                 case 3: return LDKSiPrefix_Pico;
892         }
893         (*env)->FatalError(env, "A call to SiPrefix.ordinal() from rust returned an invalid value.");
894         abort(); // Unreachable, but will let the compiler know we don't return here
895 }
896 static jclass SiPrefix_class = NULL;
897 static jfieldID SiPrefix_LDKSiPrefix_Milli = NULL;
898 static jfieldID SiPrefix_LDKSiPrefix_Micro = NULL;
899 static jfieldID SiPrefix_LDKSiPrefix_Nano = NULL;
900 static jfieldID SiPrefix_LDKSiPrefix_Pico = NULL;
901 JNIEXPORT void JNICALL Java_org_ldk_enums_SiPrefix_init (JNIEnv *env, jclass clz) {
902         SiPrefix_class = (*env)->NewGlobalRef(env, clz);
903         CHECK(SiPrefix_class != NULL);
904         SiPrefix_LDKSiPrefix_Milli = (*env)->GetStaticFieldID(env, SiPrefix_class, "LDKSiPrefix_Milli", "Lorg/ldk/enums/SiPrefix;");
905         CHECK(SiPrefix_LDKSiPrefix_Milli != NULL);
906         SiPrefix_LDKSiPrefix_Micro = (*env)->GetStaticFieldID(env, SiPrefix_class, "LDKSiPrefix_Micro", "Lorg/ldk/enums/SiPrefix;");
907         CHECK(SiPrefix_LDKSiPrefix_Micro != NULL);
908         SiPrefix_LDKSiPrefix_Nano = (*env)->GetStaticFieldID(env, SiPrefix_class, "LDKSiPrefix_Nano", "Lorg/ldk/enums/SiPrefix;");
909         CHECK(SiPrefix_LDKSiPrefix_Nano != NULL);
910         SiPrefix_LDKSiPrefix_Pico = (*env)->GetStaticFieldID(env, SiPrefix_class, "LDKSiPrefix_Pico", "Lorg/ldk/enums/SiPrefix;");
911         CHECK(SiPrefix_LDKSiPrefix_Pico != NULL);
912 }
913 static inline jclass LDKSiPrefix_to_java(JNIEnv *env, LDKSiPrefix val) {
914         switch (val) {
915                 case LDKSiPrefix_Milli:
916                         return (*env)->GetStaticObjectField(env, SiPrefix_class, SiPrefix_LDKSiPrefix_Milli);
917                 case LDKSiPrefix_Micro:
918                         return (*env)->GetStaticObjectField(env, SiPrefix_class, SiPrefix_LDKSiPrefix_Micro);
919                 case LDKSiPrefix_Nano:
920                         return (*env)->GetStaticObjectField(env, SiPrefix_class, SiPrefix_LDKSiPrefix_Nano);
921                 case LDKSiPrefix_Pico:
922                         return (*env)->GetStaticObjectField(env, SiPrefix_class, SiPrefix_LDKSiPrefix_Pico);
923                 default: abort();
924         }
925 }
926
927 struct LDKThirtyTwoBytes BigEndianScalar_get_bytes (struct LDKBigEndianScalar* thing) {
928         LDKThirtyTwoBytes ret = { .data = *thing->big_endian_bytes };
929         return ret;
930 }
931 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BigEndianScalar_1get_1bytes(JNIEnv *env, jclass clz, int64_t thing) {
932         LDKBigEndianScalar* thing_conv = (LDKBigEndianScalar*)untag_ptr(thing);
933         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
934         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, BigEndianScalar_get_bytes(thing_conv).data);
935         return ret_arr;
936 }
937
938 static void BigEndianScalar_free (struct LDKBigEndianScalar thing) {}
939 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BigEndianScalar_1free(JNIEnv *env, jclass clz, int64_t thing) {
940         if (!ptr_is_owned(thing)) return;
941         void* thing_ptr = untag_ptr(thing);
942         CHECK_ACCESS(thing_ptr);
943         LDKBigEndianScalar thing_conv = *(LDKBigEndianScalar*)(thing_ptr);
944         FREE(untag_ptr(thing));
945         BigEndianScalar_free(thing_conv);
946 }
947
948 static jclass LDKBech32Error_MissingSeparator_class = NULL;
949 static jmethodID LDKBech32Error_MissingSeparator_meth = NULL;
950 static jclass LDKBech32Error_InvalidChecksum_class = NULL;
951 static jmethodID LDKBech32Error_InvalidChecksum_meth = NULL;
952 static jclass LDKBech32Error_InvalidLength_class = NULL;
953 static jmethodID LDKBech32Error_InvalidLength_meth = NULL;
954 static jclass LDKBech32Error_InvalidChar_class = NULL;
955 static jmethodID LDKBech32Error_InvalidChar_meth = NULL;
956 static jclass LDKBech32Error_InvalidData_class = NULL;
957 static jmethodID LDKBech32Error_InvalidData_meth = NULL;
958 static jclass LDKBech32Error_InvalidPadding_class = NULL;
959 static jmethodID LDKBech32Error_InvalidPadding_meth = NULL;
960 static jclass LDKBech32Error_MixedCase_class = NULL;
961 static jmethodID LDKBech32Error_MixedCase_meth = NULL;
962 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKBech32Error_init (JNIEnv *env, jclass clz) {
963         LDKBech32Error_MissingSeparator_class =
964                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBech32Error$MissingSeparator"));
965         CHECK(LDKBech32Error_MissingSeparator_class != NULL);
966         LDKBech32Error_MissingSeparator_meth = (*env)->GetMethodID(env, LDKBech32Error_MissingSeparator_class, "<init>", "()V");
967         CHECK(LDKBech32Error_MissingSeparator_meth != NULL);
968         LDKBech32Error_InvalidChecksum_class =
969                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBech32Error$InvalidChecksum"));
970         CHECK(LDKBech32Error_InvalidChecksum_class != NULL);
971         LDKBech32Error_InvalidChecksum_meth = (*env)->GetMethodID(env, LDKBech32Error_InvalidChecksum_class, "<init>", "()V");
972         CHECK(LDKBech32Error_InvalidChecksum_meth != NULL);
973         LDKBech32Error_InvalidLength_class =
974                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBech32Error$InvalidLength"));
975         CHECK(LDKBech32Error_InvalidLength_class != NULL);
976         LDKBech32Error_InvalidLength_meth = (*env)->GetMethodID(env, LDKBech32Error_InvalidLength_class, "<init>", "()V");
977         CHECK(LDKBech32Error_InvalidLength_meth != NULL);
978         LDKBech32Error_InvalidChar_class =
979                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBech32Error$InvalidChar"));
980         CHECK(LDKBech32Error_InvalidChar_class != NULL);
981         LDKBech32Error_InvalidChar_meth = (*env)->GetMethodID(env, LDKBech32Error_InvalidChar_class, "<init>", "(I)V");
982         CHECK(LDKBech32Error_InvalidChar_meth != NULL);
983         LDKBech32Error_InvalidData_class =
984                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBech32Error$InvalidData"));
985         CHECK(LDKBech32Error_InvalidData_class != NULL);
986         LDKBech32Error_InvalidData_meth = (*env)->GetMethodID(env, LDKBech32Error_InvalidData_class, "<init>", "(B)V");
987         CHECK(LDKBech32Error_InvalidData_meth != NULL);
988         LDKBech32Error_InvalidPadding_class =
989                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBech32Error$InvalidPadding"));
990         CHECK(LDKBech32Error_InvalidPadding_class != NULL);
991         LDKBech32Error_InvalidPadding_meth = (*env)->GetMethodID(env, LDKBech32Error_InvalidPadding_class, "<init>", "()V");
992         CHECK(LDKBech32Error_InvalidPadding_meth != NULL);
993         LDKBech32Error_MixedCase_class =
994                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBech32Error$MixedCase"));
995         CHECK(LDKBech32Error_MixedCase_class != NULL);
996         LDKBech32Error_MixedCase_meth = (*env)->GetMethodID(env, LDKBech32Error_MixedCase_class, "<init>", "()V");
997         CHECK(LDKBech32Error_MixedCase_meth != NULL);
998 }
999 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKBech32Error_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1000         LDKBech32Error *obj = (LDKBech32Error*)untag_ptr(ptr);
1001         switch(obj->tag) {
1002                 case LDKBech32Error_MissingSeparator: {
1003                         return (*env)->NewObject(env, LDKBech32Error_MissingSeparator_class, LDKBech32Error_MissingSeparator_meth);
1004                 }
1005                 case LDKBech32Error_InvalidChecksum: {
1006                         return (*env)->NewObject(env, LDKBech32Error_InvalidChecksum_class, LDKBech32Error_InvalidChecksum_meth);
1007                 }
1008                 case LDKBech32Error_InvalidLength: {
1009                         return (*env)->NewObject(env, LDKBech32Error_InvalidLength_class, LDKBech32Error_InvalidLength_meth);
1010                 }
1011                 case LDKBech32Error_InvalidChar: {
1012                         int32_t invalid_char_conv = obj->invalid_char;
1013                         return (*env)->NewObject(env, LDKBech32Error_InvalidChar_class, LDKBech32Error_InvalidChar_meth, invalid_char_conv);
1014                 }
1015                 case LDKBech32Error_InvalidData: {
1016                         int8_t invalid_data_conv = obj->invalid_data;
1017                         return (*env)->NewObject(env, LDKBech32Error_InvalidData_class, LDKBech32Error_InvalidData_meth, invalid_data_conv);
1018                 }
1019                 case LDKBech32Error_InvalidPadding: {
1020                         return (*env)->NewObject(env, LDKBech32Error_InvalidPadding_class, LDKBech32Error_InvalidPadding_meth);
1021                 }
1022                 case LDKBech32Error_MixedCase: {
1023                         return (*env)->NewObject(env, LDKBech32Error_MixedCase_class, LDKBech32Error_MixedCase_meth);
1024                 }
1025                 default: abort();
1026         }
1027 }
1028 static inline LDKCVec_u8Z CVec_u8Z_clone(const LDKCVec_u8Z *orig) {
1029         LDKCVec_u8Z ret = { .data = MALLOC(sizeof(int8_t) * orig->datalen, "LDKCVec_u8Z clone bytes"), .datalen = orig->datalen };
1030         memcpy(ret.data, orig->data, sizeof(int8_t) * ret.datalen);
1031         return ret;
1032 }
1033 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) {
1034         LDKTxOut* thing_conv = (LDKTxOut*)untag_ptr(thing);
1035         LDKCVec_u8Z ret_var = TxOut_get_script_pubkey(thing_conv);
1036         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
1037         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
1038         CVec_u8Z_free(ret_var);
1039         return ret_arr;
1040 }
1041
1042 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) {
1043         LDKTxOut* thing_conv = (LDKTxOut*)untag_ptr(thing);
1044         int64_t ret_conv = TxOut_get_value(thing_conv);
1045         return ret_conv;
1046 }
1047
1048 static jclass LDKCOption_HTLCClaimZ_Some_class = NULL;
1049 static jmethodID LDKCOption_HTLCClaimZ_Some_meth = NULL;
1050 static jclass LDKCOption_HTLCClaimZ_None_class = NULL;
1051 static jmethodID LDKCOption_HTLCClaimZ_None_meth = NULL;
1052 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1HTLCClaimZ_init (JNIEnv *env, jclass clz) {
1053         LDKCOption_HTLCClaimZ_Some_class =
1054                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_HTLCClaimZ$Some"));
1055         CHECK(LDKCOption_HTLCClaimZ_Some_class != NULL);
1056         LDKCOption_HTLCClaimZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_HTLCClaimZ_Some_class, "<init>", "(Lorg/ldk/enums/HTLCClaim;)V");
1057         CHECK(LDKCOption_HTLCClaimZ_Some_meth != NULL);
1058         LDKCOption_HTLCClaimZ_None_class =
1059                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_HTLCClaimZ$None"));
1060         CHECK(LDKCOption_HTLCClaimZ_None_class != NULL);
1061         LDKCOption_HTLCClaimZ_None_meth = (*env)->GetMethodID(env, LDKCOption_HTLCClaimZ_None_class, "<init>", "()V");
1062         CHECK(LDKCOption_HTLCClaimZ_None_meth != NULL);
1063 }
1064 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1HTLCClaimZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1065         LDKCOption_HTLCClaimZ *obj = (LDKCOption_HTLCClaimZ*)untag_ptr(ptr);
1066         switch(obj->tag) {
1067                 case LDKCOption_HTLCClaimZ_Some: {
1068                         jclass some_conv = LDKHTLCClaim_to_java(env, obj->some);
1069                         return (*env)->NewObject(env, LDKCOption_HTLCClaimZ_Some_class, LDKCOption_HTLCClaimZ_Some_meth, some_conv);
1070                 }
1071                 case LDKCOption_HTLCClaimZ_None: {
1072                         return (*env)->NewObject(env, LDKCOption_HTLCClaimZ_None_class, LDKCOption_HTLCClaimZ_None_meth);
1073                 }
1074                 default: abort();
1075         }
1076 }
1077 static inline void CResult_NoneNoneZ_get_ok(LDKCResult_NoneNoneZ *NONNULL_PTR owner){
1078 CHECK(owner->result_ok);
1079         return *owner->contents.result;
1080 }
1081 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1082         LDKCResult_NoneNoneZ* owner_conv = (LDKCResult_NoneNoneZ*)untag_ptr(owner);
1083         CResult_NoneNoneZ_get_ok(owner_conv);
1084 }
1085
1086 static inline void CResult_NoneNoneZ_get_err(LDKCResult_NoneNoneZ *NONNULL_PTR owner){
1087 CHECK(!owner->result_ok);
1088         return *owner->contents.err;
1089 }
1090 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1091         LDKCResult_NoneNoneZ* owner_conv = (LDKCResult_NoneNoneZ*)untag_ptr(owner);
1092         CResult_NoneNoneZ_get_err(owner_conv);
1093 }
1094
1095 static jclass LDKDecodeError_UnknownVersion_class = NULL;
1096 static jmethodID LDKDecodeError_UnknownVersion_meth = NULL;
1097 static jclass LDKDecodeError_UnknownRequiredFeature_class = NULL;
1098 static jmethodID LDKDecodeError_UnknownRequiredFeature_meth = NULL;
1099 static jclass LDKDecodeError_InvalidValue_class = NULL;
1100 static jmethodID LDKDecodeError_InvalidValue_meth = NULL;
1101 static jclass LDKDecodeError_ShortRead_class = NULL;
1102 static jmethodID LDKDecodeError_ShortRead_meth = NULL;
1103 static jclass LDKDecodeError_BadLengthDescriptor_class = NULL;
1104 static jmethodID LDKDecodeError_BadLengthDescriptor_meth = NULL;
1105 static jclass LDKDecodeError_Io_class = NULL;
1106 static jmethodID LDKDecodeError_Io_meth = NULL;
1107 static jclass LDKDecodeError_UnsupportedCompression_class = NULL;
1108 static jmethodID LDKDecodeError_UnsupportedCompression_meth = NULL;
1109 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKDecodeError_init (JNIEnv *env, jclass clz) {
1110         LDKDecodeError_UnknownVersion_class =
1111                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKDecodeError$UnknownVersion"));
1112         CHECK(LDKDecodeError_UnknownVersion_class != NULL);
1113         LDKDecodeError_UnknownVersion_meth = (*env)->GetMethodID(env, LDKDecodeError_UnknownVersion_class, "<init>", "()V");
1114         CHECK(LDKDecodeError_UnknownVersion_meth != NULL);
1115         LDKDecodeError_UnknownRequiredFeature_class =
1116                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKDecodeError$UnknownRequiredFeature"));
1117         CHECK(LDKDecodeError_UnknownRequiredFeature_class != NULL);
1118         LDKDecodeError_UnknownRequiredFeature_meth = (*env)->GetMethodID(env, LDKDecodeError_UnknownRequiredFeature_class, "<init>", "()V");
1119         CHECK(LDKDecodeError_UnknownRequiredFeature_meth != NULL);
1120         LDKDecodeError_InvalidValue_class =
1121                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKDecodeError$InvalidValue"));
1122         CHECK(LDKDecodeError_InvalidValue_class != NULL);
1123         LDKDecodeError_InvalidValue_meth = (*env)->GetMethodID(env, LDKDecodeError_InvalidValue_class, "<init>", "()V");
1124         CHECK(LDKDecodeError_InvalidValue_meth != NULL);
1125         LDKDecodeError_ShortRead_class =
1126                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKDecodeError$ShortRead"));
1127         CHECK(LDKDecodeError_ShortRead_class != NULL);
1128         LDKDecodeError_ShortRead_meth = (*env)->GetMethodID(env, LDKDecodeError_ShortRead_class, "<init>", "()V");
1129         CHECK(LDKDecodeError_ShortRead_meth != NULL);
1130         LDKDecodeError_BadLengthDescriptor_class =
1131                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKDecodeError$BadLengthDescriptor"));
1132         CHECK(LDKDecodeError_BadLengthDescriptor_class != NULL);
1133         LDKDecodeError_BadLengthDescriptor_meth = (*env)->GetMethodID(env, LDKDecodeError_BadLengthDescriptor_class, "<init>", "()V");
1134         CHECK(LDKDecodeError_BadLengthDescriptor_meth != NULL);
1135         LDKDecodeError_Io_class =
1136                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKDecodeError$Io"));
1137         CHECK(LDKDecodeError_Io_class != NULL);
1138         LDKDecodeError_Io_meth = (*env)->GetMethodID(env, LDKDecodeError_Io_class, "<init>", "(Lorg/ldk/enums/IOError;)V");
1139         CHECK(LDKDecodeError_Io_meth != NULL);
1140         LDKDecodeError_UnsupportedCompression_class =
1141                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKDecodeError$UnsupportedCompression"));
1142         CHECK(LDKDecodeError_UnsupportedCompression_class != NULL);
1143         LDKDecodeError_UnsupportedCompression_meth = (*env)->GetMethodID(env, LDKDecodeError_UnsupportedCompression_class, "<init>", "()V");
1144         CHECK(LDKDecodeError_UnsupportedCompression_meth != NULL);
1145 }
1146 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKDecodeError_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1147         LDKDecodeError *obj = (LDKDecodeError*)untag_ptr(ptr);
1148         switch(obj->tag) {
1149                 case LDKDecodeError_UnknownVersion: {
1150                         return (*env)->NewObject(env, LDKDecodeError_UnknownVersion_class, LDKDecodeError_UnknownVersion_meth);
1151                 }
1152                 case LDKDecodeError_UnknownRequiredFeature: {
1153                         return (*env)->NewObject(env, LDKDecodeError_UnknownRequiredFeature_class, LDKDecodeError_UnknownRequiredFeature_meth);
1154                 }
1155                 case LDKDecodeError_InvalidValue: {
1156                         return (*env)->NewObject(env, LDKDecodeError_InvalidValue_class, LDKDecodeError_InvalidValue_meth);
1157                 }
1158                 case LDKDecodeError_ShortRead: {
1159                         return (*env)->NewObject(env, LDKDecodeError_ShortRead_class, LDKDecodeError_ShortRead_meth);
1160                 }
1161                 case LDKDecodeError_BadLengthDescriptor: {
1162                         return (*env)->NewObject(env, LDKDecodeError_BadLengthDescriptor_class, LDKDecodeError_BadLengthDescriptor_meth);
1163                 }
1164                 case LDKDecodeError_Io: {
1165                         jclass io_conv = LDKIOError_to_java(env, obj->io);
1166                         return (*env)->NewObject(env, LDKDecodeError_Io_class, LDKDecodeError_Io_meth, io_conv);
1167                 }
1168                 case LDKDecodeError_UnsupportedCompression: {
1169                         return (*env)->NewObject(env, LDKDecodeError_UnsupportedCompression_class, LDKDecodeError_UnsupportedCompression_meth);
1170                 }
1171                 default: abort();
1172         }
1173 }
1174 static inline struct LDKCounterpartyCommitmentSecrets CResult_CounterpartyCommitmentSecretsDecodeErrorZ_get_ok(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ *NONNULL_PTR owner){
1175         LDKCounterpartyCommitmentSecrets ret = *owner->contents.result;
1176         ret.is_owned = false;
1177         return ret;
1178 }
1179 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyCommitmentSecretsDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1180         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* owner_conv = (LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ*)untag_ptr(owner);
1181         LDKCounterpartyCommitmentSecrets ret_var = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_get_ok(owner_conv);
1182         int64_t ret_ref = 0;
1183         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1184         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
1185         return ret_ref;
1186 }
1187
1188 static inline struct LDKDecodeError CResult_CounterpartyCommitmentSecretsDecodeErrorZ_get_err(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ *NONNULL_PTR owner){
1189 CHECK(!owner->result_ok);
1190         return DecodeError_clone(&*owner->contents.err);
1191 }
1192 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyCommitmentSecretsDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1193         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* owner_conv = (LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ*)untag_ptr(owner);
1194         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
1195         *ret_copy = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_get_err(owner_conv);
1196         int64_t ret_ref = tag_ptr(ret_copy, true);
1197         return ret_ref;
1198 }
1199
1200 static inline struct LDKTxCreationKeys CResult_TxCreationKeysDecodeErrorZ_get_ok(LDKCResult_TxCreationKeysDecodeErrorZ *NONNULL_PTR owner){
1201         LDKTxCreationKeys ret = *owner->contents.result;
1202         ret.is_owned = false;
1203         return ret;
1204 }
1205 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1206         LDKCResult_TxCreationKeysDecodeErrorZ* owner_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)untag_ptr(owner);
1207         LDKTxCreationKeys ret_var = CResult_TxCreationKeysDecodeErrorZ_get_ok(owner_conv);
1208         int64_t ret_ref = 0;
1209         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1210         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
1211         return ret_ref;
1212 }
1213
1214 static inline struct LDKDecodeError CResult_TxCreationKeysDecodeErrorZ_get_err(LDKCResult_TxCreationKeysDecodeErrorZ *NONNULL_PTR owner){
1215 CHECK(!owner->result_ok);
1216         return DecodeError_clone(&*owner->contents.err);
1217 }
1218 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1219         LDKCResult_TxCreationKeysDecodeErrorZ* owner_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)untag_ptr(owner);
1220         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
1221         *ret_copy = CResult_TxCreationKeysDecodeErrorZ_get_err(owner_conv);
1222         int64_t ret_ref = tag_ptr(ret_copy, true);
1223         return ret_ref;
1224 }
1225
1226 static inline struct LDKChannelPublicKeys CResult_ChannelPublicKeysDecodeErrorZ_get_ok(LDKCResult_ChannelPublicKeysDecodeErrorZ *NONNULL_PTR owner){
1227         LDKChannelPublicKeys ret = *owner->contents.result;
1228         ret.is_owned = false;
1229         return ret;
1230 }
1231 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1232         LDKCResult_ChannelPublicKeysDecodeErrorZ* owner_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)untag_ptr(owner);
1233         LDKChannelPublicKeys ret_var = CResult_ChannelPublicKeysDecodeErrorZ_get_ok(owner_conv);
1234         int64_t ret_ref = 0;
1235         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1236         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
1237         return ret_ref;
1238 }
1239
1240 static inline struct LDKDecodeError CResult_ChannelPublicKeysDecodeErrorZ_get_err(LDKCResult_ChannelPublicKeysDecodeErrorZ *NONNULL_PTR owner){
1241 CHECK(!owner->result_ok);
1242         return DecodeError_clone(&*owner->contents.err);
1243 }
1244 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1245         LDKCResult_ChannelPublicKeysDecodeErrorZ* owner_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)untag_ptr(owner);
1246         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
1247         *ret_copy = CResult_ChannelPublicKeysDecodeErrorZ_get_err(owner_conv);
1248         int64_t ret_ref = tag_ptr(ret_copy, true);
1249         return ret_ref;
1250 }
1251
1252 static jclass LDKCOption_u32Z_Some_class = NULL;
1253 static jmethodID LDKCOption_u32Z_Some_meth = NULL;
1254 static jclass LDKCOption_u32Z_None_class = NULL;
1255 static jmethodID LDKCOption_u32Z_None_meth = NULL;
1256 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1u32Z_init (JNIEnv *env, jclass clz) {
1257         LDKCOption_u32Z_Some_class =
1258                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_u32Z$Some"));
1259         CHECK(LDKCOption_u32Z_Some_class != NULL);
1260         LDKCOption_u32Z_Some_meth = (*env)->GetMethodID(env, LDKCOption_u32Z_Some_class, "<init>", "(I)V");
1261         CHECK(LDKCOption_u32Z_Some_meth != NULL);
1262         LDKCOption_u32Z_None_class =
1263                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_u32Z$None"));
1264         CHECK(LDKCOption_u32Z_None_class != NULL);
1265         LDKCOption_u32Z_None_meth = (*env)->GetMethodID(env, LDKCOption_u32Z_None_class, "<init>", "()V");
1266         CHECK(LDKCOption_u32Z_None_meth != NULL);
1267 }
1268 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1u32Z_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1269         LDKCOption_u32Z *obj = (LDKCOption_u32Z*)untag_ptr(ptr);
1270         switch(obj->tag) {
1271                 case LDKCOption_u32Z_Some: {
1272                         int32_t some_conv = obj->some;
1273                         return (*env)->NewObject(env, LDKCOption_u32Z_Some_class, LDKCOption_u32Z_Some_meth, some_conv);
1274                 }
1275                 case LDKCOption_u32Z_None: {
1276                         return (*env)->NewObject(env, LDKCOption_u32Z_None_class, LDKCOption_u32Z_None_meth);
1277                 }
1278                 default: abort();
1279         }
1280 }
1281 static inline struct LDKHTLCOutputInCommitment CResult_HTLCOutputInCommitmentDecodeErrorZ_get_ok(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ *NONNULL_PTR owner){
1282         LDKHTLCOutputInCommitment ret = *owner->contents.result;
1283         ret.is_owned = false;
1284         return ret;
1285 }
1286 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1287         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* owner_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)untag_ptr(owner);
1288         LDKHTLCOutputInCommitment ret_var = CResult_HTLCOutputInCommitmentDecodeErrorZ_get_ok(owner_conv);
1289         int64_t ret_ref = 0;
1290         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1291         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
1292         return ret_ref;
1293 }
1294
1295 static inline struct LDKDecodeError CResult_HTLCOutputInCommitmentDecodeErrorZ_get_err(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ *NONNULL_PTR owner){
1296 CHECK(!owner->result_ok);
1297         return DecodeError_clone(&*owner->contents.err);
1298 }
1299 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1300         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* owner_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)untag_ptr(owner);
1301         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
1302         *ret_copy = CResult_HTLCOutputInCommitmentDecodeErrorZ_get_err(owner_conv);
1303         int64_t ret_ref = tag_ptr(ret_copy, true);
1304         return ret_ref;
1305 }
1306
1307 static inline struct LDKCounterpartyChannelTransactionParameters CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_ok(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ *NONNULL_PTR owner){
1308         LDKCounterpartyChannelTransactionParameters ret = *owner->contents.result;
1309         ret.is_owned = false;
1310         return ret;
1311 }
1312 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1313         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* owner_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)untag_ptr(owner);
1314         LDKCounterpartyChannelTransactionParameters ret_var = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_ok(owner_conv);
1315         int64_t ret_ref = 0;
1316         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1317         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
1318         return ret_ref;
1319 }
1320
1321 static inline struct LDKDecodeError CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_err(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ *NONNULL_PTR owner){
1322 CHECK(!owner->result_ok);
1323         return DecodeError_clone(&*owner->contents.err);
1324 }
1325 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1326         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* owner_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)untag_ptr(owner);
1327         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
1328         *ret_copy = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_get_err(owner_conv);
1329         int64_t ret_ref = tag_ptr(ret_copy, true);
1330         return ret_ref;
1331 }
1332
1333 static inline struct LDKChannelTransactionParameters CResult_ChannelTransactionParametersDecodeErrorZ_get_ok(LDKCResult_ChannelTransactionParametersDecodeErrorZ *NONNULL_PTR owner){
1334         LDKChannelTransactionParameters ret = *owner->contents.result;
1335         ret.is_owned = false;
1336         return ret;
1337 }
1338 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1339         LDKCResult_ChannelTransactionParametersDecodeErrorZ* owner_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)untag_ptr(owner);
1340         LDKChannelTransactionParameters ret_var = CResult_ChannelTransactionParametersDecodeErrorZ_get_ok(owner_conv);
1341         int64_t ret_ref = 0;
1342         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1343         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
1344         return ret_ref;
1345 }
1346
1347 static inline struct LDKDecodeError CResult_ChannelTransactionParametersDecodeErrorZ_get_err(LDKCResult_ChannelTransactionParametersDecodeErrorZ *NONNULL_PTR owner){
1348 CHECK(!owner->result_ok);
1349         return DecodeError_clone(&*owner->contents.err);
1350 }
1351 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1352         LDKCResult_ChannelTransactionParametersDecodeErrorZ* owner_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)untag_ptr(owner);
1353         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
1354         *ret_copy = CResult_ChannelTransactionParametersDecodeErrorZ_get_err(owner_conv);
1355         int64_t ret_ref = tag_ptr(ret_copy, true);
1356         return ret_ref;
1357 }
1358
1359 static inline struct LDKHolderCommitmentTransaction CResult_HolderCommitmentTransactionDecodeErrorZ_get_ok(LDKCResult_HolderCommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
1360         LDKHolderCommitmentTransaction ret = *owner->contents.result;
1361         ret.is_owned = false;
1362         return ret;
1363 }
1364 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1365         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)untag_ptr(owner);
1366         LDKHolderCommitmentTransaction ret_var = CResult_HolderCommitmentTransactionDecodeErrorZ_get_ok(owner_conv);
1367         int64_t ret_ref = 0;
1368         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1369         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
1370         return ret_ref;
1371 }
1372
1373 static inline struct LDKDecodeError CResult_HolderCommitmentTransactionDecodeErrorZ_get_err(LDKCResult_HolderCommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
1374 CHECK(!owner->result_ok);
1375         return DecodeError_clone(&*owner->contents.err);
1376 }
1377 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1378         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)untag_ptr(owner);
1379         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
1380         *ret_copy = CResult_HolderCommitmentTransactionDecodeErrorZ_get_err(owner_conv);
1381         int64_t ret_ref = tag_ptr(ret_copy, true);
1382         return ret_ref;
1383 }
1384
1385 static inline struct LDKBuiltCommitmentTransaction CResult_BuiltCommitmentTransactionDecodeErrorZ_get_ok(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
1386         LDKBuiltCommitmentTransaction ret = *owner->contents.result;
1387         ret.is_owned = false;
1388         return ret;
1389 }
1390 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1391         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)untag_ptr(owner);
1392         LDKBuiltCommitmentTransaction ret_var = CResult_BuiltCommitmentTransactionDecodeErrorZ_get_ok(owner_conv);
1393         int64_t ret_ref = 0;
1394         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1395         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
1396         return ret_ref;
1397 }
1398
1399 static inline struct LDKDecodeError CResult_BuiltCommitmentTransactionDecodeErrorZ_get_err(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
1400 CHECK(!owner->result_ok);
1401         return DecodeError_clone(&*owner->contents.err);
1402 }
1403 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1404         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)untag_ptr(owner);
1405         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
1406         *ret_copy = CResult_BuiltCommitmentTransactionDecodeErrorZ_get_err(owner_conv);
1407         int64_t ret_ref = tag_ptr(ret_copy, true);
1408         return ret_ref;
1409 }
1410
1411 static inline struct LDKTrustedClosingTransaction CResult_TrustedClosingTransactionNoneZ_get_ok(LDKCResult_TrustedClosingTransactionNoneZ *NONNULL_PTR owner){
1412         LDKTrustedClosingTransaction ret = *owner->contents.result;
1413         ret.is_owned = false;
1414         return ret;
1415 }
1416 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedClosingTransactionNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1417         LDKCResult_TrustedClosingTransactionNoneZ* owner_conv = (LDKCResult_TrustedClosingTransactionNoneZ*)untag_ptr(owner);
1418         LDKTrustedClosingTransaction ret_var = CResult_TrustedClosingTransactionNoneZ_get_ok(owner_conv);
1419         int64_t ret_ref = 0;
1420         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1421         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
1422         return ret_ref;
1423 }
1424
1425 static inline void CResult_TrustedClosingTransactionNoneZ_get_err(LDKCResult_TrustedClosingTransactionNoneZ *NONNULL_PTR owner){
1426 CHECK(!owner->result_ok);
1427         return *owner->contents.err;
1428 }
1429 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedClosingTransactionNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1430         LDKCResult_TrustedClosingTransactionNoneZ* owner_conv = (LDKCResult_TrustedClosingTransactionNoneZ*)untag_ptr(owner);
1431         CResult_TrustedClosingTransactionNoneZ_get_err(owner_conv);
1432 }
1433
1434 static inline struct LDKCommitmentTransaction CResult_CommitmentTransactionDecodeErrorZ_get_ok(LDKCResult_CommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
1435         LDKCommitmentTransaction ret = *owner->contents.result;
1436         ret.is_owned = false;
1437         return ret;
1438 }
1439 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1440         LDKCResult_CommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)untag_ptr(owner);
1441         LDKCommitmentTransaction ret_var = CResult_CommitmentTransactionDecodeErrorZ_get_ok(owner_conv);
1442         int64_t ret_ref = 0;
1443         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1444         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
1445         return ret_ref;
1446 }
1447
1448 static inline struct LDKDecodeError CResult_CommitmentTransactionDecodeErrorZ_get_err(LDKCResult_CommitmentTransactionDecodeErrorZ *NONNULL_PTR owner){
1449 CHECK(!owner->result_ok);
1450         return DecodeError_clone(&*owner->contents.err);
1451 }
1452 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1453         LDKCResult_CommitmentTransactionDecodeErrorZ* owner_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)untag_ptr(owner);
1454         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
1455         *ret_copy = CResult_CommitmentTransactionDecodeErrorZ_get_err(owner_conv);
1456         int64_t ret_ref = tag_ptr(ret_copy, true);
1457         return ret_ref;
1458 }
1459
1460 static inline struct LDKTrustedCommitmentTransaction CResult_TrustedCommitmentTransactionNoneZ_get_ok(LDKCResult_TrustedCommitmentTransactionNoneZ *NONNULL_PTR owner){
1461         LDKTrustedCommitmentTransaction ret = *owner->contents.result;
1462         ret.is_owned = false;
1463         return ret;
1464 }
1465 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedCommitmentTransactionNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1466         LDKCResult_TrustedCommitmentTransactionNoneZ* owner_conv = (LDKCResult_TrustedCommitmentTransactionNoneZ*)untag_ptr(owner);
1467         LDKTrustedCommitmentTransaction ret_var = CResult_TrustedCommitmentTransactionNoneZ_get_ok(owner_conv);
1468         int64_t ret_ref = 0;
1469         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1470         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
1471         return ret_ref;
1472 }
1473
1474 static inline void CResult_TrustedCommitmentTransactionNoneZ_get_err(LDKCResult_TrustedCommitmentTransactionNoneZ *NONNULL_PTR owner){
1475 CHECK(!owner->result_ok);
1476         return *owner->contents.err;
1477 }
1478 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedCommitmentTransactionNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1479         LDKCResult_TrustedCommitmentTransactionNoneZ* owner_conv = (LDKCResult_TrustedCommitmentTransactionNoneZ*)untag_ptr(owner);
1480         CResult_TrustedCommitmentTransactionNoneZ_get_err(owner_conv);
1481 }
1482
1483 static inline struct LDKCVec_SignatureZ CResult_CVec_SignatureZNoneZ_get_ok(LDKCResult_CVec_SignatureZNoneZ *NONNULL_PTR owner){
1484 CHECK(owner->result_ok);
1485         return *owner->contents.result;
1486 }
1487 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1488         LDKCResult_CVec_SignatureZNoneZ* owner_conv = (LDKCResult_CVec_SignatureZNoneZ*)untag_ptr(owner);
1489         LDKCVec_SignatureZ ret_var = CResult_CVec_SignatureZNoneZ_get_ok(owner_conv);
1490         jobjectArray ret_arr = NULL;
1491         ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
1492         ;
1493         for (size_t i = 0; i < ret_var.datalen; i++) {
1494                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, 64);
1495                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, 64, ret_var.data[i].compact_form);
1496                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
1497         }
1498         
1499         return ret_arr;
1500 }
1501
1502 static inline void CResult_CVec_SignatureZNoneZ_get_err(LDKCResult_CVec_SignatureZNoneZ *NONNULL_PTR owner){
1503 CHECK(!owner->result_ok);
1504         return *owner->contents.err;
1505 }
1506 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1507         LDKCResult_CVec_SignatureZNoneZ* owner_conv = (LDKCResult_CVec_SignatureZNoneZ*)untag_ptr(owner);
1508         CResult_CVec_SignatureZNoneZ_get_err(owner_conv);
1509 }
1510
1511 static inline struct LDKShutdownScript CResult_ShutdownScriptDecodeErrorZ_get_ok(LDKCResult_ShutdownScriptDecodeErrorZ *NONNULL_PTR owner){
1512         LDKShutdownScript ret = *owner->contents.result;
1513         ret.is_owned = false;
1514         return ret;
1515 }
1516 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1517         LDKCResult_ShutdownScriptDecodeErrorZ* owner_conv = (LDKCResult_ShutdownScriptDecodeErrorZ*)untag_ptr(owner);
1518         LDKShutdownScript ret_var = CResult_ShutdownScriptDecodeErrorZ_get_ok(owner_conv);
1519         int64_t ret_ref = 0;
1520         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1521         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
1522         return ret_ref;
1523 }
1524
1525 static inline struct LDKDecodeError CResult_ShutdownScriptDecodeErrorZ_get_err(LDKCResult_ShutdownScriptDecodeErrorZ *NONNULL_PTR owner){
1526 CHECK(!owner->result_ok);
1527         return DecodeError_clone(&*owner->contents.err);
1528 }
1529 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1530         LDKCResult_ShutdownScriptDecodeErrorZ* owner_conv = (LDKCResult_ShutdownScriptDecodeErrorZ*)untag_ptr(owner);
1531         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
1532         *ret_copy = CResult_ShutdownScriptDecodeErrorZ_get_err(owner_conv);
1533         int64_t ret_ref = tag_ptr(ret_copy, true);
1534         return ret_ref;
1535 }
1536
1537 static inline struct LDKShutdownScript CResult_ShutdownScriptInvalidShutdownScriptZ_get_ok(LDKCResult_ShutdownScriptInvalidShutdownScriptZ *NONNULL_PTR owner){
1538         LDKShutdownScript ret = *owner->contents.result;
1539         ret.is_owned = false;
1540         return ret;
1541 }
1542 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptInvalidShutdownScriptZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1543         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* owner_conv = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)untag_ptr(owner);
1544         LDKShutdownScript ret_var = CResult_ShutdownScriptInvalidShutdownScriptZ_get_ok(owner_conv);
1545         int64_t ret_ref = 0;
1546         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1547         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
1548         return ret_ref;
1549 }
1550
1551 static inline struct LDKInvalidShutdownScript CResult_ShutdownScriptInvalidShutdownScriptZ_get_err(LDKCResult_ShutdownScriptInvalidShutdownScriptZ *NONNULL_PTR owner){
1552         LDKInvalidShutdownScript ret = *owner->contents.err;
1553         ret.is_owned = false;
1554         return ret;
1555 }
1556 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptInvalidShutdownScriptZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1557         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* owner_conv = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)untag_ptr(owner);
1558         LDKInvalidShutdownScript ret_var = CResult_ShutdownScriptInvalidShutdownScriptZ_get_err(owner_conv);
1559         int64_t ret_ref = 0;
1560         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1561         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
1562         return ret_ref;
1563 }
1564
1565 static inline struct LDKBlindedPath CResult_BlindedPathNoneZ_get_ok(LDKCResult_BlindedPathNoneZ *NONNULL_PTR owner){
1566         LDKBlindedPath ret = *owner->contents.result;
1567         ret.is_owned = false;
1568         return ret;
1569 }
1570 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedPathNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1571         LDKCResult_BlindedPathNoneZ* owner_conv = (LDKCResult_BlindedPathNoneZ*)untag_ptr(owner);
1572         LDKBlindedPath ret_var = CResult_BlindedPathNoneZ_get_ok(owner_conv);
1573         int64_t ret_ref = 0;
1574         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1575         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
1576         return ret_ref;
1577 }
1578
1579 static inline void CResult_BlindedPathNoneZ_get_err(LDKCResult_BlindedPathNoneZ *NONNULL_PTR owner){
1580 CHECK(!owner->result_ok);
1581         return *owner->contents.err;
1582 }
1583 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedPathNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1584         LDKCResult_BlindedPathNoneZ* owner_conv = (LDKCResult_BlindedPathNoneZ*)untag_ptr(owner);
1585         CResult_BlindedPathNoneZ_get_err(owner_conv);
1586 }
1587
1588 static inline struct LDKBlindedPath CResult_BlindedPathDecodeErrorZ_get_ok(LDKCResult_BlindedPathDecodeErrorZ *NONNULL_PTR owner){
1589         LDKBlindedPath ret = *owner->contents.result;
1590         ret.is_owned = false;
1591         return ret;
1592 }
1593 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedPathDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1594         LDKCResult_BlindedPathDecodeErrorZ* owner_conv = (LDKCResult_BlindedPathDecodeErrorZ*)untag_ptr(owner);
1595         LDKBlindedPath ret_var = CResult_BlindedPathDecodeErrorZ_get_ok(owner_conv);
1596         int64_t ret_ref = 0;
1597         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1598         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
1599         return ret_ref;
1600 }
1601
1602 static inline struct LDKDecodeError CResult_BlindedPathDecodeErrorZ_get_err(LDKCResult_BlindedPathDecodeErrorZ *NONNULL_PTR owner){
1603 CHECK(!owner->result_ok);
1604         return DecodeError_clone(&*owner->contents.err);
1605 }
1606 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedPathDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1607         LDKCResult_BlindedPathDecodeErrorZ* owner_conv = (LDKCResult_BlindedPathDecodeErrorZ*)untag_ptr(owner);
1608         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
1609         *ret_copy = CResult_BlindedPathDecodeErrorZ_get_err(owner_conv);
1610         int64_t ret_ref = tag_ptr(ret_copy, true);
1611         return ret_ref;
1612 }
1613
1614 static inline struct LDKBlindedHop CResult_BlindedHopDecodeErrorZ_get_ok(LDKCResult_BlindedHopDecodeErrorZ *NONNULL_PTR owner){
1615         LDKBlindedHop ret = *owner->contents.result;
1616         ret.is_owned = false;
1617         return ret;
1618 }
1619 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedHopDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
1620         LDKCResult_BlindedHopDecodeErrorZ* owner_conv = (LDKCResult_BlindedHopDecodeErrorZ*)untag_ptr(owner);
1621         LDKBlindedHop ret_var = CResult_BlindedHopDecodeErrorZ_get_ok(owner_conv);
1622         int64_t ret_ref = 0;
1623         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
1624         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
1625         return ret_ref;
1626 }
1627
1628 static inline struct LDKDecodeError CResult_BlindedHopDecodeErrorZ_get_err(LDKCResult_BlindedHopDecodeErrorZ *NONNULL_PTR owner){
1629 CHECK(!owner->result_ok);
1630         return DecodeError_clone(&*owner->contents.err);
1631 }
1632 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedHopDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
1633         LDKCResult_BlindedHopDecodeErrorZ* owner_conv = (LDKCResult_BlindedHopDecodeErrorZ*)untag_ptr(owner);
1634         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
1635         *ret_copy = CResult_BlindedHopDecodeErrorZ_get_err(owner_conv);
1636         int64_t ret_ref = tag_ptr(ret_copy, true);
1637         return ret_ref;
1638 }
1639
1640 static inline LDKCVec_RouteHopZ CVec_RouteHopZ_clone(const LDKCVec_RouteHopZ *orig) {
1641         LDKCVec_RouteHopZ ret = { .data = MALLOC(sizeof(LDKRouteHop) * orig->datalen, "LDKCVec_RouteHopZ clone bytes"), .datalen = orig->datalen };
1642         for (size_t i = 0; i < ret.datalen; i++) {
1643                 ret.data[i] = RouteHop_clone(&orig->data[i]);
1644         }
1645         return ret;
1646 }
1647 typedef struct LDKScore_JCalls {
1648         atomic_size_t refcnt;
1649         JavaVM *vm;
1650         jweak o;
1651         jmethodID channel_penalty_msat_meth;
1652         jmethodID payment_path_failed_meth;
1653         jmethodID payment_path_successful_meth;
1654         jmethodID probe_failed_meth;
1655         jmethodID probe_successful_meth;
1656         jmethodID write_meth;
1657 } LDKScore_JCalls;
1658 static void LDKScore_JCalls_free(void* this_arg) {
1659         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
1660         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
1661                 JNIEnv *env;
1662                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
1663                 if (get_jenv_res == JNI_EDETACHED) {
1664                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
1665                 } else {
1666                         DO_ASSERT(get_jenv_res == JNI_OK);
1667                 }
1668                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
1669                 if (get_jenv_res == JNI_EDETACHED) {
1670                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
1671                 }
1672                 FREE(j_calls);
1673         }
1674 }
1675 uint64_t channel_penalty_msat_LDKScore_jcall(const void* this_arg, uint64_t short_channel_id, const LDKNodeId * source, const LDKNodeId * target, LDKChannelUsage usage) {
1676         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
1677         JNIEnv *env;
1678         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
1679         if (get_jenv_res == JNI_EDETACHED) {
1680                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
1681         } else {
1682                 DO_ASSERT(get_jenv_res == JNI_OK);
1683         }
1684         int64_t short_channel_id_conv = short_channel_id;
1685         LDKNodeId source_var = *source;
1686         int64_t source_ref = 0;
1687         source_var = NodeId_clone(&source_var);
1688         CHECK_INNER_FIELD_ACCESS_OR_NULL(source_var);
1689         source_ref = tag_ptr(source_var.inner, source_var.is_owned);
1690         LDKNodeId target_var = *target;
1691         int64_t target_ref = 0;
1692         target_var = NodeId_clone(&target_var);
1693         CHECK_INNER_FIELD_ACCESS_OR_NULL(target_var);
1694         target_ref = tag_ptr(target_var.inner, target_var.is_owned);
1695         LDKChannelUsage usage_var = usage;
1696         int64_t usage_ref = 0;
1697         CHECK_INNER_FIELD_ACCESS_OR_NULL(usage_var);
1698         usage_ref = tag_ptr(usage_var.inner, usage_var.is_owned);
1699         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
1700         CHECK(obj != NULL);
1701         int64_t ret = (*env)->CallLongMethod(env, obj, j_calls->channel_penalty_msat_meth, short_channel_id_conv, source_ref, target_ref, usage_ref);
1702         if (UNLIKELY((*env)->ExceptionCheck(env))) {
1703                 (*env)->ExceptionDescribe(env);
1704                 (*env)->FatalError(env, "A call to channel_penalty_msat in LDKScore from rust threw an exception.");
1705         }
1706         if (get_jenv_res == JNI_EDETACHED) {
1707                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
1708         }
1709         return ret;
1710 }
1711 void payment_path_failed_LDKScore_jcall(void* this_arg, LDKCVec_RouteHopZ path, uint64_t short_channel_id) {
1712         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
1713         JNIEnv *env;
1714         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
1715         if (get_jenv_res == JNI_EDETACHED) {
1716                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
1717         } else {
1718                 DO_ASSERT(get_jenv_res == JNI_OK);
1719         }
1720         LDKCVec_RouteHopZ path_var = path;
1721         int64_tArray path_arr = NULL;
1722         path_arr = (*env)->NewLongArray(env, path_var.datalen);
1723         int64_t *path_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, path_arr, NULL);
1724         for (size_t k = 0; k < path_var.datalen; k++) {
1725                 LDKRouteHop path_conv_10_var = path_var.data[k];
1726                 int64_t path_conv_10_ref = 0;
1727                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
1728                 path_conv_10_ref = tag_ptr(path_conv_10_var.inner, path_conv_10_var.is_owned);
1729                 path_arr_ptr[k] = path_conv_10_ref;
1730         }
1731         (*env)->ReleasePrimitiveArrayCritical(env, path_arr, path_arr_ptr, 0);
1732         FREE(path_var.data);
1733         int64_t short_channel_id_conv = short_channel_id;
1734         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
1735         CHECK(obj != NULL);
1736         (*env)->CallVoidMethod(env, obj, j_calls->payment_path_failed_meth, path_arr, short_channel_id_conv);
1737         if (UNLIKELY((*env)->ExceptionCheck(env))) {
1738                 (*env)->ExceptionDescribe(env);
1739                 (*env)->FatalError(env, "A call to payment_path_failed in LDKScore from rust threw an exception.");
1740         }
1741         if (get_jenv_res == JNI_EDETACHED) {
1742                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
1743         }
1744 }
1745 void payment_path_successful_LDKScore_jcall(void* this_arg, LDKCVec_RouteHopZ path) {
1746         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
1747         JNIEnv *env;
1748         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
1749         if (get_jenv_res == JNI_EDETACHED) {
1750                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
1751         } else {
1752                 DO_ASSERT(get_jenv_res == JNI_OK);
1753         }
1754         LDKCVec_RouteHopZ path_var = path;
1755         int64_tArray path_arr = NULL;
1756         path_arr = (*env)->NewLongArray(env, path_var.datalen);
1757         int64_t *path_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, path_arr, NULL);
1758         for (size_t k = 0; k < path_var.datalen; k++) {
1759                 LDKRouteHop path_conv_10_var = path_var.data[k];
1760                 int64_t path_conv_10_ref = 0;
1761                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
1762                 path_conv_10_ref = tag_ptr(path_conv_10_var.inner, path_conv_10_var.is_owned);
1763                 path_arr_ptr[k] = path_conv_10_ref;
1764         }
1765         (*env)->ReleasePrimitiveArrayCritical(env, path_arr, path_arr_ptr, 0);
1766         FREE(path_var.data);
1767         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
1768         CHECK(obj != NULL);
1769         (*env)->CallVoidMethod(env, obj, j_calls->payment_path_successful_meth, path_arr);
1770         if (UNLIKELY((*env)->ExceptionCheck(env))) {
1771                 (*env)->ExceptionDescribe(env);
1772                 (*env)->FatalError(env, "A call to payment_path_successful in LDKScore from rust threw an exception.");
1773         }
1774         if (get_jenv_res == JNI_EDETACHED) {
1775                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
1776         }
1777 }
1778 void probe_failed_LDKScore_jcall(void* this_arg, LDKCVec_RouteHopZ path, uint64_t short_channel_id) {
1779         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
1780         JNIEnv *env;
1781         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
1782         if (get_jenv_res == JNI_EDETACHED) {
1783                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
1784         } else {
1785                 DO_ASSERT(get_jenv_res == JNI_OK);
1786         }
1787         LDKCVec_RouteHopZ path_var = path;
1788         int64_tArray path_arr = NULL;
1789         path_arr = (*env)->NewLongArray(env, path_var.datalen);
1790         int64_t *path_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, path_arr, NULL);
1791         for (size_t k = 0; k < path_var.datalen; k++) {
1792                 LDKRouteHop path_conv_10_var = path_var.data[k];
1793                 int64_t path_conv_10_ref = 0;
1794                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
1795                 path_conv_10_ref = tag_ptr(path_conv_10_var.inner, path_conv_10_var.is_owned);
1796                 path_arr_ptr[k] = path_conv_10_ref;
1797         }
1798         (*env)->ReleasePrimitiveArrayCritical(env, path_arr, path_arr_ptr, 0);
1799         FREE(path_var.data);
1800         int64_t short_channel_id_conv = short_channel_id;
1801         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
1802         CHECK(obj != NULL);
1803         (*env)->CallVoidMethod(env, obj, j_calls->probe_failed_meth, path_arr, short_channel_id_conv);
1804         if (UNLIKELY((*env)->ExceptionCheck(env))) {
1805                 (*env)->ExceptionDescribe(env);
1806                 (*env)->FatalError(env, "A call to probe_failed in LDKScore from rust threw an exception.");
1807         }
1808         if (get_jenv_res == JNI_EDETACHED) {
1809                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
1810         }
1811 }
1812 void probe_successful_LDKScore_jcall(void* this_arg, LDKCVec_RouteHopZ path) {
1813         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
1814         JNIEnv *env;
1815         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
1816         if (get_jenv_res == JNI_EDETACHED) {
1817                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
1818         } else {
1819                 DO_ASSERT(get_jenv_res == JNI_OK);
1820         }
1821         LDKCVec_RouteHopZ path_var = path;
1822         int64_tArray path_arr = NULL;
1823         path_arr = (*env)->NewLongArray(env, path_var.datalen);
1824         int64_t *path_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, path_arr, NULL);
1825         for (size_t k = 0; k < path_var.datalen; k++) {
1826                 LDKRouteHop path_conv_10_var = path_var.data[k];
1827                 int64_t path_conv_10_ref = 0;
1828                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
1829                 path_conv_10_ref = tag_ptr(path_conv_10_var.inner, path_conv_10_var.is_owned);
1830                 path_arr_ptr[k] = path_conv_10_ref;
1831         }
1832         (*env)->ReleasePrimitiveArrayCritical(env, path_arr, path_arr_ptr, 0);
1833         FREE(path_var.data);
1834         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
1835         CHECK(obj != NULL);
1836         (*env)->CallVoidMethod(env, obj, j_calls->probe_successful_meth, path_arr);
1837         if (UNLIKELY((*env)->ExceptionCheck(env))) {
1838                 (*env)->ExceptionDescribe(env);
1839                 (*env)->FatalError(env, "A call to probe_successful in LDKScore from rust threw an exception.");
1840         }
1841         if (get_jenv_res == JNI_EDETACHED) {
1842                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
1843         }
1844 }
1845 LDKCVec_u8Z write_LDKScore_jcall(const void* this_arg) {
1846         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
1847         JNIEnv *env;
1848         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
1849         if (get_jenv_res == JNI_EDETACHED) {
1850                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
1851         } else {
1852                 DO_ASSERT(get_jenv_res == JNI_OK);
1853         }
1854         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
1855         CHECK(obj != NULL);
1856         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->write_meth);
1857         if (UNLIKELY((*env)->ExceptionCheck(env))) {
1858                 (*env)->ExceptionDescribe(env);
1859                 (*env)->FatalError(env, "A call to write in LDKScore from rust threw an exception.");
1860         }
1861         LDKCVec_u8Z ret_ref;
1862         ret_ref.datalen = (*env)->GetArrayLength(env, ret);
1863         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
1864         (*env)->GetByteArrayRegion(env, ret, 0, ret_ref.datalen, ret_ref.data);
1865         if (get_jenv_res == JNI_EDETACHED) {
1866                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
1867         }
1868         return ret_ref;
1869 }
1870 static void LDKScore_JCalls_cloned(LDKScore* new_obj) {
1871         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) new_obj->this_arg;
1872         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
1873 }
1874 static inline LDKScore LDKScore_init (JNIEnv *env, jclass clz, jobject o) {
1875         jclass c = (*env)->GetObjectClass(env, o);
1876         CHECK(c != NULL);
1877         LDKScore_JCalls *calls = MALLOC(sizeof(LDKScore_JCalls), "LDKScore_JCalls");
1878         atomic_init(&calls->refcnt, 1);
1879         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
1880         calls->o = (*env)->NewWeakGlobalRef(env, o);
1881         calls->channel_penalty_msat_meth = (*env)->GetMethodID(env, c, "channel_penalty_msat", "(JJJJ)J");
1882         CHECK(calls->channel_penalty_msat_meth != NULL);
1883         calls->payment_path_failed_meth = (*env)->GetMethodID(env, c, "payment_path_failed", "([JJ)V");
1884         CHECK(calls->payment_path_failed_meth != NULL);
1885         calls->payment_path_successful_meth = (*env)->GetMethodID(env, c, "payment_path_successful", "([J)V");
1886         CHECK(calls->payment_path_successful_meth != NULL);
1887         calls->probe_failed_meth = (*env)->GetMethodID(env, c, "probe_failed", "([JJ)V");
1888         CHECK(calls->probe_failed_meth != NULL);
1889         calls->probe_successful_meth = (*env)->GetMethodID(env, c, "probe_successful", "([J)V");
1890         CHECK(calls->probe_successful_meth != NULL);
1891         calls->write_meth = (*env)->GetMethodID(env, c, "write", "()[B");
1892         CHECK(calls->write_meth != NULL);
1893
1894         LDKScore ret = {
1895                 .this_arg = (void*) calls,
1896                 .channel_penalty_msat = channel_penalty_msat_LDKScore_jcall,
1897                 .payment_path_failed = payment_path_failed_LDKScore_jcall,
1898                 .payment_path_successful = payment_path_successful_LDKScore_jcall,
1899                 .probe_failed = probe_failed_LDKScore_jcall,
1900                 .probe_successful = probe_successful_LDKScore_jcall,
1901                 .write = write_LDKScore_jcall,
1902                 .free = LDKScore_JCalls_free,
1903         };
1904         return ret;
1905 }
1906 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKScore_1new(JNIEnv *env, jclass clz, jobject o) {
1907         LDKScore *res_ptr = MALLOC(sizeof(LDKScore), "LDKScore");
1908         *res_ptr = LDKScore_init(env, clz, o);
1909         return tag_ptr(res_ptr, true);
1910 }
1911 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) {
1912         void* this_arg_ptr = untag_ptr(this_arg);
1913         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
1914         LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
1915         LDKNodeId source_conv;
1916         source_conv.inner = untag_ptr(source);
1917         source_conv.is_owned = ptr_is_owned(source);
1918         CHECK_INNER_FIELD_ACCESS_OR_NULL(source_conv);
1919         source_conv.is_owned = false;
1920         LDKNodeId target_conv;
1921         target_conv.inner = untag_ptr(target);
1922         target_conv.is_owned = ptr_is_owned(target);
1923         CHECK_INNER_FIELD_ACCESS_OR_NULL(target_conv);
1924         target_conv.is_owned = false;
1925         LDKChannelUsage usage_conv;
1926         usage_conv.inner = untag_ptr(usage);
1927         usage_conv.is_owned = ptr_is_owned(usage);
1928         CHECK_INNER_FIELD_ACCESS_OR_NULL(usage_conv);
1929         usage_conv = ChannelUsage_clone(&usage_conv);
1930         int64_t ret_conv = (this_arg_conv->channel_penalty_msat)(this_arg_conv->this_arg, short_channel_id, &source_conv, &target_conv, usage_conv);
1931         return ret_conv;
1932 }
1933
1934 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) {
1935         void* this_arg_ptr = untag_ptr(this_arg);
1936         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
1937         LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
1938         LDKCVec_RouteHopZ path_constr;
1939         path_constr.datalen = (*env)->GetArrayLength(env, path);
1940         if (path_constr.datalen > 0)
1941                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
1942         else
1943                 path_constr.data = NULL;
1944         int64_t* path_vals = (*env)->GetLongArrayElements (env, path, NULL);
1945         for (size_t k = 0; k < path_constr.datalen; k++) {
1946                 int64_t path_conv_10 = path_vals[k];
1947                 LDKRouteHop path_conv_10_conv;
1948                 path_conv_10_conv.inner = untag_ptr(path_conv_10);
1949                 path_conv_10_conv.is_owned = ptr_is_owned(path_conv_10);
1950                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
1951                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
1952                 path_constr.data[k] = path_conv_10_conv;
1953         }
1954         (*env)->ReleaseLongArrayElements(env, path, path_vals, 0);
1955         (this_arg_conv->payment_path_failed)(this_arg_conv->this_arg, path_constr, short_channel_id);
1956 }
1957
1958 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Score_1payment_1path_1successful(JNIEnv *env, jclass clz, int64_t this_arg, int64_tArray path) {
1959         void* this_arg_ptr = untag_ptr(this_arg);
1960         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
1961         LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
1962         LDKCVec_RouteHopZ path_constr;
1963         path_constr.datalen = (*env)->GetArrayLength(env, path);
1964         if (path_constr.datalen > 0)
1965                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
1966         else
1967                 path_constr.data = NULL;
1968         int64_t* path_vals = (*env)->GetLongArrayElements (env, path, NULL);
1969         for (size_t k = 0; k < path_constr.datalen; k++) {
1970                 int64_t path_conv_10 = path_vals[k];
1971                 LDKRouteHop path_conv_10_conv;
1972                 path_conv_10_conv.inner = untag_ptr(path_conv_10);
1973                 path_conv_10_conv.is_owned = ptr_is_owned(path_conv_10);
1974                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
1975                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
1976                 path_constr.data[k] = path_conv_10_conv;
1977         }
1978         (*env)->ReleaseLongArrayElements(env, path, path_vals, 0);
1979         (this_arg_conv->payment_path_successful)(this_arg_conv->this_arg, path_constr);
1980 }
1981
1982 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) {
1983         void* this_arg_ptr = untag_ptr(this_arg);
1984         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
1985         LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
1986         LDKCVec_RouteHopZ path_constr;
1987         path_constr.datalen = (*env)->GetArrayLength(env, path);
1988         if (path_constr.datalen > 0)
1989                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
1990         else
1991                 path_constr.data = NULL;
1992         int64_t* path_vals = (*env)->GetLongArrayElements (env, path, NULL);
1993         for (size_t k = 0; k < path_constr.datalen; k++) {
1994                 int64_t path_conv_10 = path_vals[k];
1995                 LDKRouteHop path_conv_10_conv;
1996                 path_conv_10_conv.inner = untag_ptr(path_conv_10);
1997                 path_conv_10_conv.is_owned = ptr_is_owned(path_conv_10);
1998                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
1999                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
2000                 path_constr.data[k] = path_conv_10_conv;
2001         }
2002         (*env)->ReleaseLongArrayElements(env, path, path_vals, 0);
2003         (this_arg_conv->probe_failed)(this_arg_conv->this_arg, path_constr, short_channel_id);
2004 }
2005
2006 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Score_1probe_1successful(JNIEnv *env, jclass clz, int64_t this_arg, int64_tArray path) {
2007         void* this_arg_ptr = untag_ptr(this_arg);
2008         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
2009         LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
2010         LDKCVec_RouteHopZ path_constr;
2011         path_constr.datalen = (*env)->GetArrayLength(env, path);
2012         if (path_constr.datalen > 0)
2013                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
2014         else
2015                 path_constr.data = NULL;
2016         int64_t* path_vals = (*env)->GetLongArrayElements (env, path, NULL);
2017         for (size_t k = 0; k < path_constr.datalen; k++) {
2018                 int64_t path_conv_10 = path_vals[k];
2019                 LDKRouteHop path_conv_10_conv;
2020                 path_conv_10_conv.inner = untag_ptr(path_conv_10);
2021                 path_conv_10_conv.is_owned = ptr_is_owned(path_conv_10);
2022                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
2023                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
2024                 path_constr.data[k] = path_conv_10_conv;
2025         }
2026         (*env)->ReleaseLongArrayElements(env, path, path_vals, 0);
2027         (this_arg_conv->probe_successful)(this_arg_conv->this_arg, path_constr);
2028 }
2029
2030 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Score_1write(JNIEnv *env, jclass clz, int64_t this_arg) {
2031         void* this_arg_ptr = untag_ptr(this_arg);
2032         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
2033         LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
2034         LDKCVec_u8Z ret_var = (this_arg_conv->write)(this_arg_conv->this_arg);
2035         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
2036         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
2037         CVec_u8Z_free(ret_var);
2038         return ret_arr;
2039 }
2040
2041 typedef struct LDKLockableScore_JCalls {
2042         atomic_size_t refcnt;
2043         JavaVM *vm;
2044         jweak o;
2045         jmethodID lock_meth;
2046 } LDKLockableScore_JCalls;
2047 static void LDKLockableScore_JCalls_free(void* this_arg) {
2048         LDKLockableScore_JCalls *j_calls = (LDKLockableScore_JCalls*) this_arg;
2049         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
2050                 JNIEnv *env;
2051                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2052                 if (get_jenv_res == JNI_EDETACHED) {
2053                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2054                 } else {
2055                         DO_ASSERT(get_jenv_res == JNI_OK);
2056                 }
2057                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
2058                 if (get_jenv_res == JNI_EDETACHED) {
2059                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2060                 }
2061                 FREE(j_calls);
2062         }
2063 }
2064 LDKScore lock_LDKLockableScore_jcall(const void* this_arg) {
2065         LDKLockableScore_JCalls *j_calls = (LDKLockableScore_JCalls*) this_arg;
2066         JNIEnv *env;
2067         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2068         if (get_jenv_res == JNI_EDETACHED) {
2069                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2070         } else {
2071                 DO_ASSERT(get_jenv_res == JNI_OK);
2072         }
2073         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2074         CHECK(obj != NULL);
2075         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->lock_meth);
2076         if (UNLIKELY((*env)->ExceptionCheck(env))) {
2077                 (*env)->ExceptionDescribe(env);
2078                 (*env)->FatalError(env, "A call to lock in LDKLockableScore from rust threw an exception.");
2079         }
2080         void* ret_ptr = untag_ptr(ret);
2081         CHECK_ACCESS(ret_ptr);
2082         LDKScore ret_conv = *(LDKScore*)(ret_ptr);
2083         if (ret_conv.free == LDKScore_JCalls_free) {
2084                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
2085                 LDKScore_JCalls_cloned(&ret_conv);
2086         }// WARNING: we may need a move here but no clone is available for LDKScore
2087         
2088         if (get_jenv_res == JNI_EDETACHED) {
2089                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2090         }
2091         return ret_conv;
2092 }
2093 static void LDKLockableScore_JCalls_cloned(LDKLockableScore* new_obj) {
2094         LDKLockableScore_JCalls *j_calls = (LDKLockableScore_JCalls*) new_obj->this_arg;
2095         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
2096 }
2097 static inline LDKLockableScore LDKLockableScore_init (JNIEnv *env, jclass clz, jobject o) {
2098         jclass c = (*env)->GetObjectClass(env, o);
2099         CHECK(c != NULL);
2100         LDKLockableScore_JCalls *calls = MALLOC(sizeof(LDKLockableScore_JCalls), "LDKLockableScore_JCalls");
2101         atomic_init(&calls->refcnt, 1);
2102         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
2103         calls->o = (*env)->NewWeakGlobalRef(env, o);
2104         calls->lock_meth = (*env)->GetMethodID(env, c, "lock", "()J");
2105         CHECK(calls->lock_meth != NULL);
2106
2107         LDKLockableScore ret = {
2108                 .this_arg = (void*) calls,
2109                 .lock = lock_LDKLockableScore_jcall,
2110                 .free = LDKLockableScore_JCalls_free,
2111         };
2112         return ret;
2113 }
2114 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKLockableScore_1new(JNIEnv *env, jclass clz, jobject o) {
2115         LDKLockableScore *res_ptr = MALLOC(sizeof(LDKLockableScore), "LDKLockableScore");
2116         *res_ptr = LDKLockableScore_init(env, clz, o);
2117         return tag_ptr(res_ptr, true);
2118 }
2119 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LockableScore_1lock(JNIEnv *env, jclass clz, int64_t this_arg) {
2120         void* this_arg_ptr = untag_ptr(this_arg);
2121         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
2122         LDKLockableScore* this_arg_conv = (LDKLockableScore*)this_arg_ptr;
2123         LDKScore* ret_ret = MALLOC(sizeof(LDKScore), "LDKScore");
2124         *ret_ret = (this_arg_conv->lock)(this_arg_conv->this_arg);
2125         return tag_ptr(ret_ret, true);
2126 }
2127
2128 typedef struct LDKWriteableScore_JCalls {
2129         atomic_size_t refcnt;
2130         JavaVM *vm;
2131         jweak o;
2132         LDKLockableScore_JCalls* LockableScore;
2133         jmethodID write_meth;
2134 } LDKWriteableScore_JCalls;
2135 static void LDKWriteableScore_JCalls_free(void* this_arg) {
2136         LDKWriteableScore_JCalls *j_calls = (LDKWriteableScore_JCalls*) this_arg;
2137         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
2138                 JNIEnv *env;
2139                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2140                 if (get_jenv_res == JNI_EDETACHED) {
2141                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2142                 } else {
2143                         DO_ASSERT(get_jenv_res == JNI_OK);
2144                 }
2145                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
2146                 if (get_jenv_res == JNI_EDETACHED) {
2147                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2148                 }
2149                 FREE(j_calls);
2150         }
2151 }
2152 LDKCVec_u8Z write_LDKWriteableScore_jcall(const void* this_arg) {
2153         LDKWriteableScore_JCalls *j_calls = (LDKWriteableScore_JCalls*) this_arg;
2154         JNIEnv *env;
2155         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2156         if (get_jenv_res == JNI_EDETACHED) {
2157                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2158         } else {
2159                 DO_ASSERT(get_jenv_res == JNI_OK);
2160         }
2161         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2162         CHECK(obj != NULL);
2163         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->write_meth);
2164         if (UNLIKELY((*env)->ExceptionCheck(env))) {
2165                 (*env)->ExceptionDescribe(env);
2166                 (*env)->FatalError(env, "A call to write in LDKWriteableScore from rust threw an exception.");
2167         }
2168         LDKCVec_u8Z ret_ref;
2169         ret_ref.datalen = (*env)->GetArrayLength(env, ret);
2170         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
2171         (*env)->GetByteArrayRegion(env, ret, 0, ret_ref.datalen, ret_ref.data);
2172         if (get_jenv_res == JNI_EDETACHED) {
2173                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2174         }
2175         return ret_ref;
2176 }
2177 static void LDKWriteableScore_JCalls_cloned(LDKWriteableScore* new_obj) {
2178         LDKWriteableScore_JCalls *j_calls = (LDKWriteableScore_JCalls*) new_obj->this_arg;
2179         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
2180         atomic_fetch_add_explicit(&j_calls->LockableScore->refcnt, 1, memory_order_release);
2181 }
2182 static inline LDKWriteableScore LDKWriteableScore_init (JNIEnv *env, jclass clz, jobject o, jobject LockableScore) {
2183         jclass c = (*env)->GetObjectClass(env, o);
2184         CHECK(c != NULL);
2185         LDKWriteableScore_JCalls *calls = MALLOC(sizeof(LDKWriteableScore_JCalls), "LDKWriteableScore_JCalls");
2186         atomic_init(&calls->refcnt, 1);
2187         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
2188         calls->o = (*env)->NewWeakGlobalRef(env, o);
2189         calls->write_meth = (*env)->GetMethodID(env, c, "write", "()[B");
2190         CHECK(calls->write_meth != NULL);
2191
2192         LDKWriteableScore ret = {
2193                 .this_arg = (void*) calls,
2194                 .write = write_LDKWriteableScore_jcall,
2195                 .free = LDKWriteableScore_JCalls_free,
2196                 .LockableScore = LDKLockableScore_init(env, clz, LockableScore),
2197         };
2198         calls->LockableScore = ret.LockableScore.this_arg;
2199         return ret;
2200 }
2201 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKWriteableScore_1new(JNIEnv *env, jclass clz, jobject o, jobject LockableScore) {
2202         LDKWriteableScore *res_ptr = MALLOC(sizeof(LDKWriteableScore), "LDKWriteableScore");
2203         *res_ptr = LDKWriteableScore_init(env, clz, o, LockableScore);
2204         return tag_ptr(res_ptr, true);
2205 }
2206 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKWriteableScore_1get_1LockableScore(JNIEnv *env, jclass clz, int64_t arg) {
2207         LDKWriteableScore *inp = (LDKWriteableScore *)untag_ptr(arg);
2208         return tag_ptr(&inp->LockableScore, false);
2209 }
2210 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_WriteableScore_1write(JNIEnv *env, jclass clz, int64_t this_arg) {
2211         void* this_arg_ptr = untag_ptr(this_arg);
2212         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
2213         LDKWriteableScore* this_arg_conv = (LDKWriteableScore*)this_arg_ptr;
2214         LDKCVec_u8Z ret_var = (this_arg_conv->write)(this_arg_conv->this_arg);
2215         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
2216         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
2217         CVec_u8Z_free(ret_var);
2218         return ret_arr;
2219 }
2220
2221 static jclass LDKCOption_WriteableScoreZ_Some_class = NULL;
2222 static jmethodID LDKCOption_WriteableScoreZ_Some_meth = NULL;
2223 static jclass LDKCOption_WriteableScoreZ_None_class = NULL;
2224 static jmethodID LDKCOption_WriteableScoreZ_None_meth = NULL;
2225 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1WriteableScoreZ_init (JNIEnv *env, jclass clz) {
2226         LDKCOption_WriteableScoreZ_Some_class =
2227                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_WriteableScoreZ$Some"));
2228         CHECK(LDKCOption_WriteableScoreZ_Some_class != NULL);
2229         LDKCOption_WriteableScoreZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_WriteableScoreZ_Some_class, "<init>", "(J)V");
2230         CHECK(LDKCOption_WriteableScoreZ_Some_meth != NULL);
2231         LDKCOption_WriteableScoreZ_None_class =
2232                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_WriteableScoreZ$None"));
2233         CHECK(LDKCOption_WriteableScoreZ_None_class != NULL);
2234         LDKCOption_WriteableScoreZ_None_meth = (*env)->GetMethodID(env, LDKCOption_WriteableScoreZ_None_class, "<init>", "()V");
2235         CHECK(LDKCOption_WriteableScoreZ_None_meth != NULL);
2236 }
2237 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1WriteableScoreZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2238         LDKCOption_WriteableScoreZ *obj = (LDKCOption_WriteableScoreZ*)untag_ptr(ptr);
2239         switch(obj->tag) {
2240                 case LDKCOption_WriteableScoreZ_Some: {
2241                         LDKWriteableScore* some_ret = MALLOC(sizeof(LDKWriteableScore), "LDKWriteableScore");
2242                         *some_ret = obj->some;
2243                         // WARNING: We likely need to clone here, but no clone is available, so we just do it for Java instances
2244                         if ((*some_ret).free == LDKWriteableScore_JCalls_free) {
2245                                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
2246                                 LDKWriteableScore_JCalls_cloned(&(*some_ret));
2247                         }
2248                         return (*env)->NewObject(env, LDKCOption_WriteableScoreZ_Some_class, LDKCOption_WriteableScoreZ_Some_meth, tag_ptr(some_ret, true));
2249                 }
2250                 case LDKCOption_WriteableScoreZ_None: {
2251                         return (*env)->NewObject(env, LDKCOption_WriteableScoreZ_None_class, LDKCOption_WriteableScoreZ_None_meth);
2252                 }
2253                 default: abort();
2254         }
2255 }
2256 static inline void CResult_NoneErrorZ_get_ok(LDKCResult_NoneErrorZ *NONNULL_PTR owner){
2257 CHECK(owner->result_ok);
2258         return *owner->contents.result;
2259 }
2260 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
2261         LDKCResult_NoneErrorZ* owner_conv = (LDKCResult_NoneErrorZ*)untag_ptr(owner);
2262         CResult_NoneErrorZ_get_ok(owner_conv);
2263 }
2264
2265 static inline enum LDKIOError CResult_NoneErrorZ_get_err(LDKCResult_NoneErrorZ *NONNULL_PTR owner){
2266 CHECK(!owner->result_ok);
2267         return *owner->contents.err;
2268 }
2269 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
2270         LDKCResult_NoneErrorZ* owner_conv = (LDKCResult_NoneErrorZ*)untag_ptr(owner);
2271         jclass ret_conv = LDKIOError_to_java(env, CResult_NoneErrorZ_get_err(owner_conv));
2272         return ret_conv;
2273 }
2274
2275 static inline LDKCVec_ChannelDetailsZ CVec_ChannelDetailsZ_clone(const LDKCVec_ChannelDetailsZ *orig) {
2276         LDKCVec_ChannelDetailsZ ret = { .data = MALLOC(sizeof(LDKChannelDetails) * orig->datalen, "LDKCVec_ChannelDetailsZ clone bytes"), .datalen = orig->datalen };
2277         for (size_t i = 0; i < ret.datalen; i++) {
2278                 ret.data[i] = ChannelDetails_clone(&orig->data[i]);
2279         }
2280         return ret;
2281 }
2282 static inline struct LDKRoute CResult_RouteLightningErrorZ_get_ok(LDKCResult_RouteLightningErrorZ *NONNULL_PTR owner){
2283         LDKRoute ret = *owner->contents.result;
2284         ret.is_owned = false;
2285         return ret;
2286 }
2287 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
2288         LDKCResult_RouteLightningErrorZ* owner_conv = (LDKCResult_RouteLightningErrorZ*)untag_ptr(owner);
2289         LDKRoute ret_var = CResult_RouteLightningErrorZ_get_ok(owner_conv);
2290         int64_t ret_ref = 0;
2291         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2292         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
2293         return ret_ref;
2294 }
2295
2296 static inline struct LDKLightningError CResult_RouteLightningErrorZ_get_err(LDKCResult_RouteLightningErrorZ *NONNULL_PTR owner){
2297         LDKLightningError ret = *owner->contents.err;
2298         ret.is_owned = false;
2299         return ret;
2300 }
2301 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
2302         LDKCResult_RouteLightningErrorZ* owner_conv = (LDKCResult_RouteLightningErrorZ*)untag_ptr(owner);
2303         LDKLightningError ret_var = CResult_RouteLightningErrorZ_get_err(owner_conv);
2304         int64_t ret_ref = 0;
2305         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2306         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
2307         return ret_ref;
2308 }
2309
2310 static jclass LDKCOption_u64Z_Some_class = NULL;
2311 static jmethodID LDKCOption_u64Z_Some_meth = NULL;
2312 static jclass LDKCOption_u64Z_None_class = NULL;
2313 static jmethodID LDKCOption_u64Z_None_meth = NULL;
2314 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1u64Z_init (JNIEnv *env, jclass clz) {
2315         LDKCOption_u64Z_Some_class =
2316                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_u64Z$Some"));
2317         CHECK(LDKCOption_u64Z_Some_class != NULL);
2318         LDKCOption_u64Z_Some_meth = (*env)->GetMethodID(env, LDKCOption_u64Z_Some_class, "<init>", "(J)V");
2319         CHECK(LDKCOption_u64Z_Some_meth != NULL);
2320         LDKCOption_u64Z_None_class =
2321                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_u64Z$None"));
2322         CHECK(LDKCOption_u64Z_None_class != NULL);
2323         LDKCOption_u64Z_None_meth = (*env)->GetMethodID(env, LDKCOption_u64Z_None_class, "<init>", "()V");
2324         CHECK(LDKCOption_u64Z_None_meth != NULL);
2325 }
2326 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1u64Z_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2327         LDKCOption_u64Z *obj = (LDKCOption_u64Z*)untag_ptr(ptr);
2328         switch(obj->tag) {
2329                 case LDKCOption_u64Z_Some: {
2330                         int64_t some_conv = obj->some;
2331                         return (*env)->NewObject(env, LDKCOption_u64Z_Some_class, LDKCOption_u64Z_Some_meth, some_conv);
2332                 }
2333                 case LDKCOption_u64Z_None: {
2334                         return (*env)->NewObject(env, LDKCOption_u64Z_None_class, LDKCOption_u64Z_None_meth);
2335                 }
2336                 default: abort();
2337         }
2338 }
2339 static inline struct LDKInFlightHtlcs CResult_InFlightHtlcsDecodeErrorZ_get_ok(LDKCResult_InFlightHtlcsDecodeErrorZ *NONNULL_PTR owner){
2340         LDKInFlightHtlcs ret = *owner->contents.result;
2341         ret.is_owned = false;
2342         return ret;
2343 }
2344 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InFlightHtlcsDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
2345         LDKCResult_InFlightHtlcsDecodeErrorZ* owner_conv = (LDKCResult_InFlightHtlcsDecodeErrorZ*)untag_ptr(owner);
2346         LDKInFlightHtlcs ret_var = CResult_InFlightHtlcsDecodeErrorZ_get_ok(owner_conv);
2347         int64_t ret_ref = 0;
2348         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2349         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
2350         return ret_ref;
2351 }
2352
2353 static inline struct LDKDecodeError CResult_InFlightHtlcsDecodeErrorZ_get_err(LDKCResult_InFlightHtlcsDecodeErrorZ *NONNULL_PTR owner){
2354 CHECK(!owner->result_ok);
2355         return DecodeError_clone(&*owner->contents.err);
2356 }
2357 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InFlightHtlcsDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
2358         LDKCResult_InFlightHtlcsDecodeErrorZ* owner_conv = (LDKCResult_InFlightHtlcsDecodeErrorZ*)untag_ptr(owner);
2359         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
2360         *ret_copy = CResult_InFlightHtlcsDecodeErrorZ_get_err(owner_conv);
2361         int64_t ret_ref = tag_ptr(ret_copy, true);
2362         return ret_ref;
2363 }
2364
2365 static inline struct LDKRouteHop CResult_RouteHopDecodeErrorZ_get_ok(LDKCResult_RouteHopDecodeErrorZ *NONNULL_PTR owner){
2366         LDKRouteHop ret = *owner->contents.result;
2367         ret.is_owned = false;
2368         return ret;
2369 }
2370 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
2371         LDKCResult_RouteHopDecodeErrorZ* owner_conv = (LDKCResult_RouteHopDecodeErrorZ*)untag_ptr(owner);
2372         LDKRouteHop ret_var = CResult_RouteHopDecodeErrorZ_get_ok(owner_conv);
2373         int64_t ret_ref = 0;
2374         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2375         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
2376         return ret_ref;
2377 }
2378
2379 static inline struct LDKDecodeError CResult_RouteHopDecodeErrorZ_get_err(LDKCResult_RouteHopDecodeErrorZ *NONNULL_PTR owner){
2380 CHECK(!owner->result_ok);
2381         return DecodeError_clone(&*owner->contents.err);
2382 }
2383 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
2384         LDKCResult_RouteHopDecodeErrorZ* owner_conv = (LDKCResult_RouteHopDecodeErrorZ*)untag_ptr(owner);
2385         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
2386         *ret_copy = CResult_RouteHopDecodeErrorZ_get_err(owner_conv);
2387         int64_t ret_ref = tag_ptr(ret_copy, true);
2388         return ret_ref;
2389 }
2390
2391 static inline LDKCVec_CVec_RouteHopZZ CVec_CVec_RouteHopZZ_clone(const LDKCVec_CVec_RouteHopZZ *orig) {
2392         LDKCVec_CVec_RouteHopZZ ret = { .data = MALLOC(sizeof(LDKCVec_RouteHopZ) * orig->datalen, "LDKCVec_CVec_RouteHopZZ clone bytes"), .datalen = orig->datalen };
2393         for (size_t i = 0; i < ret.datalen; i++) {
2394                 ret.data[i] = CVec_RouteHopZ_clone(&orig->data[i]);
2395         }
2396         return ret;
2397 }
2398 static inline struct LDKRoute CResult_RouteDecodeErrorZ_get_ok(LDKCResult_RouteDecodeErrorZ *NONNULL_PTR owner){
2399         LDKRoute ret = *owner->contents.result;
2400         ret.is_owned = false;
2401         return ret;
2402 }
2403 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
2404         LDKCResult_RouteDecodeErrorZ* owner_conv = (LDKCResult_RouteDecodeErrorZ*)untag_ptr(owner);
2405         LDKRoute ret_var = CResult_RouteDecodeErrorZ_get_ok(owner_conv);
2406         int64_t ret_ref = 0;
2407         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2408         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
2409         return ret_ref;
2410 }
2411
2412 static inline struct LDKDecodeError CResult_RouteDecodeErrorZ_get_err(LDKCResult_RouteDecodeErrorZ *NONNULL_PTR owner){
2413 CHECK(!owner->result_ok);
2414         return DecodeError_clone(&*owner->contents.err);
2415 }
2416 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
2417         LDKCResult_RouteDecodeErrorZ* owner_conv = (LDKCResult_RouteDecodeErrorZ*)untag_ptr(owner);
2418         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
2419         *ret_copy = CResult_RouteDecodeErrorZ_get_err(owner_conv);
2420         int64_t ret_ref = tag_ptr(ret_copy, true);
2421         return ret_ref;
2422 }
2423
2424 static inline struct LDKRouteParameters CResult_RouteParametersDecodeErrorZ_get_ok(LDKCResult_RouteParametersDecodeErrorZ *NONNULL_PTR owner){
2425         LDKRouteParameters ret = *owner->contents.result;
2426         ret.is_owned = false;
2427         return ret;
2428 }
2429 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteParametersDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
2430         LDKCResult_RouteParametersDecodeErrorZ* owner_conv = (LDKCResult_RouteParametersDecodeErrorZ*)untag_ptr(owner);
2431         LDKRouteParameters ret_var = CResult_RouteParametersDecodeErrorZ_get_ok(owner_conv);
2432         int64_t ret_ref = 0;
2433         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2434         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
2435         return ret_ref;
2436 }
2437
2438 static inline struct LDKDecodeError CResult_RouteParametersDecodeErrorZ_get_err(LDKCResult_RouteParametersDecodeErrorZ *NONNULL_PTR owner){
2439 CHECK(!owner->result_ok);
2440         return DecodeError_clone(&*owner->contents.err);
2441 }
2442 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteParametersDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
2443         LDKCResult_RouteParametersDecodeErrorZ* owner_conv = (LDKCResult_RouteParametersDecodeErrorZ*)untag_ptr(owner);
2444         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
2445         *ret_copy = CResult_RouteParametersDecodeErrorZ_get_err(owner_conv);
2446         int64_t ret_ref = tag_ptr(ret_copy, true);
2447         return ret_ref;
2448 }
2449
2450 static inline LDKCVec_RouteHintZ CVec_RouteHintZ_clone(const LDKCVec_RouteHintZ *orig) {
2451         LDKCVec_RouteHintZ ret = { .data = MALLOC(sizeof(LDKRouteHint) * orig->datalen, "LDKCVec_RouteHintZ clone bytes"), .datalen = orig->datalen };
2452         for (size_t i = 0; i < ret.datalen; i++) {
2453                 ret.data[i] = RouteHint_clone(&orig->data[i]);
2454         }
2455         return ret;
2456 }
2457 static inline LDKCVec_u64Z CVec_u64Z_clone(const LDKCVec_u64Z *orig) {
2458         LDKCVec_u64Z ret = { .data = MALLOC(sizeof(int64_t) * orig->datalen, "LDKCVec_u64Z clone bytes"), .datalen = orig->datalen };
2459         memcpy(ret.data, orig->data, sizeof(int64_t) * ret.datalen);
2460         return ret;
2461 }
2462 static inline struct LDKPaymentParameters CResult_PaymentParametersDecodeErrorZ_get_ok(LDKCResult_PaymentParametersDecodeErrorZ *NONNULL_PTR owner){
2463         LDKPaymentParameters ret = *owner->contents.result;
2464         ret.is_owned = false;
2465         return ret;
2466 }
2467 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentParametersDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
2468         LDKCResult_PaymentParametersDecodeErrorZ* owner_conv = (LDKCResult_PaymentParametersDecodeErrorZ*)untag_ptr(owner);
2469         LDKPaymentParameters ret_var = CResult_PaymentParametersDecodeErrorZ_get_ok(owner_conv);
2470         int64_t ret_ref = 0;
2471         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2472         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
2473         return ret_ref;
2474 }
2475
2476 static inline struct LDKDecodeError CResult_PaymentParametersDecodeErrorZ_get_err(LDKCResult_PaymentParametersDecodeErrorZ *NONNULL_PTR owner){
2477 CHECK(!owner->result_ok);
2478         return DecodeError_clone(&*owner->contents.err);
2479 }
2480 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentParametersDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
2481         LDKCResult_PaymentParametersDecodeErrorZ* owner_conv = (LDKCResult_PaymentParametersDecodeErrorZ*)untag_ptr(owner);
2482         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
2483         *ret_copy = CResult_PaymentParametersDecodeErrorZ_get_err(owner_conv);
2484         int64_t ret_ref = tag_ptr(ret_copy, true);
2485         return ret_ref;
2486 }
2487
2488 static inline LDKCVec_RouteHintHopZ CVec_RouteHintHopZ_clone(const LDKCVec_RouteHintHopZ *orig) {
2489         LDKCVec_RouteHintHopZ ret = { .data = MALLOC(sizeof(LDKRouteHintHop) * orig->datalen, "LDKCVec_RouteHintHopZ clone bytes"), .datalen = orig->datalen };
2490         for (size_t i = 0; i < ret.datalen; i++) {
2491                 ret.data[i] = RouteHintHop_clone(&orig->data[i]);
2492         }
2493         return ret;
2494 }
2495 static inline struct LDKRouteHint CResult_RouteHintDecodeErrorZ_get_ok(LDKCResult_RouteHintDecodeErrorZ *NONNULL_PTR owner){
2496         LDKRouteHint ret = *owner->contents.result;
2497         ret.is_owned = false;
2498         return ret;
2499 }
2500 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
2501         LDKCResult_RouteHintDecodeErrorZ* owner_conv = (LDKCResult_RouteHintDecodeErrorZ*)untag_ptr(owner);
2502         LDKRouteHint ret_var = CResult_RouteHintDecodeErrorZ_get_ok(owner_conv);
2503         int64_t ret_ref = 0;
2504         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2505         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
2506         return ret_ref;
2507 }
2508
2509 static inline struct LDKDecodeError CResult_RouteHintDecodeErrorZ_get_err(LDKCResult_RouteHintDecodeErrorZ *NONNULL_PTR owner){
2510 CHECK(!owner->result_ok);
2511         return DecodeError_clone(&*owner->contents.err);
2512 }
2513 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
2514         LDKCResult_RouteHintDecodeErrorZ* owner_conv = (LDKCResult_RouteHintDecodeErrorZ*)untag_ptr(owner);
2515         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
2516         *ret_copy = CResult_RouteHintDecodeErrorZ_get_err(owner_conv);
2517         int64_t ret_ref = tag_ptr(ret_copy, true);
2518         return ret_ref;
2519 }
2520
2521 static inline struct LDKRouteHintHop CResult_RouteHintHopDecodeErrorZ_get_ok(LDKCResult_RouteHintHopDecodeErrorZ *NONNULL_PTR owner){
2522         LDKRouteHintHop ret = *owner->contents.result;
2523         ret.is_owned = false;
2524         return ret;
2525 }
2526 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintHopDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
2527         LDKCResult_RouteHintHopDecodeErrorZ* owner_conv = (LDKCResult_RouteHintHopDecodeErrorZ*)untag_ptr(owner);
2528         LDKRouteHintHop ret_var = CResult_RouteHintHopDecodeErrorZ_get_ok(owner_conv);
2529         int64_t ret_ref = 0;
2530         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
2531         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
2532         return ret_ref;
2533 }
2534
2535 static inline struct LDKDecodeError CResult_RouteHintHopDecodeErrorZ_get_err(LDKCResult_RouteHintHopDecodeErrorZ *NONNULL_PTR owner){
2536 CHECK(!owner->result_ok);
2537         return DecodeError_clone(&*owner->contents.err);
2538 }
2539 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintHopDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
2540         LDKCResult_RouteHintHopDecodeErrorZ* owner_conv = (LDKCResult_RouteHintHopDecodeErrorZ*)untag_ptr(owner);
2541         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
2542         *ret_copy = CResult_RouteHintHopDecodeErrorZ_get_err(owner_conv);
2543         int64_t ret_ref = tag_ptr(ret_copy, true);
2544         return ret_ref;
2545 }
2546
2547 static jclass LDKPaymentPurpose_InvoicePayment_class = NULL;
2548 static jmethodID LDKPaymentPurpose_InvoicePayment_meth = NULL;
2549 static jclass LDKPaymentPurpose_SpontaneousPayment_class = NULL;
2550 static jmethodID LDKPaymentPurpose_SpontaneousPayment_meth = NULL;
2551 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKPaymentPurpose_init (JNIEnv *env, jclass clz) {
2552         LDKPaymentPurpose_InvoicePayment_class =
2553                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKPaymentPurpose$InvoicePayment"));
2554         CHECK(LDKPaymentPurpose_InvoicePayment_class != NULL);
2555         LDKPaymentPurpose_InvoicePayment_meth = (*env)->GetMethodID(env, LDKPaymentPurpose_InvoicePayment_class, "<init>", "([B[B)V");
2556         CHECK(LDKPaymentPurpose_InvoicePayment_meth != NULL);
2557         LDKPaymentPurpose_SpontaneousPayment_class =
2558                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKPaymentPurpose$SpontaneousPayment"));
2559         CHECK(LDKPaymentPurpose_SpontaneousPayment_class != NULL);
2560         LDKPaymentPurpose_SpontaneousPayment_meth = (*env)->GetMethodID(env, LDKPaymentPurpose_SpontaneousPayment_class, "<init>", "([B)V");
2561         CHECK(LDKPaymentPurpose_SpontaneousPayment_meth != NULL);
2562 }
2563 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKPaymentPurpose_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2564         LDKPaymentPurpose *obj = (LDKPaymentPurpose*)untag_ptr(ptr);
2565         switch(obj->tag) {
2566                 case LDKPaymentPurpose_InvoicePayment: {
2567                         int8_tArray payment_preimage_arr = (*env)->NewByteArray(env, 32);
2568                         (*env)->SetByteArrayRegion(env, payment_preimage_arr, 0, 32, obj->invoice_payment.payment_preimage.data);
2569                         int8_tArray payment_secret_arr = (*env)->NewByteArray(env, 32);
2570                         (*env)->SetByteArrayRegion(env, payment_secret_arr, 0, 32, obj->invoice_payment.payment_secret.data);
2571                         return (*env)->NewObject(env, LDKPaymentPurpose_InvoicePayment_class, LDKPaymentPurpose_InvoicePayment_meth, payment_preimage_arr, payment_secret_arr);
2572                 }
2573                 case LDKPaymentPurpose_SpontaneousPayment: {
2574                         int8_tArray spontaneous_payment_arr = (*env)->NewByteArray(env, 32);
2575                         (*env)->SetByteArrayRegion(env, spontaneous_payment_arr, 0, 32, obj->spontaneous_payment.data);
2576                         return (*env)->NewObject(env, LDKPaymentPurpose_SpontaneousPayment_class, LDKPaymentPurpose_SpontaneousPayment_meth, spontaneous_payment_arr);
2577                 }
2578                 default: abort();
2579         }
2580 }
2581 static inline struct LDKPaymentPurpose CResult_PaymentPurposeDecodeErrorZ_get_ok(LDKCResult_PaymentPurposeDecodeErrorZ *NONNULL_PTR owner){
2582 CHECK(owner->result_ok);
2583         return PaymentPurpose_clone(&*owner->contents.result);
2584 }
2585 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPurposeDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
2586         LDKCResult_PaymentPurposeDecodeErrorZ* owner_conv = (LDKCResult_PaymentPurposeDecodeErrorZ*)untag_ptr(owner);
2587         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
2588         *ret_copy = CResult_PaymentPurposeDecodeErrorZ_get_ok(owner_conv);
2589         int64_t ret_ref = tag_ptr(ret_copy, true);
2590         return ret_ref;
2591 }
2592
2593 static inline struct LDKDecodeError CResult_PaymentPurposeDecodeErrorZ_get_err(LDKCResult_PaymentPurposeDecodeErrorZ *NONNULL_PTR owner){
2594 CHECK(!owner->result_ok);
2595         return DecodeError_clone(&*owner->contents.err);
2596 }
2597 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPurposeDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
2598         LDKCResult_PaymentPurposeDecodeErrorZ* owner_conv = (LDKCResult_PaymentPurposeDecodeErrorZ*)untag_ptr(owner);
2599         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
2600         *ret_copy = CResult_PaymentPurposeDecodeErrorZ_get_err(owner_conv);
2601         int64_t ret_ref = tag_ptr(ret_copy, true);
2602         return ret_ref;
2603 }
2604
2605 static jclass LDKClosureReason_CounterpartyForceClosed_class = NULL;
2606 static jmethodID LDKClosureReason_CounterpartyForceClosed_meth = NULL;
2607 static jclass LDKClosureReason_HolderForceClosed_class = NULL;
2608 static jmethodID LDKClosureReason_HolderForceClosed_meth = NULL;
2609 static jclass LDKClosureReason_CooperativeClosure_class = NULL;
2610 static jmethodID LDKClosureReason_CooperativeClosure_meth = NULL;
2611 static jclass LDKClosureReason_CommitmentTxConfirmed_class = NULL;
2612 static jmethodID LDKClosureReason_CommitmentTxConfirmed_meth = NULL;
2613 static jclass LDKClosureReason_FundingTimedOut_class = NULL;
2614 static jmethodID LDKClosureReason_FundingTimedOut_meth = NULL;
2615 static jclass LDKClosureReason_ProcessingError_class = NULL;
2616 static jmethodID LDKClosureReason_ProcessingError_meth = NULL;
2617 static jclass LDKClosureReason_DisconnectedPeer_class = NULL;
2618 static jmethodID LDKClosureReason_DisconnectedPeer_meth = NULL;
2619 static jclass LDKClosureReason_OutdatedChannelManager_class = NULL;
2620 static jmethodID LDKClosureReason_OutdatedChannelManager_meth = NULL;
2621 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKClosureReason_init (JNIEnv *env, jclass clz) {
2622         LDKClosureReason_CounterpartyForceClosed_class =
2623                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKClosureReason$CounterpartyForceClosed"));
2624         CHECK(LDKClosureReason_CounterpartyForceClosed_class != NULL);
2625         LDKClosureReason_CounterpartyForceClosed_meth = (*env)->GetMethodID(env, LDKClosureReason_CounterpartyForceClosed_class, "<init>", "(Ljava/lang/String;)V");
2626         CHECK(LDKClosureReason_CounterpartyForceClosed_meth != NULL);
2627         LDKClosureReason_HolderForceClosed_class =
2628                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKClosureReason$HolderForceClosed"));
2629         CHECK(LDKClosureReason_HolderForceClosed_class != NULL);
2630         LDKClosureReason_HolderForceClosed_meth = (*env)->GetMethodID(env, LDKClosureReason_HolderForceClosed_class, "<init>", "()V");
2631         CHECK(LDKClosureReason_HolderForceClosed_meth != NULL);
2632         LDKClosureReason_CooperativeClosure_class =
2633                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKClosureReason$CooperativeClosure"));
2634         CHECK(LDKClosureReason_CooperativeClosure_class != NULL);
2635         LDKClosureReason_CooperativeClosure_meth = (*env)->GetMethodID(env, LDKClosureReason_CooperativeClosure_class, "<init>", "()V");
2636         CHECK(LDKClosureReason_CooperativeClosure_meth != NULL);
2637         LDKClosureReason_CommitmentTxConfirmed_class =
2638                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKClosureReason$CommitmentTxConfirmed"));
2639         CHECK(LDKClosureReason_CommitmentTxConfirmed_class != NULL);
2640         LDKClosureReason_CommitmentTxConfirmed_meth = (*env)->GetMethodID(env, LDKClosureReason_CommitmentTxConfirmed_class, "<init>", "()V");
2641         CHECK(LDKClosureReason_CommitmentTxConfirmed_meth != NULL);
2642         LDKClosureReason_FundingTimedOut_class =
2643                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKClosureReason$FundingTimedOut"));
2644         CHECK(LDKClosureReason_FundingTimedOut_class != NULL);
2645         LDKClosureReason_FundingTimedOut_meth = (*env)->GetMethodID(env, LDKClosureReason_FundingTimedOut_class, "<init>", "()V");
2646         CHECK(LDKClosureReason_FundingTimedOut_meth != NULL);
2647         LDKClosureReason_ProcessingError_class =
2648                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKClosureReason$ProcessingError"));
2649         CHECK(LDKClosureReason_ProcessingError_class != NULL);
2650         LDKClosureReason_ProcessingError_meth = (*env)->GetMethodID(env, LDKClosureReason_ProcessingError_class, "<init>", "(Ljava/lang/String;)V");
2651         CHECK(LDKClosureReason_ProcessingError_meth != NULL);
2652         LDKClosureReason_DisconnectedPeer_class =
2653                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKClosureReason$DisconnectedPeer"));
2654         CHECK(LDKClosureReason_DisconnectedPeer_class != NULL);
2655         LDKClosureReason_DisconnectedPeer_meth = (*env)->GetMethodID(env, LDKClosureReason_DisconnectedPeer_class, "<init>", "()V");
2656         CHECK(LDKClosureReason_DisconnectedPeer_meth != NULL);
2657         LDKClosureReason_OutdatedChannelManager_class =
2658                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKClosureReason$OutdatedChannelManager"));
2659         CHECK(LDKClosureReason_OutdatedChannelManager_class != NULL);
2660         LDKClosureReason_OutdatedChannelManager_meth = (*env)->GetMethodID(env, LDKClosureReason_OutdatedChannelManager_class, "<init>", "()V");
2661         CHECK(LDKClosureReason_OutdatedChannelManager_meth != NULL);
2662 }
2663 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKClosureReason_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2664         LDKClosureReason *obj = (LDKClosureReason*)untag_ptr(ptr);
2665         switch(obj->tag) {
2666                 case LDKClosureReason_CounterpartyForceClosed: {
2667                         LDKStr peer_msg_str = obj->counterparty_force_closed.peer_msg;
2668                         jstring peer_msg_conv = str_ref_to_java(env, peer_msg_str.chars, peer_msg_str.len);
2669                         return (*env)->NewObject(env, LDKClosureReason_CounterpartyForceClosed_class, LDKClosureReason_CounterpartyForceClosed_meth, peer_msg_conv);
2670                 }
2671                 case LDKClosureReason_HolderForceClosed: {
2672                         return (*env)->NewObject(env, LDKClosureReason_HolderForceClosed_class, LDKClosureReason_HolderForceClosed_meth);
2673                 }
2674                 case LDKClosureReason_CooperativeClosure: {
2675                         return (*env)->NewObject(env, LDKClosureReason_CooperativeClosure_class, LDKClosureReason_CooperativeClosure_meth);
2676                 }
2677                 case LDKClosureReason_CommitmentTxConfirmed: {
2678                         return (*env)->NewObject(env, LDKClosureReason_CommitmentTxConfirmed_class, LDKClosureReason_CommitmentTxConfirmed_meth);
2679                 }
2680                 case LDKClosureReason_FundingTimedOut: {
2681                         return (*env)->NewObject(env, LDKClosureReason_FundingTimedOut_class, LDKClosureReason_FundingTimedOut_meth);
2682                 }
2683                 case LDKClosureReason_ProcessingError: {
2684                         LDKStr err_str = obj->processing_error.err;
2685                         jstring err_conv = str_ref_to_java(env, err_str.chars, err_str.len);
2686                         return (*env)->NewObject(env, LDKClosureReason_ProcessingError_class, LDKClosureReason_ProcessingError_meth, err_conv);
2687                 }
2688                 case LDKClosureReason_DisconnectedPeer: {
2689                         return (*env)->NewObject(env, LDKClosureReason_DisconnectedPeer_class, LDKClosureReason_DisconnectedPeer_meth);
2690                 }
2691                 case LDKClosureReason_OutdatedChannelManager: {
2692                         return (*env)->NewObject(env, LDKClosureReason_OutdatedChannelManager_class, LDKClosureReason_OutdatedChannelManager_meth);
2693                 }
2694                 default: abort();
2695         }
2696 }
2697 static jclass LDKCOption_ClosureReasonZ_Some_class = NULL;
2698 static jmethodID LDKCOption_ClosureReasonZ_Some_meth = NULL;
2699 static jclass LDKCOption_ClosureReasonZ_None_class = NULL;
2700 static jmethodID LDKCOption_ClosureReasonZ_None_meth = NULL;
2701 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1ClosureReasonZ_init (JNIEnv *env, jclass clz) {
2702         LDKCOption_ClosureReasonZ_Some_class =
2703                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_ClosureReasonZ$Some"));
2704         CHECK(LDKCOption_ClosureReasonZ_Some_class != NULL);
2705         LDKCOption_ClosureReasonZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_ClosureReasonZ_Some_class, "<init>", "(J)V");
2706         CHECK(LDKCOption_ClosureReasonZ_Some_meth != NULL);
2707         LDKCOption_ClosureReasonZ_None_class =
2708                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_ClosureReasonZ$None"));
2709         CHECK(LDKCOption_ClosureReasonZ_None_class != NULL);
2710         LDKCOption_ClosureReasonZ_None_meth = (*env)->GetMethodID(env, LDKCOption_ClosureReasonZ_None_class, "<init>", "()V");
2711         CHECK(LDKCOption_ClosureReasonZ_None_meth != NULL);
2712 }
2713 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1ClosureReasonZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2714         LDKCOption_ClosureReasonZ *obj = (LDKCOption_ClosureReasonZ*)untag_ptr(ptr);
2715         switch(obj->tag) {
2716                 case LDKCOption_ClosureReasonZ_Some: {
2717                         int64_t some_ref = tag_ptr(&obj->some, false);
2718                         return (*env)->NewObject(env, LDKCOption_ClosureReasonZ_Some_class, LDKCOption_ClosureReasonZ_Some_meth, some_ref);
2719                 }
2720                 case LDKCOption_ClosureReasonZ_None: {
2721                         return (*env)->NewObject(env, LDKCOption_ClosureReasonZ_None_class, LDKCOption_ClosureReasonZ_None_meth);
2722                 }
2723                 default: abort();
2724         }
2725 }
2726 static inline struct LDKCOption_ClosureReasonZ CResult_COption_ClosureReasonZDecodeErrorZ_get_ok(LDKCResult_COption_ClosureReasonZDecodeErrorZ *NONNULL_PTR owner){
2727 CHECK(owner->result_ok);
2728         return COption_ClosureReasonZ_clone(&*owner->contents.result);
2729 }
2730 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1ClosureReasonZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
2731         LDKCResult_COption_ClosureReasonZDecodeErrorZ* owner_conv = (LDKCResult_COption_ClosureReasonZDecodeErrorZ*)untag_ptr(owner);
2732         LDKCOption_ClosureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_ClosureReasonZ), "LDKCOption_ClosureReasonZ");
2733         *ret_copy = CResult_COption_ClosureReasonZDecodeErrorZ_get_ok(owner_conv);
2734         int64_t ret_ref = tag_ptr(ret_copy, true);
2735         return ret_ref;
2736 }
2737
2738 static inline struct LDKDecodeError CResult_COption_ClosureReasonZDecodeErrorZ_get_err(LDKCResult_COption_ClosureReasonZDecodeErrorZ *NONNULL_PTR owner){
2739 CHECK(!owner->result_ok);
2740         return DecodeError_clone(&*owner->contents.err);
2741 }
2742 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1ClosureReasonZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
2743         LDKCResult_COption_ClosureReasonZDecodeErrorZ* owner_conv = (LDKCResult_COption_ClosureReasonZDecodeErrorZ*)untag_ptr(owner);
2744         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
2745         *ret_copy = CResult_COption_ClosureReasonZDecodeErrorZ_get_err(owner_conv);
2746         int64_t ret_ref = tag_ptr(ret_copy, true);
2747         return ret_ref;
2748 }
2749
2750 static jclass LDKHTLCDestination_NextHopChannel_class = NULL;
2751 static jmethodID LDKHTLCDestination_NextHopChannel_meth = NULL;
2752 static jclass LDKHTLCDestination_UnknownNextHop_class = NULL;
2753 static jmethodID LDKHTLCDestination_UnknownNextHop_meth = NULL;
2754 static jclass LDKHTLCDestination_InvalidForward_class = NULL;
2755 static jmethodID LDKHTLCDestination_InvalidForward_meth = NULL;
2756 static jclass LDKHTLCDestination_FailedPayment_class = NULL;
2757 static jmethodID LDKHTLCDestination_FailedPayment_meth = NULL;
2758 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKHTLCDestination_init (JNIEnv *env, jclass clz) {
2759         LDKHTLCDestination_NextHopChannel_class =
2760                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKHTLCDestination$NextHopChannel"));
2761         CHECK(LDKHTLCDestination_NextHopChannel_class != NULL);
2762         LDKHTLCDestination_NextHopChannel_meth = (*env)->GetMethodID(env, LDKHTLCDestination_NextHopChannel_class, "<init>", "([B[B)V");
2763         CHECK(LDKHTLCDestination_NextHopChannel_meth != NULL);
2764         LDKHTLCDestination_UnknownNextHop_class =
2765                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKHTLCDestination$UnknownNextHop"));
2766         CHECK(LDKHTLCDestination_UnknownNextHop_class != NULL);
2767         LDKHTLCDestination_UnknownNextHop_meth = (*env)->GetMethodID(env, LDKHTLCDestination_UnknownNextHop_class, "<init>", "(J)V");
2768         CHECK(LDKHTLCDestination_UnknownNextHop_meth != NULL);
2769         LDKHTLCDestination_InvalidForward_class =
2770                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKHTLCDestination$InvalidForward"));
2771         CHECK(LDKHTLCDestination_InvalidForward_class != NULL);
2772         LDKHTLCDestination_InvalidForward_meth = (*env)->GetMethodID(env, LDKHTLCDestination_InvalidForward_class, "<init>", "(J)V");
2773         CHECK(LDKHTLCDestination_InvalidForward_meth != NULL);
2774         LDKHTLCDestination_FailedPayment_class =
2775                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKHTLCDestination$FailedPayment"));
2776         CHECK(LDKHTLCDestination_FailedPayment_class != NULL);
2777         LDKHTLCDestination_FailedPayment_meth = (*env)->GetMethodID(env, LDKHTLCDestination_FailedPayment_class, "<init>", "([B)V");
2778         CHECK(LDKHTLCDestination_FailedPayment_meth != NULL);
2779 }
2780 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKHTLCDestination_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2781         LDKHTLCDestination *obj = (LDKHTLCDestination*)untag_ptr(ptr);
2782         switch(obj->tag) {
2783                 case LDKHTLCDestination_NextHopChannel: {
2784                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2785                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->next_hop_channel.node_id.compressed_form);
2786                         int8_tArray channel_id_arr = (*env)->NewByteArray(env, 32);
2787                         (*env)->SetByteArrayRegion(env, channel_id_arr, 0, 32, obj->next_hop_channel.channel_id.data);
2788                         return (*env)->NewObject(env, LDKHTLCDestination_NextHopChannel_class, LDKHTLCDestination_NextHopChannel_meth, node_id_arr, channel_id_arr);
2789                 }
2790                 case LDKHTLCDestination_UnknownNextHop: {
2791                         int64_t requested_forward_scid_conv = obj->unknown_next_hop.requested_forward_scid;
2792                         return (*env)->NewObject(env, LDKHTLCDestination_UnknownNextHop_class, LDKHTLCDestination_UnknownNextHop_meth, requested_forward_scid_conv);
2793                 }
2794                 case LDKHTLCDestination_InvalidForward: {
2795                         int64_t requested_forward_scid_conv = obj->invalid_forward.requested_forward_scid;
2796                         return (*env)->NewObject(env, LDKHTLCDestination_InvalidForward_class, LDKHTLCDestination_InvalidForward_meth, requested_forward_scid_conv);
2797                 }
2798                 case LDKHTLCDestination_FailedPayment: {
2799                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
2800                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->failed_payment.payment_hash.data);
2801                         return (*env)->NewObject(env, LDKHTLCDestination_FailedPayment_class, LDKHTLCDestination_FailedPayment_meth, payment_hash_arr);
2802                 }
2803                 default: abort();
2804         }
2805 }
2806 static jclass LDKCOption_HTLCDestinationZ_Some_class = NULL;
2807 static jmethodID LDKCOption_HTLCDestinationZ_Some_meth = NULL;
2808 static jclass LDKCOption_HTLCDestinationZ_None_class = NULL;
2809 static jmethodID LDKCOption_HTLCDestinationZ_None_meth = NULL;
2810 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1HTLCDestinationZ_init (JNIEnv *env, jclass clz) {
2811         LDKCOption_HTLCDestinationZ_Some_class =
2812                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_HTLCDestinationZ$Some"));
2813         CHECK(LDKCOption_HTLCDestinationZ_Some_class != NULL);
2814         LDKCOption_HTLCDestinationZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_HTLCDestinationZ_Some_class, "<init>", "(J)V");
2815         CHECK(LDKCOption_HTLCDestinationZ_Some_meth != NULL);
2816         LDKCOption_HTLCDestinationZ_None_class =
2817                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_HTLCDestinationZ$None"));
2818         CHECK(LDKCOption_HTLCDestinationZ_None_class != NULL);
2819         LDKCOption_HTLCDestinationZ_None_meth = (*env)->GetMethodID(env, LDKCOption_HTLCDestinationZ_None_class, "<init>", "()V");
2820         CHECK(LDKCOption_HTLCDestinationZ_None_meth != NULL);
2821 }
2822 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1HTLCDestinationZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2823         LDKCOption_HTLCDestinationZ *obj = (LDKCOption_HTLCDestinationZ*)untag_ptr(ptr);
2824         switch(obj->tag) {
2825                 case LDKCOption_HTLCDestinationZ_Some: {
2826                         int64_t some_ref = tag_ptr(&obj->some, false);
2827                         return (*env)->NewObject(env, LDKCOption_HTLCDestinationZ_Some_class, LDKCOption_HTLCDestinationZ_Some_meth, some_ref);
2828                 }
2829                 case LDKCOption_HTLCDestinationZ_None: {
2830                         return (*env)->NewObject(env, LDKCOption_HTLCDestinationZ_None_class, LDKCOption_HTLCDestinationZ_None_meth);
2831                 }
2832                 default: abort();
2833         }
2834 }
2835 static inline struct LDKCOption_HTLCDestinationZ CResult_COption_HTLCDestinationZDecodeErrorZ_get_ok(LDKCResult_COption_HTLCDestinationZDecodeErrorZ *NONNULL_PTR owner){
2836 CHECK(owner->result_ok);
2837         return COption_HTLCDestinationZ_clone(&*owner->contents.result);
2838 }
2839 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1HTLCDestinationZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
2840         LDKCResult_COption_HTLCDestinationZDecodeErrorZ* owner_conv = (LDKCResult_COption_HTLCDestinationZDecodeErrorZ*)untag_ptr(owner);
2841         LDKCOption_HTLCDestinationZ *ret_copy = MALLOC(sizeof(LDKCOption_HTLCDestinationZ), "LDKCOption_HTLCDestinationZ");
2842         *ret_copy = CResult_COption_HTLCDestinationZDecodeErrorZ_get_ok(owner_conv);
2843         int64_t ret_ref = tag_ptr(ret_copy, true);
2844         return ret_ref;
2845 }
2846
2847 static inline struct LDKDecodeError CResult_COption_HTLCDestinationZDecodeErrorZ_get_err(LDKCResult_COption_HTLCDestinationZDecodeErrorZ *NONNULL_PTR owner){
2848 CHECK(!owner->result_ok);
2849         return DecodeError_clone(&*owner->contents.err);
2850 }
2851 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1HTLCDestinationZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
2852         LDKCResult_COption_HTLCDestinationZDecodeErrorZ* owner_conv = (LDKCResult_COption_HTLCDestinationZDecodeErrorZ*)untag_ptr(owner);
2853         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
2854         *ret_copy = CResult_COption_HTLCDestinationZDecodeErrorZ_get_err(owner_conv);
2855         int64_t ret_ref = tag_ptr(ret_copy, true);
2856         return ret_ref;
2857 }
2858
2859 static jclass LDKCOption_u128Z_Some_class = NULL;
2860 static jmethodID LDKCOption_u128Z_Some_meth = NULL;
2861 static jclass LDKCOption_u128Z_None_class = NULL;
2862 static jmethodID LDKCOption_u128Z_None_meth = NULL;
2863 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1u128Z_init (JNIEnv *env, jclass clz) {
2864         LDKCOption_u128Z_Some_class =
2865                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_u128Z$Some"));
2866         CHECK(LDKCOption_u128Z_Some_class != NULL);
2867         LDKCOption_u128Z_Some_meth = (*env)->GetMethodID(env, LDKCOption_u128Z_Some_class, "<init>", "([B)V");
2868         CHECK(LDKCOption_u128Z_Some_meth != NULL);
2869         LDKCOption_u128Z_None_class =
2870                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_u128Z$None"));
2871         CHECK(LDKCOption_u128Z_None_class != NULL);
2872         LDKCOption_u128Z_None_meth = (*env)->GetMethodID(env, LDKCOption_u128Z_None_class, "<init>", "()V");
2873         CHECK(LDKCOption_u128Z_None_meth != NULL);
2874 }
2875 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1u128Z_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2876         LDKCOption_u128Z *obj = (LDKCOption_u128Z*)untag_ptr(ptr);
2877         switch(obj->tag) {
2878                 case LDKCOption_u128Z_Some: {
2879                         int8_tArray some_arr = (*env)->NewByteArray(env, 16);
2880                         (*env)->SetByteArrayRegion(env, some_arr, 0, 16, obj->some.le_bytes);
2881                         return (*env)->NewObject(env, LDKCOption_u128Z_Some_class, LDKCOption_u128Z_Some_meth, some_arr);
2882                 }
2883                 case LDKCOption_u128Z_None: {
2884                         return (*env)->NewObject(env, LDKCOption_u128Z_None_class, LDKCOption_u128Z_None_meth);
2885                 }
2886                 default: abort();
2887         }
2888 }
2889 static jclass LDKNetworkUpdate_ChannelUpdateMessage_class = NULL;
2890 static jmethodID LDKNetworkUpdate_ChannelUpdateMessage_meth = NULL;
2891 static jclass LDKNetworkUpdate_ChannelFailure_class = NULL;
2892 static jmethodID LDKNetworkUpdate_ChannelFailure_meth = NULL;
2893 static jclass LDKNetworkUpdate_NodeFailure_class = NULL;
2894 static jmethodID LDKNetworkUpdate_NodeFailure_meth = NULL;
2895 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKNetworkUpdate_init (JNIEnv *env, jclass clz) {
2896         LDKNetworkUpdate_ChannelUpdateMessage_class =
2897                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKNetworkUpdate$ChannelUpdateMessage"));
2898         CHECK(LDKNetworkUpdate_ChannelUpdateMessage_class != NULL);
2899         LDKNetworkUpdate_ChannelUpdateMessage_meth = (*env)->GetMethodID(env, LDKNetworkUpdate_ChannelUpdateMessage_class, "<init>", "(J)V");
2900         CHECK(LDKNetworkUpdate_ChannelUpdateMessage_meth != NULL);
2901         LDKNetworkUpdate_ChannelFailure_class =
2902                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKNetworkUpdate$ChannelFailure"));
2903         CHECK(LDKNetworkUpdate_ChannelFailure_class != NULL);
2904         LDKNetworkUpdate_ChannelFailure_meth = (*env)->GetMethodID(env, LDKNetworkUpdate_ChannelFailure_class, "<init>", "(JZ)V");
2905         CHECK(LDKNetworkUpdate_ChannelFailure_meth != NULL);
2906         LDKNetworkUpdate_NodeFailure_class =
2907                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKNetworkUpdate$NodeFailure"));
2908         CHECK(LDKNetworkUpdate_NodeFailure_class != NULL);
2909         LDKNetworkUpdate_NodeFailure_meth = (*env)->GetMethodID(env, LDKNetworkUpdate_NodeFailure_class, "<init>", "([BZ)V");
2910         CHECK(LDKNetworkUpdate_NodeFailure_meth != NULL);
2911 }
2912 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKNetworkUpdate_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2913         LDKNetworkUpdate *obj = (LDKNetworkUpdate*)untag_ptr(ptr);
2914         switch(obj->tag) {
2915                 case LDKNetworkUpdate_ChannelUpdateMessage: {
2916                         LDKChannelUpdate msg_var = obj->channel_update_message.msg;
2917                         int64_t msg_ref = 0;
2918                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2919                         msg_ref = tag_ptr(msg_var.inner, false);
2920                         return (*env)->NewObject(env, LDKNetworkUpdate_ChannelUpdateMessage_class, LDKNetworkUpdate_ChannelUpdateMessage_meth, msg_ref);
2921                 }
2922                 case LDKNetworkUpdate_ChannelFailure: {
2923                         int64_t short_channel_id_conv = obj->channel_failure.short_channel_id;
2924                         jboolean is_permanent_conv = obj->channel_failure.is_permanent;
2925                         return (*env)->NewObject(env, LDKNetworkUpdate_ChannelFailure_class, LDKNetworkUpdate_ChannelFailure_meth, short_channel_id_conv, is_permanent_conv);
2926                 }
2927                 case LDKNetworkUpdate_NodeFailure: {
2928                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2929                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->node_failure.node_id.compressed_form);
2930                         jboolean is_permanent_conv = obj->node_failure.is_permanent;
2931                         return (*env)->NewObject(env, LDKNetworkUpdate_NodeFailure_class, LDKNetworkUpdate_NodeFailure_meth, node_id_arr, is_permanent_conv);
2932                 }
2933                 default: abort();
2934         }
2935 }
2936 static jclass LDKCOption_NetworkUpdateZ_Some_class = NULL;
2937 static jmethodID LDKCOption_NetworkUpdateZ_Some_meth = NULL;
2938 static jclass LDKCOption_NetworkUpdateZ_None_class = NULL;
2939 static jmethodID LDKCOption_NetworkUpdateZ_None_meth = NULL;
2940 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1NetworkUpdateZ_init (JNIEnv *env, jclass clz) {
2941         LDKCOption_NetworkUpdateZ_Some_class =
2942                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_NetworkUpdateZ$Some"));
2943         CHECK(LDKCOption_NetworkUpdateZ_Some_class != NULL);
2944         LDKCOption_NetworkUpdateZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_NetworkUpdateZ_Some_class, "<init>", "(J)V");
2945         CHECK(LDKCOption_NetworkUpdateZ_Some_meth != NULL);
2946         LDKCOption_NetworkUpdateZ_None_class =
2947                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_NetworkUpdateZ$None"));
2948         CHECK(LDKCOption_NetworkUpdateZ_None_class != NULL);
2949         LDKCOption_NetworkUpdateZ_None_meth = (*env)->GetMethodID(env, LDKCOption_NetworkUpdateZ_None_class, "<init>", "()V");
2950         CHECK(LDKCOption_NetworkUpdateZ_None_meth != NULL);
2951 }
2952 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1NetworkUpdateZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2953         LDKCOption_NetworkUpdateZ *obj = (LDKCOption_NetworkUpdateZ*)untag_ptr(ptr);
2954         switch(obj->tag) {
2955                 case LDKCOption_NetworkUpdateZ_Some: {
2956                         int64_t some_ref = tag_ptr(&obj->some, false);
2957                         return (*env)->NewObject(env, LDKCOption_NetworkUpdateZ_Some_class, LDKCOption_NetworkUpdateZ_Some_meth, some_ref);
2958                 }
2959                 case LDKCOption_NetworkUpdateZ_None: {
2960                         return (*env)->NewObject(env, LDKCOption_NetworkUpdateZ_None_class, LDKCOption_NetworkUpdateZ_None_meth);
2961                 }
2962                 default: abort();
2963         }
2964 }
2965 static jclass LDKSpendableOutputDescriptor_StaticOutput_class = NULL;
2966 static jmethodID LDKSpendableOutputDescriptor_StaticOutput_meth = NULL;
2967 static jclass LDKSpendableOutputDescriptor_DelayedPaymentOutput_class = NULL;
2968 static jmethodID LDKSpendableOutputDescriptor_DelayedPaymentOutput_meth = NULL;
2969 static jclass LDKSpendableOutputDescriptor_StaticPaymentOutput_class = NULL;
2970 static jmethodID LDKSpendableOutputDescriptor_StaticPaymentOutput_meth = NULL;
2971 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKSpendableOutputDescriptor_init (JNIEnv *env, jclass clz) {
2972         LDKSpendableOutputDescriptor_StaticOutput_class =
2973                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKSpendableOutputDescriptor$StaticOutput"));
2974         CHECK(LDKSpendableOutputDescriptor_StaticOutput_class != NULL);
2975         LDKSpendableOutputDescriptor_StaticOutput_meth = (*env)->GetMethodID(env, LDKSpendableOutputDescriptor_StaticOutput_class, "<init>", "(JJ)V");
2976         CHECK(LDKSpendableOutputDescriptor_StaticOutput_meth != NULL);
2977         LDKSpendableOutputDescriptor_DelayedPaymentOutput_class =
2978                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKSpendableOutputDescriptor$DelayedPaymentOutput"));
2979         CHECK(LDKSpendableOutputDescriptor_DelayedPaymentOutput_class != NULL);
2980         LDKSpendableOutputDescriptor_DelayedPaymentOutput_meth = (*env)->GetMethodID(env, LDKSpendableOutputDescriptor_DelayedPaymentOutput_class, "<init>", "(J)V");
2981         CHECK(LDKSpendableOutputDescriptor_DelayedPaymentOutput_meth != NULL);
2982         LDKSpendableOutputDescriptor_StaticPaymentOutput_class =
2983                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKSpendableOutputDescriptor$StaticPaymentOutput"));
2984         CHECK(LDKSpendableOutputDescriptor_StaticPaymentOutput_class != NULL);
2985         LDKSpendableOutputDescriptor_StaticPaymentOutput_meth = (*env)->GetMethodID(env, LDKSpendableOutputDescriptor_StaticPaymentOutput_class, "<init>", "(J)V");
2986         CHECK(LDKSpendableOutputDescriptor_StaticPaymentOutput_meth != NULL);
2987 }
2988 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKSpendableOutputDescriptor_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2989         LDKSpendableOutputDescriptor *obj = (LDKSpendableOutputDescriptor*)untag_ptr(ptr);
2990         switch(obj->tag) {
2991                 case LDKSpendableOutputDescriptor_StaticOutput: {
2992                         LDKOutPoint outpoint_var = obj->static_output.outpoint;
2993                         int64_t outpoint_ref = 0;
2994                         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_var);
2995                         outpoint_ref = tag_ptr(outpoint_var.inner, false);
2996                         LDKTxOut* output_ref = &obj->static_output.output;
2997                         return (*env)->NewObject(env, LDKSpendableOutputDescriptor_StaticOutput_class, LDKSpendableOutputDescriptor_StaticOutput_meth, outpoint_ref, tag_ptr(output_ref, false));
2998                 }
2999                 case LDKSpendableOutputDescriptor_DelayedPaymentOutput: {
3000                         LDKDelayedPaymentOutputDescriptor delayed_payment_output_var = obj->delayed_payment_output;
3001                         int64_t delayed_payment_output_ref = 0;
3002                         CHECK_INNER_FIELD_ACCESS_OR_NULL(delayed_payment_output_var);
3003                         delayed_payment_output_ref = tag_ptr(delayed_payment_output_var.inner, false);
3004                         return (*env)->NewObject(env, LDKSpendableOutputDescriptor_DelayedPaymentOutput_class, LDKSpendableOutputDescriptor_DelayedPaymentOutput_meth, delayed_payment_output_ref);
3005                 }
3006                 case LDKSpendableOutputDescriptor_StaticPaymentOutput: {
3007                         LDKStaticPaymentOutputDescriptor static_payment_output_var = obj->static_payment_output;
3008                         int64_t static_payment_output_ref = 0;
3009                         CHECK_INNER_FIELD_ACCESS_OR_NULL(static_payment_output_var);
3010                         static_payment_output_ref = tag_ptr(static_payment_output_var.inner, false);
3011                         return (*env)->NewObject(env, LDKSpendableOutputDescriptor_StaticPaymentOutput_class, LDKSpendableOutputDescriptor_StaticPaymentOutput_meth, static_payment_output_ref);
3012                 }
3013                 default: abort();
3014         }
3015 }
3016 static inline LDKCVec_SpendableOutputDescriptorZ CVec_SpendableOutputDescriptorZ_clone(const LDKCVec_SpendableOutputDescriptorZ *orig) {
3017         LDKCVec_SpendableOutputDescriptorZ ret = { .data = MALLOC(sizeof(LDKSpendableOutputDescriptor) * orig->datalen, "LDKCVec_SpendableOutputDescriptorZ clone bytes"), .datalen = orig->datalen };
3018         for (size_t i = 0; i < ret.datalen; i++) {
3019                 ret.data[i] = SpendableOutputDescriptor_clone(&orig->data[i]);
3020         }
3021         return ret;
3022 }
3023 static jclass LDKEvent_FundingGenerationReady_class = NULL;
3024 static jmethodID LDKEvent_FundingGenerationReady_meth = NULL;
3025 static jclass LDKEvent_PaymentClaimable_class = NULL;
3026 static jmethodID LDKEvent_PaymentClaimable_meth = NULL;
3027 static jclass LDKEvent_PaymentClaimed_class = NULL;
3028 static jmethodID LDKEvent_PaymentClaimed_meth = NULL;
3029 static jclass LDKEvent_PaymentSent_class = NULL;
3030 static jmethodID LDKEvent_PaymentSent_meth = NULL;
3031 static jclass LDKEvent_PaymentFailed_class = NULL;
3032 static jmethodID LDKEvent_PaymentFailed_meth = NULL;
3033 static jclass LDKEvent_PaymentPathSuccessful_class = NULL;
3034 static jmethodID LDKEvent_PaymentPathSuccessful_meth = NULL;
3035 static jclass LDKEvent_PaymentPathFailed_class = NULL;
3036 static jmethodID LDKEvent_PaymentPathFailed_meth = NULL;
3037 static jclass LDKEvent_ProbeSuccessful_class = NULL;
3038 static jmethodID LDKEvent_ProbeSuccessful_meth = NULL;
3039 static jclass LDKEvent_ProbeFailed_class = NULL;
3040 static jmethodID LDKEvent_ProbeFailed_meth = NULL;
3041 static jclass LDKEvent_PendingHTLCsForwardable_class = NULL;
3042 static jmethodID LDKEvent_PendingHTLCsForwardable_meth = NULL;
3043 static jclass LDKEvent_HTLCIntercepted_class = NULL;
3044 static jmethodID LDKEvent_HTLCIntercepted_meth = NULL;
3045 static jclass LDKEvent_SpendableOutputs_class = NULL;
3046 static jmethodID LDKEvent_SpendableOutputs_meth = NULL;
3047 static jclass LDKEvent_PaymentForwarded_class = NULL;
3048 static jmethodID LDKEvent_PaymentForwarded_meth = NULL;
3049 static jclass LDKEvent_ChannelReady_class = NULL;
3050 static jmethodID LDKEvent_ChannelReady_meth = NULL;
3051 static jclass LDKEvent_ChannelClosed_class = NULL;
3052 static jmethodID LDKEvent_ChannelClosed_meth = NULL;
3053 static jclass LDKEvent_DiscardFunding_class = NULL;
3054 static jmethodID LDKEvent_DiscardFunding_meth = NULL;
3055 static jclass LDKEvent_OpenChannelRequest_class = NULL;
3056 static jmethodID LDKEvent_OpenChannelRequest_meth = NULL;
3057 static jclass LDKEvent_HTLCHandlingFailed_class = NULL;
3058 static jmethodID LDKEvent_HTLCHandlingFailed_meth = NULL;
3059 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKEvent_init (JNIEnv *env, jclass clz) {
3060         LDKEvent_FundingGenerationReady_class =
3061                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$FundingGenerationReady"));
3062         CHECK(LDKEvent_FundingGenerationReady_class != NULL);
3063         LDKEvent_FundingGenerationReady_meth = (*env)->GetMethodID(env, LDKEvent_FundingGenerationReady_class, "<init>", "([B[BJ[B[B)V");
3064         CHECK(LDKEvent_FundingGenerationReady_meth != NULL);
3065         LDKEvent_PaymentClaimable_class =
3066                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$PaymentClaimable"));
3067         CHECK(LDKEvent_PaymentClaimable_class != NULL);
3068         LDKEvent_PaymentClaimable_meth = (*env)->GetMethodID(env, LDKEvent_PaymentClaimable_class, "<init>", "([B[BJJ[BJ)V");
3069         CHECK(LDKEvent_PaymentClaimable_meth != NULL);
3070         LDKEvent_PaymentClaimed_class =
3071                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$PaymentClaimed"));
3072         CHECK(LDKEvent_PaymentClaimed_class != NULL);
3073         LDKEvent_PaymentClaimed_meth = (*env)->GetMethodID(env, LDKEvent_PaymentClaimed_class, "<init>", "([B[BJJ)V");
3074         CHECK(LDKEvent_PaymentClaimed_meth != NULL);
3075         LDKEvent_PaymentSent_class =
3076                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$PaymentSent"));
3077         CHECK(LDKEvent_PaymentSent_class != NULL);
3078         LDKEvent_PaymentSent_meth = (*env)->GetMethodID(env, LDKEvent_PaymentSent_class, "<init>", "([B[B[BJ)V");
3079         CHECK(LDKEvent_PaymentSent_meth != NULL);
3080         LDKEvent_PaymentFailed_class =
3081                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$PaymentFailed"));
3082         CHECK(LDKEvent_PaymentFailed_class != NULL);
3083         LDKEvent_PaymentFailed_meth = (*env)->GetMethodID(env, LDKEvent_PaymentFailed_class, "<init>", "([B[B)V");
3084         CHECK(LDKEvent_PaymentFailed_meth != NULL);
3085         LDKEvent_PaymentPathSuccessful_class =
3086                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$PaymentPathSuccessful"));
3087         CHECK(LDKEvent_PaymentPathSuccessful_class != NULL);
3088         LDKEvent_PaymentPathSuccessful_meth = (*env)->GetMethodID(env, LDKEvent_PaymentPathSuccessful_class, "<init>", "([B[B[J)V");
3089         CHECK(LDKEvent_PaymentPathSuccessful_meth != NULL);
3090         LDKEvent_PaymentPathFailed_class =
3091                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$PaymentPathFailed"));
3092         CHECK(LDKEvent_PaymentPathFailed_class != NULL);
3093         LDKEvent_PaymentPathFailed_meth = (*env)->GetMethodID(env, LDKEvent_PaymentPathFailed_class, "<init>", "([B[BZJZ[JJJ)V");
3094         CHECK(LDKEvent_PaymentPathFailed_meth != NULL);
3095         LDKEvent_ProbeSuccessful_class =
3096                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$ProbeSuccessful"));
3097         CHECK(LDKEvent_ProbeSuccessful_class != NULL);
3098         LDKEvent_ProbeSuccessful_meth = (*env)->GetMethodID(env, LDKEvent_ProbeSuccessful_class, "<init>", "([B[B[J)V");
3099         CHECK(LDKEvent_ProbeSuccessful_meth != NULL);
3100         LDKEvent_ProbeFailed_class =
3101                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$ProbeFailed"));
3102         CHECK(LDKEvent_ProbeFailed_class != NULL);
3103         LDKEvent_ProbeFailed_meth = (*env)->GetMethodID(env, LDKEvent_ProbeFailed_class, "<init>", "([B[B[JJ)V");
3104         CHECK(LDKEvent_ProbeFailed_meth != NULL);
3105         LDKEvent_PendingHTLCsForwardable_class =
3106                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$PendingHTLCsForwardable"));
3107         CHECK(LDKEvent_PendingHTLCsForwardable_class != NULL);
3108         LDKEvent_PendingHTLCsForwardable_meth = (*env)->GetMethodID(env, LDKEvent_PendingHTLCsForwardable_class, "<init>", "(J)V");
3109         CHECK(LDKEvent_PendingHTLCsForwardable_meth != NULL);
3110         LDKEvent_HTLCIntercepted_class =
3111                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$HTLCIntercepted"));
3112         CHECK(LDKEvent_HTLCIntercepted_class != NULL);
3113         LDKEvent_HTLCIntercepted_meth = (*env)->GetMethodID(env, LDKEvent_HTLCIntercepted_class, "<init>", "([BJ[BJJ)V");
3114         CHECK(LDKEvent_HTLCIntercepted_meth != NULL);
3115         LDKEvent_SpendableOutputs_class =
3116                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$SpendableOutputs"));
3117         CHECK(LDKEvent_SpendableOutputs_class != NULL);
3118         LDKEvent_SpendableOutputs_meth = (*env)->GetMethodID(env, LDKEvent_SpendableOutputs_class, "<init>", "([J)V");
3119         CHECK(LDKEvent_SpendableOutputs_meth != NULL);
3120         LDKEvent_PaymentForwarded_class =
3121                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$PaymentForwarded"));
3122         CHECK(LDKEvent_PaymentForwarded_class != NULL);
3123         LDKEvent_PaymentForwarded_meth = (*env)->GetMethodID(env, LDKEvent_PaymentForwarded_class, "<init>", "([B[BJZ)V");
3124         CHECK(LDKEvent_PaymentForwarded_meth != NULL);
3125         LDKEvent_ChannelReady_class =
3126                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$ChannelReady"));
3127         CHECK(LDKEvent_ChannelReady_class != NULL);
3128         LDKEvent_ChannelReady_meth = (*env)->GetMethodID(env, LDKEvent_ChannelReady_class, "<init>", "([B[B[BJ)V");
3129         CHECK(LDKEvent_ChannelReady_meth != NULL);
3130         LDKEvent_ChannelClosed_class =
3131                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$ChannelClosed"));
3132         CHECK(LDKEvent_ChannelClosed_class != NULL);
3133         LDKEvent_ChannelClosed_meth = (*env)->GetMethodID(env, LDKEvent_ChannelClosed_class, "<init>", "([B[BJ)V");
3134         CHECK(LDKEvent_ChannelClosed_meth != NULL);
3135         LDKEvent_DiscardFunding_class =
3136                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$DiscardFunding"));
3137         CHECK(LDKEvent_DiscardFunding_class != NULL);
3138         LDKEvent_DiscardFunding_meth = (*env)->GetMethodID(env, LDKEvent_DiscardFunding_class, "<init>", "([B[B)V");
3139         CHECK(LDKEvent_DiscardFunding_meth != NULL);
3140         LDKEvent_OpenChannelRequest_class =
3141                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$OpenChannelRequest"));
3142         CHECK(LDKEvent_OpenChannelRequest_class != NULL);
3143         LDKEvent_OpenChannelRequest_meth = (*env)->GetMethodID(env, LDKEvent_OpenChannelRequest_class, "<init>", "([B[BJJJ)V");
3144         CHECK(LDKEvent_OpenChannelRequest_meth != NULL);
3145         LDKEvent_HTLCHandlingFailed_class =
3146                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEvent$HTLCHandlingFailed"));
3147         CHECK(LDKEvent_HTLCHandlingFailed_class != NULL);
3148         LDKEvent_HTLCHandlingFailed_meth = (*env)->GetMethodID(env, LDKEvent_HTLCHandlingFailed_class, "<init>", "([BJ)V");
3149         CHECK(LDKEvent_HTLCHandlingFailed_meth != NULL);
3150 }
3151 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKEvent_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
3152         LDKEvent *obj = (LDKEvent*)untag_ptr(ptr);
3153         switch(obj->tag) {
3154                 case LDKEvent_FundingGenerationReady: {
3155                         int8_tArray temporary_channel_id_arr = (*env)->NewByteArray(env, 32);
3156                         (*env)->SetByteArrayRegion(env, temporary_channel_id_arr, 0, 32, obj->funding_generation_ready.temporary_channel_id.data);
3157                         int8_tArray counterparty_node_id_arr = (*env)->NewByteArray(env, 33);
3158                         (*env)->SetByteArrayRegion(env, counterparty_node_id_arr, 0, 33, obj->funding_generation_ready.counterparty_node_id.compressed_form);
3159                         int64_t channel_value_satoshis_conv = obj->funding_generation_ready.channel_value_satoshis;
3160                         LDKCVec_u8Z output_script_var = obj->funding_generation_ready.output_script;
3161                         int8_tArray output_script_arr = (*env)->NewByteArray(env, output_script_var.datalen);
3162                         (*env)->SetByteArrayRegion(env, output_script_arr, 0, output_script_var.datalen, output_script_var.data);
3163                         int8_tArray user_channel_id_arr = (*env)->NewByteArray(env, 16);
3164                         (*env)->SetByteArrayRegion(env, user_channel_id_arr, 0, 16, obj->funding_generation_ready.user_channel_id.le_bytes);
3165                         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_arr);
3166                 }
3167                 case LDKEvent_PaymentClaimable: {
3168                         int8_tArray receiver_node_id_arr = (*env)->NewByteArray(env, 33);
3169                         (*env)->SetByteArrayRegion(env, receiver_node_id_arr, 0, 33, obj->payment_claimable.receiver_node_id.compressed_form);
3170                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
3171                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->payment_claimable.payment_hash.data);
3172                         int64_t amount_msat_conv = obj->payment_claimable.amount_msat;
3173                         int64_t purpose_ref = tag_ptr(&obj->payment_claimable.purpose, false);
3174                         int8_tArray via_channel_id_arr = (*env)->NewByteArray(env, 32);
3175                         (*env)->SetByteArrayRegion(env, via_channel_id_arr, 0, 32, obj->payment_claimable.via_channel_id.data);
3176                         int64_t via_user_channel_id_ref = tag_ptr(&obj->payment_claimable.via_user_channel_id, false);
3177                         return (*env)->NewObject(env, LDKEvent_PaymentClaimable_class, LDKEvent_PaymentClaimable_meth, receiver_node_id_arr, payment_hash_arr, amount_msat_conv, purpose_ref, via_channel_id_arr, via_user_channel_id_ref);
3178                 }
3179                 case LDKEvent_PaymentClaimed: {
3180                         int8_tArray receiver_node_id_arr = (*env)->NewByteArray(env, 33);
3181                         (*env)->SetByteArrayRegion(env, receiver_node_id_arr, 0, 33, obj->payment_claimed.receiver_node_id.compressed_form);
3182                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
3183                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->payment_claimed.payment_hash.data);
3184                         int64_t amount_msat_conv = obj->payment_claimed.amount_msat;
3185                         int64_t purpose_ref = tag_ptr(&obj->payment_claimed.purpose, false);
3186                         return (*env)->NewObject(env, LDKEvent_PaymentClaimed_class, LDKEvent_PaymentClaimed_meth, receiver_node_id_arr, payment_hash_arr, amount_msat_conv, purpose_ref);
3187                 }
3188                 case LDKEvent_PaymentSent: {
3189                         int8_tArray payment_id_arr = (*env)->NewByteArray(env, 32);
3190                         (*env)->SetByteArrayRegion(env, payment_id_arr, 0, 32, obj->payment_sent.payment_id.data);
3191                         int8_tArray payment_preimage_arr = (*env)->NewByteArray(env, 32);
3192                         (*env)->SetByteArrayRegion(env, payment_preimage_arr, 0, 32, obj->payment_sent.payment_preimage.data);
3193                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
3194                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->payment_sent.payment_hash.data);
3195                         int64_t fee_paid_msat_ref = tag_ptr(&obj->payment_sent.fee_paid_msat, false);
3196                         return (*env)->NewObject(env, LDKEvent_PaymentSent_class, LDKEvent_PaymentSent_meth, payment_id_arr, payment_preimage_arr, payment_hash_arr, fee_paid_msat_ref);
3197                 }
3198                 case LDKEvent_PaymentFailed: {
3199                         int8_tArray payment_id_arr = (*env)->NewByteArray(env, 32);
3200                         (*env)->SetByteArrayRegion(env, payment_id_arr, 0, 32, obj->payment_failed.payment_id.data);
3201                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
3202                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->payment_failed.payment_hash.data);
3203                         return (*env)->NewObject(env, LDKEvent_PaymentFailed_class, LDKEvent_PaymentFailed_meth, payment_id_arr, payment_hash_arr);
3204                 }
3205                 case LDKEvent_PaymentPathSuccessful: {
3206                         int8_tArray payment_id_arr = (*env)->NewByteArray(env, 32);
3207                         (*env)->SetByteArrayRegion(env, payment_id_arr, 0, 32, obj->payment_path_successful.payment_id.data);
3208                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
3209                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->payment_path_successful.payment_hash.data);
3210                         LDKCVec_RouteHopZ path_var = obj->payment_path_successful.path;
3211                         int64_tArray path_arr = NULL;
3212                         path_arr = (*env)->NewLongArray(env, path_var.datalen);
3213                         int64_t *path_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, path_arr, NULL);
3214                         for (size_t k = 0; k < path_var.datalen; k++) {
3215                                 LDKRouteHop path_conv_10_var = path_var.data[k];
3216                                 int64_t path_conv_10_ref = 0;
3217                                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
3218                                 path_conv_10_ref = tag_ptr(path_conv_10_var.inner, false);
3219                                 path_arr_ptr[k] = path_conv_10_ref;
3220                         }
3221                         (*env)->ReleasePrimitiveArrayCritical(env, path_arr, path_arr_ptr, 0);
3222                         return (*env)->NewObject(env, LDKEvent_PaymentPathSuccessful_class, LDKEvent_PaymentPathSuccessful_meth, payment_id_arr, payment_hash_arr, path_arr);
3223                 }
3224                 case LDKEvent_PaymentPathFailed: {
3225                         int8_tArray payment_id_arr = (*env)->NewByteArray(env, 32);
3226                         (*env)->SetByteArrayRegion(env, payment_id_arr, 0, 32, obj->payment_path_failed.payment_id.data);
3227                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
3228                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->payment_path_failed.payment_hash.data);
3229                         jboolean payment_failed_permanently_conv = obj->payment_path_failed.payment_failed_permanently;
3230                         int64_t network_update_ref = tag_ptr(&obj->payment_path_failed.network_update, false);
3231                         jboolean all_paths_failed_conv = obj->payment_path_failed.all_paths_failed;
3232                         LDKCVec_RouteHopZ path_var = obj->payment_path_failed.path;
3233                         int64_tArray path_arr = NULL;
3234                         path_arr = (*env)->NewLongArray(env, path_var.datalen);
3235                         int64_t *path_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, path_arr, NULL);
3236                         for (size_t k = 0; k < path_var.datalen; k++) {
3237                                 LDKRouteHop path_conv_10_var = path_var.data[k];
3238                                 int64_t path_conv_10_ref = 0;
3239                                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
3240                                 path_conv_10_ref = tag_ptr(path_conv_10_var.inner, false);
3241                                 path_arr_ptr[k] = path_conv_10_ref;
3242                         }
3243                         (*env)->ReleasePrimitiveArrayCritical(env, path_arr, path_arr_ptr, 0);
3244                         int64_t short_channel_id_ref = tag_ptr(&obj->payment_path_failed.short_channel_id, false);
3245                         LDKRouteParameters retry_var = obj->payment_path_failed.retry;
3246                         int64_t retry_ref = 0;
3247                         CHECK_INNER_FIELD_ACCESS_OR_NULL(retry_var);
3248                         retry_ref = tag_ptr(retry_var.inner, false);
3249                         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);
3250                 }
3251                 case LDKEvent_ProbeSuccessful: {
3252                         int8_tArray payment_id_arr = (*env)->NewByteArray(env, 32);
3253                         (*env)->SetByteArrayRegion(env, payment_id_arr, 0, 32, obj->probe_successful.payment_id.data);
3254                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
3255                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->probe_successful.payment_hash.data);
3256                         LDKCVec_RouteHopZ path_var = obj->probe_successful.path;
3257                         int64_tArray path_arr = NULL;
3258                         path_arr = (*env)->NewLongArray(env, path_var.datalen);
3259                         int64_t *path_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, path_arr, NULL);
3260                         for (size_t k = 0; k < path_var.datalen; k++) {
3261                                 LDKRouteHop path_conv_10_var = path_var.data[k];
3262                                 int64_t path_conv_10_ref = 0;
3263                                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
3264                                 path_conv_10_ref = tag_ptr(path_conv_10_var.inner, false);
3265                                 path_arr_ptr[k] = path_conv_10_ref;
3266                         }
3267                         (*env)->ReleasePrimitiveArrayCritical(env, path_arr, path_arr_ptr, 0);
3268                         return (*env)->NewObject(env, LDKEvent_ProbeSuccessful_class, LDKEvent_ProbeSuccessful_meth, payment_id_arr, payment_hash_arr, path_arr);
3269                 }
3270                 case LDKEvent_ProbeFailed: {
3271                         int8_tArray payment_id_arr = (*env)->NewByteArray(env, 32);
3272                         (*env)->SetByteArrayRegion(env, payment_id_arr, 0, 32, obj->probe_failed.payment_id.data);
3273                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
3274                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->probe_failed.payment_hash.data);
3275                         LDKCVec_RouteHopZ path_var = obj->probe_failed.path;
3276                         int64_tArray path_arr = NULL;
3277                         path_arr = (*env)->NewLongArray(env, path_var.datalen);
3278                         int64_t *path_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, path_arr, NULL);
3279                         for (size_t k = 0; k < path_var.datalen; k++) {
3280                                 LDKRouteHop path_conv_10_var = path_var.data[k];
3281                                 int64_t path_conv_10_ref = 0;
3282                                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
3283                                 path_conv_10_ref = tag_ptr(path_conv_10_var.inner, false);
3284                                 path_arr_ptr[k] = path_conv_10_ref;
3285                         }
3286                         (*env)->ReleasePrimitiveArrayCritical(env, path_arr, path_arr_ptr, 0);
3287                         int64_t short_channel_id_ref = tag_ptr(&obj->probe_failed.short_channel_id, false);
3288                         return (*env)->NewObject(env, LDKEvent_ProbeFailed_class, LDKEvent_ProbeFailed_meth, payment_id_arr, payment_hash_arr, path_arr, short_channel_id_ref);
3289                 }
3290                 case LDKEvent_PendingHTLCsForwardable: {
3291                         int64_t time_forwardable_conv = obj->pending_htl_cs_forwardable.time_forwardable;
3292                         return (*env)->NewObject(env, LDKEvent_PendingHTLCsForwardable_class, LDKEvent_PendingHTLCsForwardable_meth, time_forwardable_conv);
3293                 }
3294                 case LDKEvent_HTLCIntercepted: {
3295                         int8_tArray intercept_id_arr = (*env)->NewByteArray(env, 32);
3296                         (*env)->SetByteArrayRegion(env, intercept_id_arr, 0, 32, obj->htlc_intercepted.intercept_id.data);
3297                         int64_t requested_next_hop_scid_conv = obj->htlc_intercepted.requested_next_hop_scid;
3298                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
3299                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->htlc_intercepted.payment_hash.data);
3300                         int64_t inbound_amount_msat_conv = obj->htlc_intercepted.inbound_amount_msat;
3301                         int64_t expected_outbound_amount_msat_conv = obj->htlc_intercepted.expected_outbound_amount_msat;
3302                         return (*env)->NewObject(env, LDKEvent_HTLCIntercepted_class, LDKEvent_HTLCIntercepted_meth, intercept_id_arr, requested_next_hop_scid_conv, payment_hash_arr, inbound_amount_msat_conv, expected_outbound_amount_msat_conv);
3303                 }
3304                 case LDKEvent_SpendableOutputs: {
3305                         LDKCVec_SpendableOutputDescriptorZ outputs_var = obj->spendable_outputs.outputs;
3306                         int64_tArray outputs_arr = NULL;
3307                         outputs_arr = (*env)->NewLongArray(env, outputs_var.datalen);
3308                         int64_t *outputs_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, outputs_arr, NULL);
3309                         for (size_t b = 0; b < outputs_var.datalen; b++) {
3310                                 int64_t outputs_conv_27_ref = tag_ptr(&outputs_var.data[b], false);
3311                                 outputs_arr_ptr[b] = outputs_conv_27_ref;
3312                         }
3313                         (*env)->ReleasePrimitiveArrayCritical(env, outputs_arr, outputs_arr_ptr, 0);
3314                         return (*env)->NewObject(env, LDKEvent_SpendableOutputs_class, LDKEvent_SpendableOutputs_meth, outputs_arr);
3315                 }
3316                 case LDKEvent_PaymentForwarded: {
3317                         int8_tArray prev_channel_id_arr = (*env)->NewByteArray(env, 32);
3318                         (*env)->SetByteArrayRegion(env, prev_channel_id_arr, 0, 32, obj->payment_forwarded.prev_channel_id.data);
3319                         int8_tArray next_channel_id_arr = (*env)->NewByteArray(env, 32);
3320                         (*env)->SetByteArrayRegion(env, next_channel_id_arr, 0, 32, obj->payment_forwarded.next_channel_id.data);
3321                         int64_t fee_earned_msat_ref = tag_ptr(&obj->payment_forwarded.fee_earned_msat, false);
3322                         jboolean claim_from_onchain_tx_conv = obj->payment_forwarded.claim_from_onchain_tx;
3323                         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);
3324                 }
3325                 case LDKEvent_ChannelReady: {
3326                         int8_tArray channel_id_arr = (*env)->NewByteArray(env, 32);
3327                         (*env)->SetByteArrayRegion(env, channel_id_arr, 0, 32, obj->channel_ready.channel_id.data);
3328                         int8_tArray user_channel_id_arr = (*env)->NewByteArray(env, 16);
3329                         (*env)->SetByteArrayRegion(env, user_channel_id_arr, 0, 16, obj->channel_ready.user_channel_id.le_bytes);
3330                         int8_tArray counterparty_node_id_arr = (*env)->NewByteArray(env, 33);
3331                         (*env)->SetByteArrayRegion(env, counterparty_node_id_arr, 0, 33, obj->channel_ready.counterparty_node_id.compressed_form);
3332                         LDKChannelTypeFeatures channel_type_var = obj->channel_ready.channel_type;
3333                         int64_t channel_type_ref = 0;
3334                         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_type_var);
3335                         channel_type_ref = tag_ptr(channel_type_var.inner, false);
3336                         return (*env)->NewObject(env, LDKEvent_ChannelReady_class, LDKEvent_ChannelReady_meth, channel_id_arr, user_channel_id_arr, counterparty_node_id_arr, channel_type_ref);
3337                 }
3338                 case LDKEvent_ChannelClosed: {
3339                         int8_tArray channel_id_arr = (*env)->NewByteArray(env, 32);
3340                         (*env)->SetByteArrayRegion(env, channel_id_arr, 0, 32, obj->channel_closed.channel_id.data);
3341                         int8_tArray user_channel_id_arr = (*env)->NewByteArray(env, 16);
3342                         (*env)->SetByteArrayRegion(env, user_channel_id_arr, 0, 16, obj->channel_closed.user_channel_id.le_bytes);
3343                         int64_t reason_ref = tag_ptr(&obj->channel_closed.reason, false);
3344                         return (*env)->NewObject(env, LDKEvent_ChannelClosed_class, LDKEvent_ChannelClosed_meth, channel_id_arr, user_channel_id_arr, reason_ref);
3345                 }
3346                 case LDKEvent_DiscardFunding: {
3347                         int8_tArray channel_id_arr = (*env)->NewByteArray(env, 32);
3348                         (*env)->SetByteArrayRegion(env, channel_id_arr, 0, 32, obj->discard_funding.channel_id.data);
3349                         LDKTransaction transaction_var = obj->discard_funding.transaction;
3350                         int8_tArray transaction_arr = (*env)->NewByteArray(env, transaction_var.datalen);
3351                         (*env)->SetByteArrayRegion(env, transaction_arr, 0, transaction_var.datalen, transaction_var.data);
3352                         return (*env)->NewObject(env, LDKEvent_DiscardFunding_class, LDKEvent_DiscardFunding_meth, channel_id_arr, transaction_arr);
3353                 }
3354                 case LDKEvent_OpenChannelRequest: {
3355                         int8_tArray temporary_channel_id_arr = (*env)->NewByteArray(env, 32);
3356                         (*env)->SetByteArrayRegion(env, temporary_channel_id_arr, 0, 32, obj->open_channel_request.temporary_channel_id.data);
3357                         int8_tArray counterparty_node_id_arr = (*env)->NewByteArray(env, 33);
3358                         (*env)->SetByteArrayRegion(env, counterparty_node_id_arr, 0, 33, obj->open_channel_request.counterparty_node_id.compressed_form);
3359                         int64_t funding_satoshis_conv = obj->open_channel_request.funding_satoshis;
3360                         int64_t push_msat_conv = obj->open_channel_request.push_msat;
3361                         LDKChannelTypeFeatures channel_type_var = obj->open_channel_request.channel_type;
3362                         int64_t channel_type_ref = 0;
3363                         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_type_var);
3364                         channel_type_ref = tag_ptr(channel_type_var.inner, false);
3365                         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);
3366                 }
3367                 case LDKEvent_HTLCHandlingFailed: {
3368                         int8_tArray prev_channel_id_arr = (*env)->NewByteArray(env, 32);
3369                         (*env)->SetByteArrayRegion(env, prev_channel_id_arr, 0, 32, obj->htlc_handling_failed.prev_channel_id.data);
3370                         int64_t failed_next_destination_ref = tag_ptr(&obj->htlc_handling_failed.failed_next_destination, false);
3371                         return (*env)->NewObject(env, LDKEvent_HTLCHandlingFailed_class, LDKEvent_HTLCHandlingFailed_meth, prev_channel_id_arr, failed_next_destination_ref);
3372                 }
3373                 default: abort();
3374         }
3375 }
3376 static jclass LDKCOption_EventZ_Some_class = NULL;
3377 static jmethodID LDKCOption_EventZ_Some_meth = NULL;
3378 static jclass LDKCOption_EventZ_None_class = NULL;
3379 static jmethodID LDKCOption_EventZ_None_meth = NULL;
3380 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1EventZ_init (JNIEnv *env, jclass clz) {
3381         LDKCOption_EventZ_Some_class =
3382                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_EventZ$Some"));
3383         CHECK(LDKCOption_EventZ_Some_class != NULL);
3384         LDKCOption_EventZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_EventZ_Some_class, "<init>", "(J)V");
3385         CHECK(LDKCOption_EventZ_Some_meth != NULL);
3386         LDKCOption_EventZ_None_class =
3387                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_EventZ$None"));
3388         CHECK(LDKCOption_EventZ_None_class != NULL);
3389         LDKCOption_EventZ_None_meth = (*env)->GetMethodID(env, LDKCOption_EventZ_None_class, "<init>", "()V");
3390         CHECK(LDKCOption_EventZ_None_meth != NULL);
3391 }
3392 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1EventZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
3393         LDKCOption_EventZ *obj = (LDKCOption_EventZ*)untag_ptr(ptr);
3394         switch(obj->tag) {
3395                 case LDKCOption_EventZ_Some: {
3396                         int64_t some_ref = tag_ptr(&obj->some, false);
3397                         return (*env)->NewObject(env, LDKCOption_EventZ_Some_class, LDKCOption_EventZ_Some_meth, some_ref);
3398                 }
3399                 case LDKCOption_EventZ_None: {
3400                         return (*env)->NewObject(env, LDKCOption_EventZ_None_class, LDKCOption_EventZ_None_meth);
3401                 }
3402                 default: abort();
3403         }
3404 }
3405 static inline struct LDKCOption_EventZ CResult_COption_EventZDecodeErrorZ_get_ok(LDKCResult_COption_EventZDecodeErrorZ *NONNULL_PTR owner){
3406 CHECK(owner->result_ok);
3407         return COption_EventZ_clone(&*owner->contents.result);
3408 }
3409 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1EventZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3410         LDKCResult_COption_EventZDecodeErrorZ* owner_conv = (LDKCResult_COption_EventZDecodeErrorZ*)untag_ptr(owner);
3411         LDKCOption_EventZ *ret_copy = MALLOC(sizeof(LDKCOption_EventZ), "LDKCOption_EventZ");
3412         *ret_copy = CResult_COption_EventZDecodeErrorZ_get_ok(owner_conv);
3413         int64_t ret_ref = tag_ptr(ret_copy, true);
3414         return ret_ref;
3415 }
3416
3417 static inline struct LDKDecodeError CResult_COption_EventZDecodeErrorZ_get_err(LDKCResult_COption_EventZDecodeErrorZ *NONNULL_PTR owner){
3418 CHECK(!owner->result_ok);
3419         return DecodeError_clone(&*owner->contents.err);
3420 }
3421 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1EventZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3422         LDKCResult_COption_EventZDecodeErrorZ* owner_conv = (LDKCResult_COption_EventZDecodeErrorZ*)untag_ptr(owner);
3423         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
3424         *ret_copy = CResult_COption_EventZDecodeErrorZ_get_err(owner_conv);
3425         int64_t ret_ref = tag_ptr(ret_copy, true);
3426         return ret_ref;
3427 }
3428
3429 static jclass LDKErrorAction_DisconnectPeer_class = NULL;
3430 static jmethodID LDKErrorAction_DisconnectPeer_meth = NULL;
3431 static jclass LDKErrorAction_IgnoreError_class = NULL;
3432 static jmethodID LDKErrorAction_IgnoreError_meth = NULL;
3433 static jclass LDKErrorAction_IgnoreAndLog_class = NULL;
3434 static jmethodID LDKErrorAction_IgnoreAndLog_meth = NULL;
3435 static jclass LDKErrorAction_IgnoreDuplicateGossip_class = NULL;
3436 static jmethodID LDKErrorAction_IgnoreDuplicateGossip_meth = NULL;
3437 static jclass LDKErrorAction_SendErrorMessage_class = NULL;
3438 static jmethodID LDKErrorAction_SendErrorMessage_meth = NULL;
3439 static jclass LDKErrorAction_SendWarningMessage_class = NULL;
3440 static jmethodID LDKErrorAction_SendWarningMessage_meth = NULL;
3441 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKErrorAction_init (JNIEnv *env, jclass clz) {
3442         LDKErrorAction_DisconnectPeer_class =
3443                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKErrorAction$DisconnectPeer"));
3444         CHECK(LDKErrorAction_DisconnectPeer_class != NULL);
3445         LDKErrorAction_DisconnectPeer_meth = (*env)->GetMethodID(env, LDKErrorAction_DisconnectPeer_class, "<init>", "(J)V");
3446         CHECK(LDKErrorAction_DisconnectPeer_meth != NULL);
3447         LDKErrorAction_IgnoreError_class =
3448                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKErrorAction$IgnoreError"));
3449         CHECK(LDKErrorAction_IgnoreError_class != NULL);
3450         LDKErrorAction_IgnoreError_meth = (*env)->GetMethodID(env, LDKErrorAction_IgnoreError_class, "<init>", "()V");
3451         CHECK(LDKErrorAction_IgnoreError_meth != NULL);
3452         LDKErrorAction_IgnoreAndLog_class =
3453                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKErrorAction$IgnoreAndLog"));
3454         CHECK(LDKErrorAction_IgnoreAndLog_class != NULL);
3455         LDKErrorAction_IgnoreAndLog_meth = (*env)->GetMethodID(env, LDKErrorAction_IgnoreAndLog_class, "<init>", "(Lorg/ldk/enums/Level;)V");
3456         CHECK(LDKErrorAction_IgnoreAndLog_meth != NULL);
3457         LDKErrorAction_IgnoreDuplicateGossip_class =
3458                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKErrorAction$IgnoreDuplicateGossip"));
3459         CHECK(LDKErrorAction_IgnoreDuplicateGossip_class != NULL);
3460         LDKErrorAction_IgnoreDuplicateGossip_meth = (*env)->GetMethodID(env, LDKErrorAction_IgnoreDuplicateGossip_class, "<init>", "()V");
3461         CHECK(LDKErrorAction_IgnoreDuplicateGossip_meth != NULL);
3462         LDKErrorAction_SendErrorMessage_class =
3463                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKErrorAction$SendErrorMessage"));
3464         CHECK(LDKErrorAction_SendErrorMessage_class != NULL);
3465         LDKErrorAction_SendErrorMessage_meth = (*env)->GetMethodID(env, LDKErrorAction_SendErrorMessage_class, "<init>", "(J)V");
3466         CHECK(LDKErrorAction_SendErrorMessage_meth != NULL);
3467         LDKErrorAction_SendWarningMessage_class =
3468                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKErrorAction$SendWarningMessage"));
3469         CHECK(LDKErrorAction_SendWarningMessage_class != NULL);
3470         LDKErrorAction_SendWarningMessage_meth = (*env)->GetMethodID(env, LDKErrorAction_SendWarningMessage_class, "<init>", "(JLorg/ldk/enums/Level;)V");
3471         CHECK(LDKErrorAction_SendWarningMessage_meth != NULL);
3472 }
3473 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKErrorAction_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
3474         LDKErrorAction *obj = (LDKErrorAction*)untag_ptr(ptr);
3475         switch(obj->tag) {
3476                 case LDKErrorAction_DisconnectPeer: {
3477                         LDKErrorMessage msg_var = obj->disconnect_peer.msg;
3478                         int64_t msg_ref = 0;
3479                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3480                         msg_ref = tag_ptr(msg_var.inner, false);
3481                         return (*env)->NewObject(env, LDKErrorAction_DisconnectPeer_class, LDKErrorAction_DisconnectPeer_meth, msg_ref);
3482                 }
3483                 case LDKErrorAction_IgnoreError: {
3484                         return (*env)->NewObject(env, LDKErrorAction_IgnoreError_class, LDKErrorAction_IgnoreError_meth);
3485                 }
3486                 case LDKErrorAction_IgnoreAndLog: {
3487                         jclass ignore_and_log_conv = LDKLevel_to_java(env, obj->ignore_and_log);
3488                         return (*env)->NewObject(env, LDKErrorAction_IgnoreAndLog_class, LDKErrorAction_IgnoreAndLog_meth, ignore_and_log_conv);
3489                 }
3490                 case LDKErrorAction_IgnoreDuplicateGossip: {
3491                         return (*env)->NewObject(env, LDKErrorAction_IgnoreDuplicateGossip_class, LDKErrorAction_IgnoreDuplicateGossip_meth);
3492                 }
3493                 case LDKErrorAction_SendErrorMessage: {
3494                         LDKErrorMessage msg_var = obj->send_error_message.msg;
3495                         int64_t msg_ref = 0;
3496                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3497                         msg_ref = tag_ptr(msg_var.inner, false);
3498                         return (*env)->NewObject(env, LDKErrorAction_SendErrorMessage_class, LDKErrorAction_SendErrorMessage_meth, msg_ref);
3499                 }
3500                 case LDKErrorAction_SendWarningMessage: {
3501                         LDKWarningMessage msg_var = obj->send_warning_message.msg;
3502                         int64_t msg_ref = 0;
3503                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3504                         msg_ref = tag_ptr(msg_var.inner, false);
3505                         jclass log_level_conv = LDKLevel_to_java(env, obj->send_warning_message.log_level);
3506                         return (*env)->NewObject(env, LDKErrorAction_SendWarningMessage_class, LDKErrorAction_SendWarningMessage_meth, msg_ref, log_level_conv);
3507                 }
3508                 default: abort();
3509         }
3510 }
3511 static jclass LDKMessageSendEvent_SendAcceptChannel_class = NULL;
3512 static jmethodID LDKMessageSendEvent_SendAcceptChannel_meth = NULL;
3513 static jclass LDKMessageSendEvent_SendOpenChannel_class = NULL;
3514 static jmethodID LDKMessageSendEvent_SendOpenChannel_meth = NULL;
3515 static jclass LDKMessageSendEvent_SendFundingCreated_class = NULL;
3516 static jmethodID LDKMessageSendEvent_SendFundingCreated_meth = NULL;
3517 static jclass LDKMessageSendEvent_SendFundingSigned_class = NULL;
3518 static jmethodID LDKMessageSendEvent_SendFundingSigned_meth = NULL;
3519 static jclass LDKMessageSendEvent_SendChannelReady_class = NULL;
3520 static jmethodID LDKMessageSendEvent_SendChannelReady_meth = NULL;
3521 static jclass LDKMessageSendEvent_SendAnnouncementSignatures_class = NULL;
3522 static jmethodID LDKMessageSendEvent_SendAnnouncementSignatures_meth = NULL;
3523 static jclass LDKMessageSendEvent_UpdateHTLCs_class = NULL;
3524 static jmethodID LDKMessageSendEvent_UpdateHTLCs_meth = NULL;
3525 static jclass LDKMessageSendEvent_SendRevokeAndACK_class = NULL;
3526 static jmethodID LDKMessageSendEvent_SendRevokeAndACK_meth = NULL;
3527 static jclass LDKMessageSendEvent_SendClosingSigned_class = NULL;
3528 static jmethodID LDKMessageSendEvent_SendClosingSigned_meth = NULL;
3529 static jclass LDKMessageSendEvent_SendShutdown_class = NULL;
3530 static jmethodID LDKMessageSendEvent_SendShutdown_meth = NULL;
3531 static jclass LDKMessageSendEvent_SendChannelReestablish_class = NULL;
3532 static jmethodID LDKMessageSendEvent_SendChannelReestablish_meth = NULL;
3533 static jclass LDKMessageSendEvent_SendChannelAnnouncement_class = NULL;
3534 static jmethodID LDKMessageSendEvent_SendChannelAnnouncement_meth = NULL;
3535 static jclass LDKMessageSendEvent_BroadcastChannelAnnouncement_class = NULL;
3536 static jmethodID LDKMessageSendEvent_BroadcastChannelAnnouncement_meth = NULL;
3537 static jclass LDKMessageSendEvent_BroadcastChannelUpdate_class = NULL;
3538 static jmethodID LDKMessageSendEvent_BroadcastChannelUpdate_meth = NULL;
3539 static jclass LDKMessageSendEvent_SendChannelUpdate_class = NULL;
3540 static jmethodID LDKMessageSendEvent_SendChannelUpdate_meth = NULL;
3541 static jclass LDKMessageSendEvent_HandleError_class = NULL;
3542 static jmethodID LDKMessageSendEvent_HandleError_meth = NULL;
3543 static jclass LDKMessageSendEvent_SendChannelRangeQuery_class = NULL;
3544 static jmethodID LDKMessageSendEvent_SendChannelRangeQuery_meth = NULL;
3545 static jclass LDKMessageSendEvent_SendShortIdsQuery_class = NULL;
3546 static jmethodID LDKMessageSendEvent_SendShortIdsQuery_meth = NULL;
3547 static jclass LDKMessageSendEvent_SendReplyChannelRange_class = NULL;
3548 static jmethodID LDKMessageSendEvent_SendReplyChannelRange_meth = NULL;
3549 static jclass LDKMessageSendEvent_SendGossipTimestampFilter_class = NULL;
3550 static jmethodID LDKMessageSendEvent_SendGossipTimestampFilter_meth = NULL;
3551 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKMessageSendEvent_init (JNIEnv *env, jclass clz) {
3552         LDKMessageSendEvent_SendAcceptChannel_class =
3553                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendAcceptChannel"));
3554         CHECK(LDKMessageSendEvent_SendAcceptChannel_class != NULL);
3555         LDKMessageSendEvent_SendAcceptChannel_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendAcceptChannel_class, "<init>", "([BJ)V");
3556         CHECK(LDKMessageSendEvent_SendAcceptChannel_meth != NULL);
3557         LDKMessageSendEvent_SendOpenChannel_class =
3558                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendOpenChannel"));
3559         CHECK(LDKMessageSendEvent_SendOpenChannel_class != NULL);
3560         LDKMessageSendEvent_SendOpenChannel_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendOpenChannel_class, "<init>", "([BJ)V");
3561         CHECK(LDKMessageSendEvent_SendOpenChannel_meth != NULL);
3562         LDKMessageSendEvent_SendFundingCreated_class =
3563                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendFundingCreated"));
3564         CHECK(LDKMessageSendEvent_SendFundingCreated_class != NULL);
3565         LDKMessageSendEvent_SendFundingCreated_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendFundingCreated_class, "<init>", "([BJ)V");
3566         CHECK(LDKMessageSendEvent_SendFundingCreated_meth != NULL);
3567         LDKMessageSendEvent_SendFundingSigned_class =
3568                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendFundingSigned"));
3569         CHECK(LDKMessageSendEvent_SendFundingSigned_class != NULL);
3570         LDKMessageSendEvent_SendFundingSigned_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendFundingSigned_class, "<init>", "([BJ)V");
3571         CHECK(LDKMessageSendEvent_SendFundingSigned_meth != NULL);
3572         LDKMessageSendEvent_SendChannelReady_class =
3573                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendChannelReady"));
3574         CHECK(LDKMessageSendEvent_SendChannelReady_class != NULL);
3575         LDKMessageSendEvent_SendChannelReady_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendChannelReady_class, "<init>", "([BJ)V");
3576         CHECK(LDKMessageSendEvent_SendChannelReady_meth != NULL);
3577         LDKMessageSendEvent_SendAnnouncementSignatures_class =
3578                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendAnnouncementSignatures"));
3579         CHECK(LDKMessageSendEvent_SendAnnouncementSignatures_class != NULL);
3580         LDKMessageSendEvent_SendAnnouncementSignatures_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendAnnouncementSignatures_class, "<init>", "([BJ)V");
3581         CHECK(LDKMessageSendEvent_SendAnnouncementSignatures_meth != NULL);
3582         LDKMessageSendEvent_UpdateHTLCs_class =
3583                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$UpdateHTLCs"));
3584         CHECK(LDKMessageSendEvent_UpdateHTLCs_class != NULL);
3585         LDKMessageSendEvent_UpdateHTLCs_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_UpdateHTLCs_class, "<init>", "([BJ)V");
3586         CHECK(LDKMessageSendEvent_UpdateHTLCs_meth != NULL);
3587         LDKMessageSendEvent_SendRevokeAndACK_class =
3588                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendRevokeAndACK"));
3589         CHECK(LDKMessageSendEvent_SendRevokeAndACK_class != NULL);
3590         LDKMessageSendEvent_SendRevokeAndACK_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendRevokeAndACK_class, "<init>", "([BJ)V");
3591         CHECK(LDKMessageSendEvent_SendRevokeAndACK_meth != NULL);
3592         LDKMessageSendEvent_SendClosingSigned_class =
3593                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendClosingSigned"));
3594         CHECK(LDKMessageSendEvent_SendClosingSigned_class != NULL);
3595         LDKMessageSendEvent_SendClosingSigned_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendClosingSigned_class, "<init>", "([BJ)V");
3596         CHECK(LDKMessageSendEvent_SendClosingSigned_meth != NULL);
3597         LDKMessageSendEvent_SendShutdown_class =
3598                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendShutdown"));
3599         CHECK(LDKMessageSendEvent_SendShutdown_class != NULL);
3600         LDKMessageSendEvent_SendShutdown_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendShutdown_class, "<init>", "([BJ)V");
3601         CHECK(LDKMessageSendEvent_SendShutdown_meth != NULL);
3602         LDKMessageSendEvent_SendChannelReestablish_class =
3603                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendChannelReestablish"));
3604         CHECK(LDKMessageSendEvent_SendChannelReestablish_class != NULL);
3605         LDKMessageSendEvent_SendChannelReestablish_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendChannelReestablish_class, "<init>", "([BJ)V");
3606         CHECK(LDKMessageSendEvent_SendChannelReestablish_meth != NULL);
3607         LDKMessageSendEvent_SendChannelAnnouncement_class =
3608                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendChannelAnnouncement"));
3609         CHECK(LDKMessageSendEvent_SendChannelAnnouncement_class != NULL);
3610         LDKMessageSendEvent_SendChannelAnnouncement_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendChannelAnnouncement_class, "<init>", "([BJJ)V");
3611         CHECK(LDKMessageSendEvent_SendChannelAnnouncement_meth != NULL);
3612         LDKMessageSendEvent_BroadcastChannelAnnouncement_class =
3613                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$BroadcastChannelAnnouncement"));
3614         CHECK(LDKMessageSendEvent_BroadcastChannelAnnouncement_class != NULL);
3615         LDKMessageSendEvent_BroadcastChannelAnnouncement_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_BroadcastChannelAnnouncement_class, "<init>", "(JJ)V");
3616         CHECK(LDKMessageSendEvent_BroadcastChannelAnnouncement_meth != NULL);
3617         LDKMessageSendEvent_BroadcastChannelUpdate_class =
3618                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$BroadcastChannelUpdate"));
3619         CHECK(LDKMessageSendEvent_BroadcastChannelUpdate_class != NULL);
3620         LDKMessageSendEvent_BroadcastChannelUpdate_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_BroadcastChannelUpdate_class, "<init>", "(J)V");
3621         CHECK(LDKMessageSendEvent_BroadcastChannelUpdate_meth != NULL);
3622         LDKMessageSendEvent_SendChannelUpdate_class =
3623                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendChannelUpdate"));
3624         CHECK(LDKMessageSendEvent_SendChannelUpdate_class != NULL);
3625         LDKMessageSendEvent_SendChannelUpdate_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendChannelUpdate_class, "<init>", "([BJ)V");
3626         CHECK(LDKMessageSendEvent_SendChannelUpdate_meth != NULL);
3627         LDKMessageSendEvent_HandleError_class =
3628                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$HandleError"));
3629         CHECK(LDKMessageSendEvent_HandleError_class != NULL);
3630         LDKMessageSendEvent_HandleError_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_HandleError_class, "<init>", "([BJ)V");
3631         CHECK(LDKMessageSendEvent_HandleError_meth != NULL);
3632         LDKMessageSendEvent_SendChannelRangeQuery_class =
3633                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendChannelRangeQuery"));
3634         CHECK(LDKMessageSendEvent_SendChannelRangeQuery_class != NULL);
3635         LDKMessageSendEvent_SendChannelRangeQuery_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendChannelRangeQuery_class, "<init>", "([BJ)V");
3636         CHECK(LDKMessageSendEvent_SendChannelRangeQuery_meth != NULL);
3637         LDKMessageSendEvent_SendShortIdsQuery_class =
3638                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendShortIdsQuery"));
3639         CHECK(LDKMessageSendEvent_SendShortIdsQuery_class != NULL);
3640         LDKMessageSendEvent_SendShortIdsQuery_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendShortIdsQuery_class, "<init>", "([BJ)V");
3641         CHECK(LDKMessageSendEvent_SendShortIdsQuery_meth != NULL);
3642         LDKMessageSendEvent_SendReplyChannelRange_class =
3643                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendReplyChannelRange"));
3644         CHECK(LDKMessageSendEvent_SendReplyChannelRange_class != NULL);
3645         LDKMessageSendEvent_SendReplyChannelRange_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendReplyChannelRange_class, "<init>", "([BJ)V");
3646         CHECK(LDKMessageSendEvent_SendReplyChannelRange_meth != NULL);
3647         LDKMessageSendEvent_SendGossipTimestampFilter_class =
3648                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMessageSendEvent$SendGossipTimestampFilter"));
3649         CHECK(LDKMessageSendEvent_SendGossipTimestampFilter_class != NULL);
3650         LDKMessageSendEvent_SendGossipTimestampFilter_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendGossipTimestampFilter_class, "<init>", "([BJ)V");
3651         CHECK(LDKMessageSendEvent_SendGossipTimestampFilter_meth != NULL);
3652 }
3653 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKMessageSendEvent_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
3654         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)untag_ptr(ptr);
3655         switch(obj->tag) {
3656                 case LDKMessageSendEvent_SendAcceptChannel: {
3657                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
3658                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_accept_channel.node_id.compressed_form);
3659                         LDKAcceptChannel msg_var = obj->send_accept_channel.msg;
3660                         int64_t msg_ref = 0;
3661                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3662                         msg_ref = tag_ptr(msg_var.inner, false);
3663                         return (*env)->NewObject(env, LDKMessageSendEvent_SendAcceptChannel_class, LDKMessageSendEvent_SendAcceptChannel_meth, node_id_arr, msg_ref);
3664                 }
3665                 case LDKMessageSendEvent_SendOpenChannel: {
3666                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
3667                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_open_channel.node_id.compressed_form);
3668                         LDKOpenChannel msg_var = obj->send_open_channel.msg;
3669                         int64_t msg_ref = 0;
3670                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3671                         msg_ref = tag_ptr(msg_var.inner, false);
3672                         return (*env)->NewObject(env, LDKMessageSendEvent_SendOpenChannel_class, LDKMessageSendEvent_SendOpenChannel_meth, node_id_arr, msg_ref);
3673                 }
3674                 case LDKMessageSendEvent_SendFundingCreated: {
3675                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
3676                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_funding_created.node_id.compressed_form);
3677                         LDKFundingCreated msg_var = obj->send_funding_created.msg;
3678                         int64_t msg_ref = 0;
3679                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3680                         msg_ref = tag_ptr(msg_var.inner, false);
3681                         return (*env)->NewObject(env, LDKMessageSendEvent_SendFundingCreated_class, LDKMessageSendEvent_SendFundingCreated_meth, node_id_arr, msg_ref);
3682                 }
3683                 case LDKMessageSendEvent_SendFundingSigned: {
3684                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
3685                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_funding_signed.node_id.compressed_form);
3686                         LDKFundingSigned msg_var = obj->send_funding_signed.msg;
3687                         int64_t msg_ref = 0;
3688                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3689                         msg_ref = tag_ptr(msg_var.inner, false);
3690                         return (*env)->NewObject(env, LDKMessageSendEvent_SendFundingSigned_class, LDKMessageSendEvent_SendFundingSigned_meth, node_id_arr, msg_ref);
3691                 }
3692                 case LDKMessageSendEvent_SendChannelReady: {
3693                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
3694                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_channel_ready.node_id.compressed_form);
3695                         LDKChannelReady msg_var = obj->send_channel_ready.msg;
3696                         int64_t msg_ref = 0;
3697                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3698                         msg_ref = tag_ptr(msg_var.inner, false);
3699                         return (*env)->NewObject(env, LDKMessageSendEvent_SendChannelReady_class, LDKMessageSendEvent_SendChannelReady_meth, node_id_arr, msg_ref);
3700                 }
3701                 case LDKMessageSendEvent_SendAnnouncementSignatures: {
3702                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
3703                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_announcement_signatures.node_id.compressed_form);
3704                         LDKAnnouncementSignatures msg_var = obj->send_announcement_signatures.msg;
3705                         int64_t msg_ref = 0;
3706                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3707                         msg_ref = tag_ptr(msg_var.inner, false);
3708                         return (*env)->NewObject(env, LDKMessageSendEvent_SendAnnouncementSignatures_class, LDKMessageSendEvent_SendAnnouncementSignatures_meth, node_id_arr, msg_ref);
3709                 }
3710                 case LDKMessageSendEvent_UpdateHTLCs: {
3711                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
3712                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->update_htl_cs.node_id.compressed_form);
3713                         LDKCommitmentUpdate updates_var = obj->update_htl_cs.updates;
3714                         int64_t updates_ref = 0;
3715                         CHECK_INNER_FIELD_ACCESS_OR_NULL(updates_var);
3716                         updates_ref = tag_ptr(updates_var.inner, false);
3717                         return (*env)->NewObject(env, LDKMessageSendEvent_UpdateHTLCs_class, LDKMessageSendEvent_UpdateHTLCs_meth, node_id_arr, updates_ref);
3718                 }
3719                 case LDKMessageSendEvent_SendRevokeAndACK: {
3720                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
3721                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_revoke_and_ack.node_id.compressed_form);
3722                         LDKRevokeAndACK msg_var = obj->send_revoke_and_ack.msg;
3723                         int64_t msg_ref = 0;
3724                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3725                         msg_ref = tag_ptr(msg_var.inner, false);
3726                         return (*env)->NewObject(env, LDKMessageSendEvent_SendRevokeAndACK_class, LDKMessageSendEvent_SendRevokeAndACK_meth, node_id_arr, msg_ref);
3727                 }
3728                 case LDKMessageSendEvent_SendClosingSigned: {
3729                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
3730                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_closing_signed.node_id.compressed_form);
3731                         LDKClosingSigned msg_var = obj->send_closing_signed.msg;
3732                         int64_t msg_ref = 0;
3733                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3734                         msg_ref = tag_ptr(msg_var.inner, false);
3735                         return (*env)->NewObject(env, LDKMessageSendEvent_SendClosingSigned_class, LDKMessageSendEvent_SendClosingSigned_meth, node_id_arr, msg_ref);
3736                 }
3737                 case LDKMessageSendEvent_SendShutdown: {
3738                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
3739                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_shutdown.node_id.compressed_form);
3740                         LDKShutdown msg_var = obj->send_shutdown.msg;
3741                         int64_t msg_ref = 0;
3742                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3743                         msg_ref = tag_ptr(msg_var.inner, false);
3744                         return (*env)->NewObject(env, LDKMessageSendEvent_SendShutdown_class, LDKMessageSendEvent_SendShutdown_meth, node_id_arr, msg_ref);
3745                 }
3746                 case LDKMessageSendEvent_SendChannelReestablish: {
3747                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
3748                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_channel_reestablish.node_id.compressed_form);
3749                         LDKChannelReestablish msg_var = obj->send_channel_reestablish.msg;
3750                         int64_t msg_ref = 0;
3751                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3752                         msg_ref = tag_ptr(msg_var.inner, false);
3753                         return (*env)->NewObject(env, LDKMessageSendEvent_SendChannelReestablish_class, LDKMessageSendEvent_SendChannelReestablish_meth, node_id_arr, msg_ref);
3754                 }
3755                 case LDKMessageSendEvent_SendChannelAnnouncement: {
3756                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
3757                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_channel_announcement.node_id.compressed_form);
3758                         LDKChannelAnnouncement msg_var = obj->send_channel_announcement.msg;
3759                         int64_t msg_ref = 0;
3760                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3761                         msg_ref = tag_ptr(msg_var.inner, false);
3762                         LDKChannelUpdate update_msg_var = obj->send_channel_announcement.update_msg;
3763                         int64_t update_msg_ref = 0;
3764                         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_msg_var);
3765                         update_msg_ref = tag_ptr(update_msg_var.inner, false);
3766                         return (*env)->NewObject(env, LDKMessageSendEvent_SendChannelAnnouncement_class, LDKMessageSendEvent_SendChannelAnnouncement_meth, node_id_arr, msg_ref, update_msg_ref);
3767                 }
3768                 case LDKMessageSendEvent_BroadcastChannelAnnouncement: {
3769                         LDKChannelAnnouncement msg_var = obj->broadcast_channel_announcement.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                         LDKChannelUpdate update_msg_var = obj->broadcast_channel_announcement.update_msg;
3774                         int64_t update_msg_ref = 0;
3775                         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_msg_var);
3776                         update_msg_ref = tag_ptr(update_msg_var.inner, false);
3777                         return (*env)->NewObject(env, LDKMessageSendEvent_BroadcastChannelAnnouncement_class, LDKMessageSendEvent_BroadcastChannelAnnouncement_meth, msg_ref, update_msg_ref);
3778                 }
3779                 case LDKMessageSendEvent_BroadcastChannelUpdate: {
3780                         LDKChannelUpdate msg_var = obj->broadcast_channel_update.msg;
3781                         int64_t msg_ref = 0;
3782                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3783                         msg_ref = tag_ptr(msg_var.inner, false);
3784                         return (*env)->NewObject(env, LDKMessageSendEvent_BroadcastChannelUpdate_class, LDKMessageSendEvent_BroadcastChannelUpdate_meth, msg_ref);
3785                 }
3786                 case LDKMessageSendEvent_SendChannelUpdate: {
3787                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
3788                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_channel_update.node_id.compressed_form);
3789                         LDKChannelUpdate msg_var = obj->send_channel_update.msg;
3790                         int64_t msg_ref = 0;
3791                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3792                         msg_ref = tag_ptr(msg_var.inner, false);
3793                         return (*env)->NewObject(env, LDKMessageSendEvent_SendChannelUpdate_class, LDKMessageSendEvent_SendChannelUpdate_meth, node_id_arr, msg_ref);
3794                 }
3795                 case LDKMessageSendEvent_HandleError: {
3796                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
3797                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->handle_error.node_id.compressed_form);
3798                         int64_t action_ref = tag_ptr(&obj->handle_error.action, false);
3799                         return (*env)->NewObject(env, LDKMessageSendEvent_HandleError_class, LDKMessageSendEvent_HandleError_meth, node_id_arr, action_ref);
3800                 }
3801                 case LDKMessageSendEvent_SendChannelRangeQuery: {
3802                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
3803                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_channel_range_query.node_id.compressed_form);
3804                         LDKQueryChannelRange msg_var = obj->send_channel_range_query.msg;
3805                         int64_t msg_ref = 0;
3806                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3807                         msg_ref = tag_ptr(msg_var.inner, false);
3808                         return (*env)->NewObject(env, LDKMessageSendEvent_SendChannelRangeQuery_class, LDKMessageSendEvent_SendChannelRangeQuery_meth, node_id_arr, msg_ref);
3809                 }
3810                 case LDKMessageSendEvent_SendShortIdsQuery: {
3811                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
3812                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_short_ids_query.node_id.compressed_form);
3813                         LDKQueryShortChannelIds msg_var = obj->send_short_ids_query.msg;
3814                         int64_t msg_ref = 0;
3815                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3816                         msg_ref = tag_ptr(msg_var.inner, false);
3817                         return (*env)->NewObject(env, LDKMessageSendEvent_SendShortIdsQuery_class, LDKMessageSendEvent_SendShortIdsQuery_meth, node_id_arr, msg_ref);
3818                 }
3819                 case LDKMessageSendEvent_SendReplyChannelRange: {
3820                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
3821                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_reply_channel_range.node_id.compressed_form);
3822                         LDKReplyChannelRange msg_var = obj->send_reply_channel_range.msg;
3823                         int64_t msg_ref = 0;
3824                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3825                         msg_ref = tag_ptr(msg_var.inner, false);
3826                         return (*env)->NewObject(env, LDKMessageSendEvent_SendReplyChannelRange_class, LDKMessageSendEvent_SendReplyChannelRange_meth, node_id_arr, msg_ref);
3827                 }
3828                 case LDKMessageSendEvent_SendGossipTimestampFilter: {
3829                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
3830                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_gossip_timestamp_filter.node_id.compressed_form);
3831                         LDKGossipTimestampFilter msg_var = obj->send_gossip_timestamp_filter.msg;
3832                         int64_t msg_ref = 0;
3833                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3834                         msg_ref = tag_ptr(msg_var.inner, false);
3835                         return (*env)->NewObject(env, LDKMessageSendEvent_SendGossipTimestampFilter_class, LDKMessageSendEvent_SendGossipTimestampFilter_meth, node_id_arr, msg_ref);
3836                 }
3837                 default: abort();
3838         }
3839 }
3840 static inline LDKCVec_MessageSendEventZ CVec_MessageSendEventZ_clone(const LDKCVec_MessageSendEventZ *orig) {
3841         LDKCVec_MessageSendEventZ ret = { .data = MALLOC(sizeof(LDKMessageSendEvent) * orig->datalen, "LDKCVec_MessageSendEventZ clone bytes"), .datalen = orig->datalen };
3842         for (size_t i = 0; i < ret.datalen; i++) {
3843                 ret.data[i] = MessageSendEvent_clone(&orig->data[i]);
3844         }
3845         return ret;
3846 }
3847 static inline struct LDKTxOut CResult_TxOutAccessErrorZ_get_ok(LDKCResult_TxOutAccessErrorZ *NONNULL_PTR owner){
3848 CHECK(owner->result_ok);
3849         return TxOut_clone(&*owner->contents.result);
3850 }
3851 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
3852         LDKCResult_TxOutAccessErrorZ* owner_conv = (LDKCResult_TxOutAccessErrorZ*)untag_ptr(owner);
3853         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
3854         *ret_ref = CResult_TxOutAccessErrorZ_get_ok(owner_conv);
3855         return tag_ptr(ret_ref, true);
3856 }
3857
3858 static inline enum LDKAccessError CResult_TxOutAccessErrorZ_get_err(LDKCResult_TxOutAccessErrorZ *NONNULL_PTR owner){
3859 CHECK(!owner->result_ok);
3860         return AccessError_clone(&*owner->contents.err);
3861 }
3862 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
3863         LDKCResult_TxOutAccessErrorZ* owner_conv = (LDKCResult_TxOutAccessErrorZ*)untag_ptr(owner);
3864         jclass ret_conv = LDKAccessError_to_java(env, CResult_TxOutAccessErrorZ_get_err(owner_conv));
3865         return ret_conv;
3866 }
3867
3868 static inline uintptr_t C2Tuple_usizeTransactionZ_get_a(LDKC2Tuple_usizeTransactionZ *NONNULL_PTR owner){
3869         return owner->a;
3870 }
3871 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
3872         LDKC2Tuple_usizeTransactionZ* owner_conv = (LDKC2Tuple_usizeTransactionZ*)untag_ptr(owner);
3873         int64_t ret_conv = C2Tuple_usizeTransactionZ_get_a(owner_conv);
3874         return ret_conv;
3875 }
3876
3877 static inline struct LDKTransaction C2Tuple_usizeTransactionZ_get_b(LDKC2Tuple_usizeTransactionZ *NONNULL_PTR owner){
3878         return owner->b;
3879 }
3880 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
3881         LDKC2Tuple_usizeTransactionZ* owner_conv = (LDKC2Tuple_usizeTransactionZ*)untag_ptr(owner);
3882         LDKTransaction ret_var = C2Tuple_usizeTransactionZ_get_b(owner_conv);
3883         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
3884         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
3885         return ret_arr;
3886 }
3887
3888 static inline LDKCVec_C2Tuple_usizeTransactionZZ CVec_C2Tuple_usizeTransactionZZ_clone(const LDKCVec_C2Tuple_usizeTransactionZZ *orig) {
3889         LDKCVec_C2Tuple_usizeTransactionZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ) * orig->datalen, "LDKCVec_C2Tuple_usizeTransactionZZ clone bytes"), .datalen = orig->datalen };
3890         for (size_t i = 0; i < ret.datalen; i++) {
3891                 ret.data[i] = C2Tuple_usizeTransactionZ_clone(&orig->data[i]);
3892         }
3893         return ret;
3894 }
3895 static inline struct LDKThirtyTwoBytes C2Tuple_TxidBlockHashZ_get_a(LDKC2Tuple_TxidBlockHashZ *NONNULL_PTR owner){
3896         return ThirtyTwoBytes_clone(&owner->a);
3897 }
3898 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidBlockHashZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
3899         LDKC2Tuple_TxidBlockHashZ* owner_conv = (LDKC2Tuple_TxidBlockHashZ*)untag_ptr(owner);
3900         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
3901         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_TxidBlockHashZ_get_a(owner_conv).data);
3902         return ret_arr;
3903 }
3904
3905 static inline struct LDKThirtyTwoBytes C2Tuple_TxidBlockHashZ_get_b(LDKC2Tuple_TxidBlockHashZ *NONNULL_PTR owner){
3906         return ThirtyTwoBytes_clone(&owner->b);
3907 }
3908 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidBlockHashZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
3909         LDKC2Tuple_TxidBlockHashZ* owner_conv = (LDKC2Tuple_TxidBlockHashZ*)untag_ptr(owner);
3910         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
3911         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_TxidBlockHashZ_get_b(owner_conv).data);
3912         return ret_arr;
3913 }
3914
3915 static inline LDKCVec_C2Tuple_TxidBlockHashZZ CVec_C2Tuple_TxidBlockHashZZ_clone(const LDKCVec_C2Tuple_TxidBlockHashZZ *orig) {
3916         LDKCVec_C2Tuple_TxidBlockHashZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_TxidBlockHashZ) * orig->datalen, "LDKCVec_C2Tuple_TxidBlockHashZZ clone bytes"), .datalen = orig->datalen };
3917         for (size_t i = 0; i < ret.datalen; i++) {
3918                 ret.data[i] = C2Tuple_TxidBlockHashZ_clone(&orig->data[i]);
3919         }
3920         return ret;
3921 }
3922 static jclass LDKMonitorEvent_HTLCEvent_class = NULL;
3923 static jmethodID LDKMonitorEvent_HTLCEvent_meth = NULL;
3924 static jclass LDKMonitorEvent_CommitmentTxConfirmed_class = NULL;
3925 static jmethodID LDKMonitorEvent_CommitmentTxConfirmed_meth = NULL;
3926 static jclass LDKMonitorEvent_Completed_class = NULL;
3927 static jmethodID LDKMonitorEvent_Completed_meth = NULL;
3928 static jclass LDKMonitorEvent_UpdateFailed_class = NULL;
3929 static jmethodID LDKMonitorEvent_UpdateFailed_meth = NULL;
3930 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKMonitorEvent_init (JNIEnv *env, jclass clz) {
3931         LDKMonitorEvent_HTLCEvent_class =
3932                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMonitorEvent$HTLCEvent"));
3933         CHECK(LDKMonitorEvent_HTLCEvent_class != NULL);
3934         LDKMonitorEvent_HTLCEvent_meth = (*env)->GetMethodID(env, LDKMonitorEvent_HTLCEvent_class, "<init>", "(J)V");
3935         CHECK(LDKMonitorEvent_HTLCEvent_meth != NULL);
3936         LDKMonitorEvent_CommitmentTxConfirmed_class =
3937                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMonitorEvent$CommitmentTxConfirmed"));
3938         CHECK(LDKMonitorEvent_CommitmentTxConfirmed_class != NULL);
3939         LDKMonitorEvent_CommitmentTxConfirmed_meth = (*env)->GetMethodID(env, LDKMonitorEvent_CommitmentTxConfirmed_class, "<init>", "(J)V");
3940         CHECK(LDKMonitorEvent_CommitmentTxConfirmed_meth != NULL);
3941         LDKMonitorEvent_Completed_class =
3942                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMonitorEvent$Completed"));
3943         CHECK(LDKMonitorEvent_Completed_class != NULL);
3944         LDKMonitorEvent_Completed_meth = (*env)->GetMethodID(env, LDKMonitorEvent_Completed_class, "<init>", "(JJ)V");
3945         CHECK(LDKMonitorEvent_Completed_meth != NULL);
3946         LDKMonitorEvent_UpdateFailed_class =
3947                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKMonitorEvent$UpdateFailed"));
3948         CHECK(LDKMonitorEvent_UpdateFailed_class != NULL);
3949         LDKMonitorEvent_UpdateFailed_meth = (*env)->GetMethodID(env, LDKMonitorEvent_UpdateFailed_class, "<init>", "(J)V");
3950         CHECK(LDKMonitorEvent_UpdateFailed_meth != NULL);
3951 }
3952 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKMonitorEvent_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
3953         LDKMonitorEvent *obj = (LDKMonitorEvent*)untag_ptr(ptr);
3954         switch(obj->tag) {
3955                 case LDKMonitorEvent_HTLCEvent: {
3956                         LDKHTLCUpdate htlc_event_var = obj->htlc_event;
3957                         int64_t htlc_event_ref = 0;
3958                         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_event_var);
3959                         htlc_event_ref = tag_ptr(htlc_event_var.inner, false);
3960                         return (*env)->NewObject(env, LDKMonitorEvent_HTLCEvent_class, LDKMonitorEvent_HTLCEvent_meth, htlc_event_ref);
3961                 }
3962                 case LDKMonitorEvent_CommitmentTxConfirmed: {
3963                         LDKOutPoint commitment_tx_confirmed_var = obj->commitment_tx_confirmed;
3964                         int64_t commitment_tx_confirmed_ref = 0;
3965                         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_confirmed_var);
3966                         commitment_tx_confirmed_ref = tag_ptr(commitment_tx_confirmed_var.inner, false);
3967                         return (*env)->NewObject(env, LDKMonitorEvent_CommitmentTxConfirmed_class, LDKMonitorEvent_CommitmentTxConfirmed_meth, commitment_tx_confirmed_ref);
3968                 }
3969                 case LDKMonitorEvent_Completed: {
3970                         LDKOutPoint funding_txo_var = obj->completed.funding_txo;
3971                         int64_t funding_txo_ref = 0;
3972                         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_var);
3973                         funding_txo_ref = tag_ptr(funding_txo_var.inner, false);
3974                         int64_t monitor_update_id_conv = obj->completed.monitor_update_id;
3975                         return (*env)->NewObject(env, LDKMonitorEvent_Completed_class, LDKMonitorEvent_Completed_meth, funding_txo_ref, monitor_update_id_conv);
3976                 }
3977                 case LDKMonitorEvent_UpdateFailed: {
3978                         LDKOutPoint update_failed_var = obj->update_failed;
3979                         int64_t update_failed_ref = 0;
3980                         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_failed_var);
3981                         update_failed_ref = tag_ptr(update_failed_var.inner, false);
3982                         return (*env)->NewObject(env, LDKMonitorEvent_UpdateFailed_class, LDKMonitorEvent_UpdateFailed_meth, update_failed_ref);
3983                 }
3984                 default: abort();
3985         }
3986 }
3987 static inline LDKCVec_MonitorEventZ CVec_MonitorEventZ_clone(const LDKCVec_MonitorEventZ *orig) {
3988         LDKCVec_MonitorEventZ ret = { .data = MALLOC(sizeof(LDKMonitorEvent) * orig->datalen, "LDKCVec_MonitorEventZ clone bytes"), .datalen = orig->datalen };
3989         for (size_t i = 0; i < ret.datalen; i++) {
3990                 ret.data[i] = MonitorEvent_clone(&orig->data[i]);
3991         }
3992         return ret;
3993 }
3994 static inline struct LDKOutPoint C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_get_a(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ *NONNULL_PTR owner){
3995         LDKOutPoint ret = owner->a;
3996         ret.is_owned = false;
3997         return ret;
3998 }
3999 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1OutPointCVec_1MonitorEventZPublicKeyZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
4000         LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ* owner_conv = (LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ*)untag_ptr(owner);
4001         LDKOutPoint ret_var = C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_get_a(owner_conv);
4002         int64_t ret_ref = 0;
4003         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4004         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
4005         return ret_ref;
4006 }
4007
4008 static inline struct LDKCVec_MonitorEventZ C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_get_b(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ *NONNULL_PTR owner){
4009         return CVec_MonitorEventZ_clone(&owner->b);
4010 }
4011 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_C3Tuple_1OutPointCVec_1MonitorEventZPublicKeyZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
4012         LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ* owner_conv = (LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ*)untag_ptr(owner);
4013         LDKCVec_MonitorEventZ ret_var = C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_get_b(owner_conv);
4014         int64_tArray ret_arr = NULL;
4015         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
4016         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
4017         for (size_t o = 0; o < ret_var.datalen; o++) {
4018                 LDKMonitorEvent *ret_conv_14_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
4019                 *ret_conv_14_copy = ret_var.data[o];
4020                 int64_t ret_conv_14_ref = tag_ptr(ret_conv_14_copy, true);
4021                 ret_arr_ptr[o] = ret_conv_14_ref;
4022         }
4023         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
4024         FREE(ret_var.data);
4025         return ret_arr;
4026 }
4027
4028 static inline struct LDKPublicKey C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_get_c(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ *NONNULL_PTR owner){
4029         return owner->c;
4030 }
4031 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C3Tuple_1OutPointCVec_1MonitorEventZPublicKeyZ_1get_1c(JNIEnv *env, jclass clz, int64_t owner) {
4032         LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ* owner_conv = (LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ*)untag_ptr(owner);
4033         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
4034         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_get_c(owner_conv).compressed_form);
4035         return ret_arr;
4036 }
4037
4038 static inline LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ CVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ_clone(const LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ *orig) {
4039         LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ ret = { .data = MALLOC(sizeof(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ) * orig->datalen, "LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ clone bytes"), .datalen = orig->datalen };
4040         for (size_t i = 0; i < ret.datalen; i++) {
4041                 ret.data[i] = C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_clone(&orig->data[i]);
4042         }
4043         return ret;
4044 }
4045 static inline struct LDKFixedPenaltyScorer CResult_FixedPenaltyScorerDecodeErrorZ_get_ok(LDKCResult_FixedPenaltyScorerDecodeErrorZ *NONNULL_PTR owner){
4046         LDKFixedPenaltyScorer ret = *owner->contents.result;
4047         ret.is_owned = false;
4048         return ret;
4049 }
4050 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FixedPenaltyScorerDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4051         LDKCResult_FixedPenaltyScorerDecodeErrorZ* owner_conv = (LDKCResult_FixedPenaltyScorerDecodeErrorZ*)untag_ptr(owner);
4052         LDKFixedPenaltyScorer ret_var = CResult_FixedPenaltyScorerDecodeErrorZ_get_ok(owner_conv);
4053         int64_t ret_ref = 0;
4054         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4055         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
4056         return ret_ref;
4057 }
4058
4059 static inline struct LDKDecodeError CResult_FixedPenaltyScorerDecodeErrorZ_get_err(LDKCResult_FixedPenaltyScorerDecodeErrorZ *NONNULL_PTR owner){
4060 CHECK(!owner->result_ok);
4061         return DecodeError_clone(&*owner->contents.err);
4062 }
4063 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FixedPenaltyScorerDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4064         LDKCResult_FixedPenaltyScorerDecodeErrorZ* owner_conv = (LDKCResult_FixedPenaltyScorerDecodeErrorZ*)untag_ptr(owner);
4065         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
4066         *ret_copy = CResult_FixedPenaltyScorerDecodeErrorZ_get_err(owner_conv);
4067         int64_t ret_ref = tag_ptr(ret_copy, true);
4068         return ret_ref;
4069 }
4070
4071 static inline uint64_t C2Tuple_u64u64Z_get_a(LDKC2Tuple_u64u64Z *NONNULL_PTR owner){
4072         return owner->a;
4073 }
4074 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u64u64Z_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
4075         LDKC2Tuple_u64u64Z* owner_conv = (LDKC2Tuple_u64u64Z*)untag_ptr(owner);
4076         int64_t ret_conv = C2Tuple_u64u64Z_get_a(owner_conv);
4077         return ret_conv;
4078 }
4079
4080 static inline uint64_t C2Tuple_u64u64Z_get_b(LDKC2Tuple_u64u64Z *NONNULL_PTR owner){
4081         return owner->b;
4082 }
4083 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u64u64Z_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
4084         LDKC2Tuple_u64u64Z* owner_conv = (LDKC2Tuple_u64u64Z*)untag_ptr(owner);
4085         int64_t ret_conv = C2Tuple_u64u64Z_get_b(owner_conv);
4086         return ret_conv;
4087 }
4088
4089 static jclass LDKCOption_C2Tuple_u64u64ZZ_Some_class = NULL;
4090 static jmethodID LDKCOption_C2Tuple_u64u64ZZ_Some_meth = NULL;
4091 static jclass LDKCOption_C2Tuple_u64u64ZZ_None_class = NULL;
4092 static jmethodID LDKCOption_C2Tuple_u64u64ZZ_None_meth = NULL;
4093 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1C2Tuple_1u64u64ZZ_init (JNIEnv *env, jclass clz) {
4094         LDKCOption_C2Tuple_u64u64ZZ_Some_class =
4095                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_C2Tuple_u64u64ZZ$Some"));
4096         CHECK(LDKCOption_C2Tuple_u64u64ZZ_Some_class != NULL);
4097         LDKCOption_C2Tuple_u64u64ZZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_C2Tuple_u64u64ZZ_Some_class, "<init>", "(J)V");
4098         CHECK(LDKCOption_C2Tuple_u64u64ZZ_Some_meth != NULL);
4099         LDKCOption_C2Tuple_u64u64ZZ_None_class =
4100                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_C2Tuple_u64u64ZZ$None"));
4101         CHECK(LDKCOption_C2Tuple_u64u64ZZ_None_class != NULL);
4102         LDKCOption_C2Tuple_u64u64ZZ_None_meth = (*env)->GetMethodID(env, LDKCOption_C2Tuple_u64u64ZZ_None_class, "<init>", "()V");
4103         CHECK(LDKCOption_C2Tuple_u64u64ZZ_None_meth != NULL);
4104 }
4105 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1C2Tuple_1u64u64ZZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
4106         LDKCOption_C2Tuple_u64u64ZZ *obj = (LDKCOption_C2Tuple_u64u64ZZ*)untag_ptr(ptr);
4107         switch(obj->tag) {
4108                 case LDKCOption_C2Tuple_u64u64ZZ_Some: {
4109                         LDKC2Tuple_u64u64Z* some_conv = MALLOC(sizeof(LDKC2Tuple_u64u64Z), "LDKC2Tuple_u64u64Z");
4110                         *some_conv = obj->some;
4111                         *some_conv = C2Tuple_u64u64Z_clone(some_conv);
4112                         return (*env)->NewObject(env, LDKCOption_C2Tuple_u64u64ZZ_Some_class, LDKCOption_C2Tuple_u64u64ZZ_Some_meth, tag_ptr(some_conv, true));
4113                 }
4114                 case LDKCOption_C2Tuple_u64u64ZZ_None: {
4115                         return (*env)->NewObject(env, LDKCOption_C2Tuple_u64u64ZZ_None_class, LDKCOption_C2Tuple_u64u64ZZ_None_meth);
4116                 }
4117                 default: abort();
4118         }
4119 }
4120 static inline LDKCVec_NodeIdZ CVec_NodeIdZ_clone(const LDKCVec_NodeIdZ *orig) {
4121         LDKCVec_NodeIdZ ret = { .data = MALLOC(sizeof(LDKNodeId) * orig->datalen, "LDKCVec_NodeIdZ clone bytes"), .datalen = orig->datalen };
4122         for (size_t i = 0; i < ret.datalen; i++) {
4123                 ret.data[i] = NodeId_clone(&orig->data[i]);
4124         }
4125         return ret;
4126 }
4127 typedef struct LDKLogger_JCalls {
4128         atomic_size_t refcnt;
4129         JavaVM *vm;
4130         jweak o;
4131         jmethodID log_meth;
4132 } LDKLogger_JCalls;
4133 static void LDKLogger_JCalls_free(void* this_arg) {
4134         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) this_arg;
4135         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
4136                 JNIEnv *env;
4137                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4138                 if (get_jenv_res == JNI_EDETACHED) {
4139                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4140                 } else {
4141                         DO_ASSERT(get_jenv_res == JNI_OK);
4142                 }
4143                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
4144                 if (get_jenv_res == JNI_EDETACHED) {
4145                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4146                 }
4147                 FREE(j_calls);
4148         }
4149 }
4150 void log_LDKLogger_jcall(const void* this_arg, const LDKRecord * record) {
4151         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) this_arg;
4152         JNIEnv *env;
4153         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4154         if (get_jenv_res == JNI_EDETACHED) {
4155                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4156         } else {
4157                 DO_ASSERT(get_jenv_res == JNI_OK);
4158         }
4159         LDKRecord record_var = *record;
4160         int64_t record_ref = 0;
4161         record_var = Record_clone(&record_var);
4162         CHECK_INNER_FIELD_ACCESS_OR_NULL(record_var);
4163         record_ref = tag_ptr(record_var.inner, record_var.is_owned);
4164         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4165         CHECK(obj != NULL);
4166         (*env)->CallVoidMethod(env, obj, j_calls->log_meth, record_ref);
4167         if (UNLIKELY((*env)->ExceptionCheck(env))) {
4168                 (*env)->ExceptionDescribe(env);
4169                 (*env)->FatalError(env, "A call to log in LDKLogger from rust threw an exception.");
4170         }
4171         if (get_jenv_res == JNI_EDETACHED) {
4172                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4173         }
4174 }
4175 static void LDKLogger_JCalls_cloned(LDKLogger* new_obj) {
4176         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) new_obj->this_arg;
4177         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
4178 }
4179 static inline LDKLogger LDKLogger_init (JNIEnv *env, jclass clz, jobject o) {
4180         jclass c = (*env)->GetObjectClass(env, o);
4181         CHECK(c != NULL);
4182         LDKLogger_JCalls *calls = MALLOC(sizeof(LDKLogger_JCalls), "LDKLogger_JCalls");
4183         atomic_init(&calls->refcnt, 1);
4184         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
4185         calls->o = (*env)->NewWeakGlobalRef(env, o);
4186         calls->log_meth = (*env)->GetMethodID(env, c, "log", "(J)V");
4187         CHECK(calls->log_meth != NULL);
4188
4189         LDKLogger ret = {
4190                 .this_arg = (void*) calls,
4191                 .log = log_LDKLogger_jcall,
4192                 .free = LDKLogger_JCalls_free,
4193         };
4194         return ret;
4195 }
4196 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKLogger_1new(JNIEnv *env, jclass clz, jobject o) {
4197         LDKLogger *res_ptr = MALLOC(sizeof(LDKLogger), "LDKLogger");
4198         *res_ptr = LDKLogger_init(env, clz, o);
4199         return tag_ptr(res_ptr, true);
4200 }
4201 static inline struct LDKProbabilisticScorer CResult_ProbabilisticScorerDecodeErrorZ_get_ok(LDKCResult_ProbabilisticScorerDecodeErrorZ *NONNULL_PTR owner){
4202         LDKProbabilisticScorer ret = *owner->contents.result;
4203         ret.is_owned = false;
4204         return ret;
4205 }
4206 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ProbabilisticScorerDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4207         LDKCResult_ProbabilisticScorerDecodeErrorZ* owner_conv = (LDKCResult_ProbabilisticScorerDecodeErrorZ*)untag_ptr(owner);
4208         LDKProbabilisticScorer ret_var = CResult_ProbabilisticScorerDecodeErrorZ_get_ok(owner_conv);
4209         int64_t ret_ref = 0;
4210         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4211         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
4212         return ret_ref;
4213 }
4214
4215 static inline struct LDKDecodeError CResult_ProbabilisticScorerDecodeErrorZ_get_err(LDKCResult_ProbabilisticScorerDecodeErrorZ *NONNULL_PTR owner){
4216 CHECK(!owner->result_ok);
4217         return DecodeError_clone(&*owner->contents.err);
4218 }
4219 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ProbabilisticScorerDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4220         LDKCResult_ProbabilisticScorerDecodeErrorZ* owner_conv = (LDKCResult_ProbabilisticScorerDecodeErrorZ*)untag_ptr(owner);
4221         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
4222         *ret_copy = CResult_ProbabilisticScorerDecodeErrorZ_get_err(owner_conv);
4223         int64_t ret_ref = tag_ptr(ret_copy, true);
4224         return ret_ref;
4225 }
4226
4227 static inline struct LDKInitFeatures CResult_InitFeaturesDecodeErrorZ_get_ok(LDKCResult_InitFeaturesDecodeErrorZ *NONNULL_PTR owner){
4228         LDKInitFeatures ret = *owner->contents.result;
4229         ret.is_owned = false;
4230         return ret;
4231 }
4232 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4233         LDKCResult_InitFeaturesDecodeErrorZ* owner_conv = (LDKCResult_InitFeaturesDecodeErrorZ*)untag_ptr(owner);
4234         LDKInitFeatures ret_var = CResult_InitFeaturesDecodeErrorZ_get_ok(owner_conv);
4235         int64_t ret_ref = 0;
4236         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4237         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
4238         return ret_ref;
4239 }
4240
4241 static inline struct LDKDecodeError CResult_InitFeaturesDecodeErrorZ_get_err(LDKCResult_InitFeaturesDecodeErrorZ *NONNULL_PTR owner){
4242 CHECK(!owner->result_ok);
4243         return DecodeError_clone(&*owner->contents.err);
4244 }
4245 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4246         LDKCResult_InitFeaturesDecodeErrorZ* owner_conv = (LDKCResult_InitFeaturesDecodeErrorZ*)untag_ptr(owner);
4247         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
4248         *ret_copy = CResult_InitFeaturesDecodeErrorZ_get_err(owner_conv);
4249         int64_t ret_ref = tag_ptr(ret_copy, true);
4250         return ret_ref;
4251 }
4252
4253 static inline struct LDKChannelFeatures CResult_ChannelFeaturesDecodeErrorZ_get_ok(LDKCResult_ChannelFeaturesDecodeErrorZ *NONNULL_PTR owner){
4254         LDKChannelFeatures ret = *owner->contents.result;
4255         ret.is_owned = false;
4256         return ret;
4257 }
4258 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4259         LDKCResult_ChannelFeaturesDecodeErrorZ* owner_conv = (LDKCResult_ChannelFeaturesDecodeErrorZ*)untag_ptr(owner);
4260         LDKChannelFeatures ret_var = CResult_ChannelFeaturesDecodeErrorZ_get_ok(owner_conv);
4261         int64_t ret_ref = 0;
4262         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4263         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
4264         return ret_ref;
4265 }
4266
4267 static inline struct LDKDecodeError CResult_ChannelFeaturesDecodeErrorZ_get_err(LDKCResult_ChannelFeaturesDecodeErrorZ *NONNULL_PTR owner){
4268 CHECK(!owner->result_ok);
4269         return DecodeError_clone(&*owner->contents.err);
4270 }
4271 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4272         LDKCResult_ChannelFeaturesDecodeErrorZ* owner_conv = (LDKCResult_ChannelFeaturesDecodeErrorZ*)untag_ptr(owner);
4273         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
4274         *ret_copy = CResult_ChannelFeaturesDecodeErrorZ_get_err(owner_conv);
4275         int64_t ret_ref = tag_ptr(ret_copy, true);
4276         return ret_ref;
4277 }
4278
4279 static inline struct LDKNodeFeatures CResult_NodeFeaturesDecodeErrorZ_get_ok(LDKCResult_NodeFeaturesDecodeErrorZ *NONNULL_PTR owner){
4280         LDKNodeFeatures ret = *owner->contents.result;
4281         ret.is_owned = false;
4282         return ret;
4283 }
4284 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4285         LDKCResult_NodeFeaturesDecodeErrorZ* owner_conv = (LDKCResult_NodeFeaturesDecodeErrorZ*)untag_ptr(owner);
4286         LDKNodeFeatures ret_var = CResult_NodeFeaturesDecodeErrorZ_get_ok(owner_conv);
4287         int64_t ret_ref = 0;
4288         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4289         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
4290         return ret_ref;
4291 }
4292
4293 static inline struct LDKDecodeError CResult_NodeFeaturesDecodeErrorZ_get_err(LDKCResult_NodeFeaturesDecodeErrorZ *NONNULL_PTR owner){
4294 CHECK(!owner->result_ok);
4295         return DecodeError_clone(&*owner->contents.err);
4296 }
4297 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4298         LDKCResult_NodeFeaturesDecodeErrorZ* owner_conv = (LDKCResult_NodeFeaturesDecodeErrorZ*)untag_ptr(owner);
4299         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
4300         *ret_copy = CResult_NodeFeaturesDecodeErrorZ_get_err(owner_conv);
4301         int64_t ret_ref = tag_ptr(ret_copy, true);
4302         return ret_ref;
4303 }
4304
4305 static inline struct LDKInvoiceFeatures CResult_InvoiceFeaturesDecodeErrorZ_get_ok(LDKCResult_InvoiceFeaturesDecodeErrorZ *NONNULL_PTR owner){
4306         LDKInvoiceFeatures ret = *owner->contents.result;
4307         ret.is_owned = false;
4308         return ret;
4309 }
4310 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4311         LDKCResult_InvoiceFeaturesDecodeErrorZ* owner_conv = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)untag_ptr(owner);
4312         LDKInvoiceFeatures ret_var = CResult_InvoiceFeaturesDecodeErrorZ_get_ok(owner_conv);
4313         int64_t ret_ref = 0;
4314         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4315         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
4316         return ret_ref;
4317 }
4318
4319 static inline struct LDKDecodeError CResult_InvoiceFeaturesDecodeErrorZ_get_err(LDKCResult_InvoiceFeaturesDecodeErrorZ *NONNULL_PTR owner){
4320 CHECK(!owner->result_ok);
4321         return DecodeError_clone(&*owner->contents.err);
4322 }
4323 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4324         LDKCResult_InvoiceFeaturesDecodeErrorZ* owner_conv = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)untag_ptr(owner);
4325         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
4326         *ret_copy = CResult_InvoiceFeaturesDecodeErrorZ_get_err(owner_conv);
4327         int64_t ret_ref = tag_ptr(ret_copy, true);
4328         return ret_ref;
4329 }
4330
4331 static inline struct LDKChannelTypeFeatures CResult_ChannelTypeFeaturesDecodeErrorZ_get_ok(LDKCResult_ChannelTypeFeaturesDecodeErrorZ *NONNULL_PTR owner){
4332         LDKChannelTypeFeatures ret = *owner->contents.result;
4333         ret.is_owned = false;
4334         return ret;
4335 }
4336 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTypeFeaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4337         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* owner_conv = (LDKCResult_ChannelTypeFeaturesDecodeErrorZ*)untag_ptr(owner);
4338         LDKChannelTypeFeatures ret_var = CResult_ChannelTypeFeaturesDecodeErrorZ_get_ok(owner_conv);
4339         int64_t ret_ref = 0;
4340         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4341         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
4342         return ret_ref;
4343 }
4344
4345 static inline struct LDKDecodeError CResult_ChannelTypeFeaturesDecodeErrorZ_get_err(LDKCResult_ChannelTypeFeaturesDecodeErrorZ *NONNULL_PTR owner){
4346 CHECK(!owner->result_ok);
4347         return DecodeError_clone(&*owner->contents.err);
4348 }
4349 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTypeFeaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4350         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* owner_conv = (LDKCResult_ChannelTypeFeaturesDecodeErrorZ*)untag_ptr(owner);
4351         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
4352         *ret_copy = CResult_ChannelTypeFeaturesDecodeErrorZ_get_err(owner_conv);
4353         int64_t ret_ref = tag_ptr(ret_copy, true);
4354         return ret_ref;
4355 }
4356
4357 static inline struct LDKOfferFeatures CResult_OfferFeaturesDecodeErrorZ_get_ok(LDKCResult_OfferFeaturesDecodeErrorZ *NONNULL_PTR owner){
4358         LDKOfferFeatures ret = *owner->contents.result;
4359         ret.is_owned = false;
4360         return ret;
4361 }
4362 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OfferFeaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4363         LDKCResult_OfferFeaturesDecodeErrorZ* owner_conv = (LDKCResult_OfferFeaturesDecodeErrorZ*)untag_ptr(owner);
4364         LDKOfferFeatures ret_var = CResult_OfferFeaturesDecodeErrorZ_get_ok(owner_conv);
4365         int64_t ret_ref = 0;
4366         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4367         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
4368         return ret_ref;
4369 }
4370
4371 static inline struct LDKDecodeError CResult_OfferFeaturesDecodeErrorZ_get_err(LDKCResult_OfferFeaturesDecodeErrorZ *NONNULL_PTR owner){
4372 CHECK(!owner->result_ok);
4373         return DecodeError_clone(&*owner->contents.err);
4374 }
4375 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OfferFeaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4376         LDKCResult_OfferFeaturesDecodeErrorZ* owner_conv = (LDKCResult_OfferFeaturesDecodeErrorZ*)untag_ptr(owner);
4377         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
4378         *ret_copy = CResult_OfferFeaturesDecodeErrorZ_get_err(owner_conv);
4379         int64_t ret_ref = tag_ptr(ret_copy, true);
4380         return ret_ref;
4381 }
4382
4383 static inline struct LDKInvoiceRequestFeatures CResult_InvoiceRequestFeaturesDecodeErrorZ_get_ok(LDKCResult_InvoiceRequestFeaturesDecodeErrorZ *NONNULL_PTR owner){
4384         LDKInvoiceRequestFeatures ret = *owner->contents.result;
4385         ret.is_owned = false;
4386         return ret;
4387 }
4388 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceRequestFeaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4389         LDKCResult_InvoiceRequestFeaturesDecodeErrorZ* owner_conv = (LDKCResult_InvoiceRequestFeaturesDecodeErrorZ*)untag_ptr(owner);
4390         LDKInvoiceRequestFeatures ret_var = CResult_InvoiceRequestFeaturesDecodeErrorZ_get_ok(owner_conv);
4391         int64_t ret_ref = 0;
4392         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4393         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
4394         return ret_ref;
4395 }
4396
4397 static inline struct LDKDecodeError CResult_InvoiceRequestFeaturesDecodeErrorZ_get_err(LDKCResult_InvoiceRequestFeaturesDecodeErrorZ *NONNULL_PTR owner){
4398 CHECK(!owner->result_ok);
4399         return DecodeError_clone(&*owner->contents.err);
4400 }
4401 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceRequestFeaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4402         LDKCResult_InvoiceRequestFeaturesDecodeErrorZ* owner_conv = (LDKCResult_InvoiceRequestFeaturesDecodeErrorZ*)untag_ptr(owner);
4403         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
4404         *ret_copy = CResult_InvoiceRequestFeaturesDecodeErrorZ_get_err(owner_conv);
4405         int64_t ret_ref = tag_ptr(ret_copy, true);
4406         return ret_ref;
4407 }
4408
4409 static inline struct LDKNodeId CResult_NodeIdDecodeErrorZ_get_ok(LDKCResult_NodeIdDecodeErrorZ *NONNULL_PTR owner){
4410         LDKNodeId ret = *owner->contents.result;
4411         ret.is_owned = false;
4412         return ret;
4413 }
4414 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeIdDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4415         LDKCResult_NodeIdDecodeErrorZ* owner_conv = (LDKCResult_NodeIdDecodeErrorZ*)untag_ptr(owner);
4416         LDKNodeId ret_var = CResult_NodeIdDecodeErrorZ_get_ok(owner_conv);
4417         int64_t ret_ref = 0;
4418         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4419         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
4420         return ret_ref;
4421 }
4422
4423 static inline struct LDKDecodeError CResult_NodeIdDecodeErrorZ_get_err(LDKCResult_NodeIdDecodeErrorZ *NONNULL_PTR owner){
4424 CHECK(!owner->result_ok);
4425         return DecodeError_clone(&*owner->contents.err);
4426 }
4427 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeIdDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4428         LDKCResult_NodeIdDecodeErrorZ* owner_conv = (LDKCResult_NodeIdDecodeErrorZ*)untag_ptr(owner);
4429         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
4430         *ret_copy = CResult_NodeIdDecodeErrorZ_get_err(owner_conv);
4431         int64_t ret_ref = tag_ptr(ret_copy, true);
4432         return ret_ref;
4433 }
4434
4435 static inline struct LDKCOption_NetworkUpdateZ CResult_COption_NetworkUpdateZDecodeErrorZ_get_ok(LDKCResult_COption_NetworkUpdateZDecodeErrorZ *NONNULL_PTR owner){
4436 CHECK(owner->result_ok);
4437         return COption_NetworkUpdateZ_clone(&*owner->contents.result);
4438 }
4439 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1NetworkUpdateZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4440         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* owner_conv = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)untag_ptr(owner);
4441         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
4442         *ret_copy = CResult_COption_NetworkUpdateZDecodeErrorZ_get_ok(owner_conv);
4443         int64_t ret_ref = tag_ptr(ret_copy, true);
4444         return ret_ref;
4445 }
4446
4447 static inline struct LDKDecodeError CResult_COption_NetworkUpdateZDecodeErrorZ_get_err(LDKCResult_COption_NetworkUpdateZDecodeErrorZ *NONNULL_PTR owner){
4448 CHECK(!owner->result_ok);
4449         return DecodeError_clone(&*owner->contents.err);
4450 }
4451 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1NetworkUpdateZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4452         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* owner_conv = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)untag_ptr(owner);
4453         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
4454         *ret_copy = CResult_COption_NetworkUpdateZDecodeErrorZ_get_err(owner_conv);
4455         int64_t ret_ref = tag_ptr(ret_copy, true);
4456         return ret_ref;
4457 }
4458
4459 typedef struct LDKAccess_JCalls {
4460         atomic_size_t refcnt;
4461         JavaVM *vm;
4462         jweak o;
4463         jmethodID get_utxo_meth;
4464 } LDKAccess_JCalls;
4465 static void LDKAccess_JCalls_free(void* this_arg) {
4466         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) this_arg;
4467         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
4468                 JNIEnv *env;
4469                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4470                 if (get_jenv_res == JNI_EDETACHED) {
4471                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4472                 } else {
4473                         DO_ASSERT(get_jenv_res == JNI_OK);
4474                 }
4475                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
4476                 if (get_jenv_res == JNI_EDETACHED) {
4477                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4478                 }
4479                 FREE(j_calls);
4480         }
4481 }
4482 LDKCResult_TxOutAccessErrorZ get_utxo_LDKAccess_jcall(const void* this_arg, const uint8_t (* genesis_hash)[32], uint64_t short_channel_id) {
4483         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) this_arg;
4484         JNIEnv *env;
4485         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4486         if (get_jenv_res == JNI_EDETACHED) {
4487                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4488         } else {
4489                 DO_ASSERT(get_jenv_res == JNI_OK);
4490         }
4491         int8_tArray genesis_hash_arr = (*env)->NewByteArray(env, 32);
4492         (*env)->SetByteArrayRegion(env, genesis_hash_arr, 0, 32, *genesis_hash);
4493         int64_t short_channel_id_conv = short_channel_id;
4494         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4495         CHECK(obj != NULL);
4496         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->get_utxo_meth, genesis_hash_arr, short_channel_id_conv);
4497         if (UNLIKELY((*env)->ExceptionCheck(env))) {
4498                 (*env)->ExceptionDescribe(env);
4499                 (*env)->FatalError(env, "A call to get_utxo in LDKAccess from rust threw an exception.");
4500         }
4501         void* ret_ptr = untag_ptr(ret);
4502         CHECK_ACCESS(ret_ptr);
4503         LDKCResult_TxOutAccessErrorZ ret_conv = *(LDKCResult_TxOutAccessErrorZ*)(ret_ptr);
4504         FREE(untag_ptr(ret));
4505         if (get_jenv_res == JNI_EDETACHED) {
4506                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4507         }
4508         return ret_conv;
4509 }
4510 static void LDKAccess_JCalls_cloned(LDKAccess* new_obj) {
4511         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) new_obj->this_arg;
4512         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
4513 }
4514 static inline LDKAccess LDKAccess_init (JNIEnv *env, jclass clz, jobject o) {
4515         jclass c = (*env)->GetObjectClass(env, o);
4516         CHECK(c != NULL);
4517         LDKAccess_JCalls *calls = MALLOC(sizeof(LDKAccess_JCalls), "LDKAccess_JCalls");
4518         atomic_init(&calls->refcnt, 1);
4519         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
4520         calls->o = (*env)->NewWeakGlobalRef(env, o);
4521         calls->get_utxo_meth = (*env)->GetMethodID(env, c, "get_utxo", "([BJ)J");
4522         CHECK(calls->get_utxo_meth != NULL);
4523
4524         LDKAccess ret = {
4525                 .this_arg = (void*) calls,
4526                 .get_utxo = get_utxo_LDKAccess_jcall,
4527                 .free = LDKAccess_JCalls_free,
4528         };
4529         return ret;
4530 }
4531 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKAccess_1new(JNIEnv *env, jclass clz, jobject o) {
4532         LDKAccess *res_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess");
4533         *res_ptr = LDKAccess_init(env, clz, o);
4534         return tag_ptr(res_ptr, true);
4535 }
4536 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) {
4537         void* this_arg_ptr = untag_ptr(this_arg);
4538         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
4539         LDKAccess* this_arg_conv = (LDKAccess*)this_arg_ptr;
4540         unsigned char genesis_hash_arr[32];
4541         CHECK((*env)->GetArrayLength(env, genesis_hash) == 32);
4542         (*env)->GetByteArrayRegion(env, genesis_hash, 0, 32, genesis_hash_arr);
4543         unsigned char (*genesis_hash_ref)[32] = &genesis_hash_arr;
4544         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
4545         *ret_conv = (this_arg_conv->get_utxo)(this_arg_conv->this_arg, genesis_hash_ref, short_channel_id);
4546         return tag_ptr(ret_conv, true);
4547 }
4548
4549 static jclass LDKCOption_AccessZ_Some_class = NULL;
4550 static jmethodID LDKCOption_AccessZ_Some_meth = NULL;
4551 static jclass LDKCOption_AccessZ_None_class = NULL;
4552 static jmethodID LDKCOption_AccessZ_None_meth = NULL;
4553 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1AccessZ_init (JNIEnv *env, jclass clz) {
4554         LDKCOption_AccessZ_Some_class =
4555                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_AccessZ$Some"));
4556         CHECK(LDKCOption_AccessZ_Some_class != NULL);
4557         LDKCOption_AccessZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_AccessZ_Some_class, "<init>", "(J)V");
4558         CHECK(LDKCOption_AccessZ_Some_meth != NULL);
4559         LDKCOption_AccessZ_None_class =
4560                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_AccessZ$None"));
4561         CHECK(LDKCOption_AccessZ_None_class != NULL);
4562         LDKCOption_AccessZ_None_meth = (*env)->GetMethodID(env, LDKCOption_AccessZ_None_class, "<init>", "()V");
4563         CHECK(LDKCOption_AccessZ_None_meth != NULL);
4564 }
4565 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1AccessZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
4566         LDKCOption_AccessZ *obj = (LDKCOption_AccessZ*)untag_ptr(ptr);
4567         switch(obj->tag) {
4568                 case LDKCOption_AccessZ_Some: {
4569                         LDKAccess* some_ret = MALLOC(sizeof(LDKAccess), "LDKAccess");
4570                         *some_ret = obj->some;
4571                         // WARNING: We likely need to clone here, but no clone is available, so we just do it for Java instances
4572                         if ((*some_ret).free == LDKAccess_JCalls_free) {
4573                                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
4574                                 LDKAccess_JCalls_cloned(&(*some_ret));
4575                         }
4576                         return (*env)->NewObject(env, LDKCOption_AccessZ_Some_class, LDKCOption_AccessZ_Some_meth, tag_ptr(some_ret, true));
4577                 }
4578                 case LDKCOption_AccessZ_None: {
4579                         return (*env)->NewObject(env, LDKCOption_AccessZ_None_class, LDKCOption_AccessZ_None_meth);
4580                 }
4581                 default: abort();
4582         }
4583 }
4584 static inline bool CResult_boolLightningErrorZ_get_ok(LDKCResult_boolLightningErrorZ *NONNULL_PTR owner){
4585 CHECK(owner->result_ok);
4586         return *owner->contents.result;
4587 }
4588 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4589         LDKCResult_boolLightningErrorZ* owner_conv = (LDKCResult_boolLightningErrorZ*)untag_ptr(owner);
4590         jboolean ret_conv = CResult_boolLightningErrorZ_get_ok(owner_conv);
4591         return ret_conv;
4592 }
4593
4594 static inline struct LDKLightningError CResult_boolLightningErrorZ_get_err(LDKCResult_boolLightningErrorZ *NONNULL_PTR owner){
4595         LDKLightningError ret = *owner->contents.err;
4596         ret.is_owned = false;
4597         return ret;
4598 }
4599 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4600         LDKCResult_boolLightningErrorZ* owner_conv = (LDKCResult_boolLightningErrorZ*)untag_ptr(owner);
4601         LDKLightningError ret_var = CResult_boolLightningErrorZ_get_err(owner_conv);
4602         int64_t ret_ref = 0;
4603         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4604         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
4605         return ret_ref;
4606 }
4607
4608 static inline struct LDKChannelAnnouncement C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_a(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *NONNULL_PTR owner){
4609         LDKChannelAnnouncement ret = owner->a;
4610         ret.is_owned = false;
4611         return ret;
4612 }
4613 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
4614         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* owner_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)untag_ptr(owner);
4615         LDKChannelAnnouncement ret_var = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_a(owner_conv);
4616         int64_t ret_ref = 0;
4617         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4618         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
4619         return ret_ref;
4620 }
4621
4622 static inline struct LDKChannelUpdate C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_b(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *NONNULL_PTR owner){
4623         LDKChannelUpdate ret = owner->b;
4624         ret.is_owned = false;
4625         return ret;
4626 }
4627 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
4628         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* owner_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)untag_ptr(owner);
4629         LDKChannelUpdate ret_var = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_b(owner_conv);
4630         int64_t ret_ref = 0;
4631         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4632         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
4633         return ret_ref;
4634 }
4635
4636 static inline struct LDKChannelUpdate C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_c(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *NONNULL_PTR owner){
4637         LDKChannelUpdate ret = owner->c;
4638         ret.is_owned = false;
4639         return ret;
4640 }
4641 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1get_1c(JNIEnv *env, jclass clz, int64_t owner) {
4642         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* owner_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)untag_ptr(owner);
4643         LDKChannelUpdate ret_var = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_c(owner_conv);
4644         int64_t ret_ref = 0;
4645         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4646         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
4647         return ret_ref;
4648 }
4649
4650 static jclass LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_Some_class = NULL;
4651 static jmethodID LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_Some_meth = NULL;
4652 static jclass LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_None_class = NULL;
4653 static jmethodID LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_None_meth = NULL;
4654 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZZ_init (JNIEnv *env, jclass clz) {
4655         LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_Some_class =
4656                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ$Some"));
4657         CHECK(LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_Some_class != NULL);
4658         LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_Some_class, "<init>", "(J)V");
4659         CHECK(LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_Some_meth != NULL);
4660         LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_None_class =
4661                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ$None"));
4662         CHECK(LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_None_class != NULL);
4663         LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_None_meth = (*env)->GetMethodID(env, LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_None_class, "<init>", "()V");
4664         CHECK(LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_None_meth != NULL);
4665 }
4666 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
4667         LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ *obj = (LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ*)untag_ptr(ptr);
4668         switch(obj->tag) {
4669                 case LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_Some: {
4670                         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* some_conv = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
4671                         *some_conv = obj->some;
4672                         *some_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(some_conv);
4673                         return (*env)->NewObject(env, LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_Some_class, LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_Some_meth, tag_ptr(some_conv, true));
4674                 }
4675                 case LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_None: {
4676                         return (*env)->NewObject(env, LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_None_class, LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_None_meth);
4677                 }
4678                 default: abort();
4679         }
4680 }
4681 static inline void CResult_NoneLightningErrorZ_get_ok(LDKCResult_NoneLightningErrorZ *NONNULL_PTR owner){
4682 CHECK(owner->result_ok);
4683         return *owner->contents.result;
4684 }
4685 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4686         LDKCResult_NoneLightningErrorZ* owner_conv = (LDKCResult_NoneLightningErrorZ*)untag_ptr(owner);
4687         CResult_NoneLightningErrorZ_get_ok(owner_conv);
4688 }
4689
4690 static inline struct LDKLightningError CResult_NoneLightningErrorZ_get_err(LDKCResult_NoneLightningErrorZ *NONNULL_PTR owner){
4691         LDKLightningError ret = *owner->contents.err;
4692         ret.is_owned = false;
4693         return ret;
4694 }
4695 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4696         LDKCResult_NoneLightningErrorZ* owner_conv = (LDKCResult_NoneLightningErrorZ*)untag_ptr(owner);
4697         LDKLightningError ret_var = CResult_NoneLightningErrorZ_get_err(owner_conv);
4698         int64_t ret_ref = 0;
4699         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4700         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
4701         return ret_ref;
4702 }
4703
4704 static inline struct LDKChannelUpdateInfo CResult_ChannelUpdateInfoDecodeErrorZ_get_ok(LDKCResult_ChannelUpdateInfoDecodeErrorZ *NONNULL_PTR owner){
4705         LDKChannelUpdateInfo ret = *owner->contents.result;
4706         ret.is_owned = false;
4707         return ret;
4708 }
4709 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateInfoDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4710         LDKCResult_ChannelUpdateInfoDecodeErrorZ* owner_conv = (LDKCResult_ChannelUpdateInfoDecodeErrorZ*)untag_ptr(owner);
4711         LDKChannelUpdateInfo ret_var = CResult_ChannelUpdateInfoDecodeErrorZ_get_ok(owner_conv);
4712         int64_t ret_ref = 0;
4713         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4714         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
4715         return ret_ref;
4716 }
4717
4718 static inline struct LDKDecodeError CResult_ChannelUpdateInfoDecodeErrorZ_get_err(LDKCResult_ChannelUpdateInfoDecodeErrorZ *NONNULL_PTR owner){
4719 CHECK(!owner->result_ok);
4720         return DecodeError_clone(&*owner->contents.err);
4721 }
4722 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateInfoDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4723         LDKCResult_ChannelUpdateInfoDecodeErrorZ* owner_conv = (LDKCResult_ChannelUpdateInfoDecodeErrorZ*)untag_ptr(owner);
4724         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
4725         *ret_copy = CResult_ChannelUpdateInfoDecodeErrorZ_get_err(owner_conv);
4726         int64_t ret_ref = tag_ptr(ret_copy, true);
4727         return ret_ref;
4728 }
4729
4730 static inline struct LDKChannelInfo CResult_ChannelInfoDecodeErrorZ_get_ok(LDKCResult_ChannelInfoDecodeErrorZ *NONNULL_PTR owner){
4731         LDKChannelInfo ret = *owner->contents.result;
4732         ret.is_owned = false;
4733         return ret;
4734 }
4735 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4736         LDKCResult_ChannelInfoDecodeErrorZ* owner_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)untag_ptr(owner);
4737         LDKChannelInfo ret_var = CResult_ChannelInfoDecodeErrorZ_get_ok(owner_conv);
4738         int64_t ret_ref = 0;
4739         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4740         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
4741         return ret_ref;
4742 }
4743
4744 static inline struct LDKDecodeError CResult_ChannelInfoDecodeErrorZ_get_err(LDKCResult_ChannelInfoDecodeErrorZ *NONNULL_PTR owner){
4745 CHECK(!owner->result_ok);
4746         return DecodeError_clone(&*owner->contents.err);
4747 }
4748 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4749         LDKCResult_ChannelInfoDecodeErrorZ* owner_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)untag_ptr(owner);
4750         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
4751         *ret_copy = CResult_ChannelInfoDecodeErrorZ_get_err(owner_conv);
4752         int64_t ret_ref = tag_ptr(ret_copy, true);
4753         return ret_ref;
4754 }
4755
4756 static inline struct LDKRoutingFees CResult_RoutingFeesDecodeErrorZ_get_ok(LDKCResult_RoutingFeesDecodeErrorZ *NONNULL_PTR owner){
4757         LDKRoutingFees ret = *owner->contents.result;
4758         ret.is_owned = false;
4759         return ret;
4760 }
4761 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4762         LDKCResult_RoutingFeesDecodeErrorZ* owner_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)untag_ptr(owner);
4763         LDKRoutingFees ret_var = CResult_RoutingFeesDecodeErrorZ_get_ok(owner_conv);
4764         int64_t ret_ref = 0;
4765         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4766         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
4767         return ret_ref;
4768 }
4769
4770 static inline struct LDKDecodeError CResult_RoutingFeesDecodeErrorZ_get_err(LDKCResult_RoutingFeesDecodeErrorZ *NONNULL_PTR owner){
4771 CHECK(!owner->result_ok);
4772         return DecodeError_clone(&*owner->contents.err);
4773 }
4774 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4775         LDKCResult_RoutingFeesDecodeErrorZ* owner_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)untag_ptr(owner);
4776         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
4777         *ret_copy = CResult_RoutingFeesDecodeErrorZ_get_err(owner_conv);
4778         int64_t ret_ref = tag_ptr(ret_copy, true);
4779         return ret_ref;
4780 }
4781
4782 static jclass LDKNetAddress_IPv4_class = NULL;
4783 static jmethodID LDKNetAddress_IPv4_meth = NULL;
4784 static jclass LDKNetAddress_IPv6_class = NULL;
4785 static jmethodID LDKNetAddress_IPv6_meth = NULL;
4786 static jclass LDKNetAddress_OnionV2_class = NULL;
4787 static jmethodID LDKNetAddress_OnionV2_meth = NULL;
4788 static jclass LDKNetAddress_OnionV3_class = NULL;
4789 static jmethodID LDKNetAddress_OnionV3_meth = NULL;
4790 static jclass LDKNetAddress_Hostname_class = NULL;
4791 static jmethodID LDKNetAddress_Hostname_meth = NULL;
4792 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKNetAddress_init (JNIEnv *env, jclass clz) {
4793         LDKNetAddress_IPv4_class =
4794                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKNetAddress$IPv4"));
4795         CHECK(LDKNetAddress_IPv4_class != NULL);
4796         LDKNetAddress_IPv4_meth = (*env)->GetMethodID(env, LDKNetAddress_IPv4_class, "<init>", "([BS)V");
4797         CHECK(LDKNetAddress_IPv4_meth != NULL);
4798         LDKNetAddress_IPv6_class =
4799                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKNetAddress$IPv6"));
4800         CHECK(LDKNetAddress_IPv6_class != NULL);
4801         LDKNetAddress_IPv6_meth = (*env)->GetMethodID(env, LDKNetAddress_IPv6_class, "<init>", "([BS)V");
4802         CHECK(LDKNetAddress_IPv6_meth != NULL);
4803         LDKNetAddress_OnionV2_class =
4804                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKNetAddress$OnionV2"));
4805         CHECK(LDKNetAddress_OnionV2_class != NULL);
4806         LDKNetAddress_OnionV2_meth = (*env)->GetMethodID(env, LDKNetAddress_OnionV2_class, "<init>", "([B)V");
4807         CHECK(LDKNetAddress_OnionV2_meth != NULL);
4808         LDKNetAddress_OnionV3_class =
4809                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKNetAddress$OnionV3"));
4810         CHECK(LDKNetAddress_OnionV3_class != NULL);
4811         LDKNetAddress_OnionV3_meth = (*env)->GetMethodID(env, LDKNetAddress_OnionV3_class, "<init>", "([BSBS)V");
4812         CHECK(LDKNetAddress_OnionV3_meth != NULL);
4813         LDKNetAddress_Hostname_class =
4814                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKNetAddress$Hostname"));
4815         CHECK(LDKNetAddress_Hostname_class != NULL);
4816         LDKNetAddress_Hostname_meth = (*env)->GetMethodID(env, LDKNetAddress_Hostname_class, "<init>", "(JS)V");
4817         CHECK(LDKNetAddress_Hostname_meth != NULL);
4818 }
4819 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKNetAddress_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
4820         LDKNetAddress *obj = (LDKNetAddress*)untag_ptr(ptr);
4821         switch(obj->tag) {
4822                 case LDKNetAddress_IPv4: {
4823                         int8_tArray addr_arr = (*env)->NewByteArray(env, 4);
4824                         (*env)->SetByteArrayRegion(env, addr_arr, 0, 4, obj->i_pv4.addr.data);
4825                         int16_t port_conv = obj->i_pv4.port;
4826                         return (*env)->NewObject(env, LDKNetAddress_IPv4_class, LDKNetAddress_IPv4_meth, addr_arr, port_conv);
4827                 }
4828                 case LDKNetAddress_IPv6: {
4829                         int8_tArray addr_arr = (*env)->NewByteArray(env, 16);
4830                         (*env)->SetByteArrayRegion(env, addr_arr, 0, 16, obj->i_pv6.addr.data);
4831                         int16_t port_conv = obj->i_pv6.port;
4832                         return (*env)->NewObject(env, LDKNetAddress_IPv6_class, LDKNetAddress_IPv6_meth, addr_arr, port_conv);
4833                 }
4834                 case LDKNetAddress_OnionV2: {
4835                         int8_tArray onion_v2_arr = (*env)->NewByteArray(env, 12);
4836                         (*env)->SetByteArrayRegion(env, onion_v2_arr, 0, 12, obj->onion_v2.data);
4837                         return (*env)->NewObject(env, LDKNetAddress_OnionV2_class, LDKNetAddress_OnionV2_meth, onion_v2_arr);
4838                 }
4839                 case LDKNetAddress_OnionV3: {
4840                         int8_tArray ed25519_pubkey_arr = (*env)->NewByteArray(env, 32);
4841                         (*env)->SetByteArrayRegion(env, ed25519_pubkey_arr, 0, 32, obj->onion_v3.ed25519_pubkey.data);
4842                         int16_t checksum_conv = obj->onion_v3.checksum;
4843                         int8_t version_conv = obj->onion_v3.version;
4844                         int16_t port_conv = obj->onion_v3.port;
4845                         return (*env)->NewObject(env, LDKNetAddress_OnionV3_class, LDKNetAddress_OnionV3_meth, ed25519_pubkey_arr, checksum_conv, version_conv, port_conv);
4846                 }
4847                 case LDKNetAddress_Hostname: {
4848                         LDKHostname hostname_var = obj->hostname.hostname;
4849                         int64_t hostname_ref = 0;
4850                         CHECK_INNER_FIELD_ACCESS_OR_NULL(hostname_var);
4851                         hostname_ref = tag_ptr(hostname_var.inner, false);
4852                         int16_t port_conv = obj->hostname.port;
4853                         return (*env)->NewObject(env, LDKNetAddress_Hostname_class, LDKNetAddress_Hostname_meth, hostname_ref, port_conv);
4854                 }
4855                 default: abort();
4856         }
4857 }
4858 static inline LDKCVec_NetAddressZ CVec_NetAddressZ_clone(const LDKCVec_NetAddressZ *orig) {
4859         LDKCVec_NetAddressZ ret = { .data = MALLOC(sizeof(LDKNetAddress) * orig->datalen, "LDKCVec_NetAddressZ clone bytes"), .datalen = orig->datalen };
4860         for (size_t i = 0; i < ret.datalen; i++) {
4861                 ret.data[i] = NetAddress_clone(&orig->data[i]);
4862         }
4863         return ret;
4864 }
4865 static inline struct LDKNodeAnnouncementInfo CResult_NodeAnnouncementInfoDecodeErrorZ_get_ok(LDKCResult_NodeAnnouncementInfoDecodeErrorZ *NONNULL_PTR owner){
4866         LDKNodeAnnouncementInfo ret = *owner->contents.result;
4867         ret.is_owned = false;
4868         return ret;
4869 }
4870 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4871         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* owner_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)untag_ptr(owner);
4872         LDKNodeAnnouncementInfo ret_var = CResult_NodeAnnouncementInfoDecodeErrorZ_get_ok(owner_conv);
4873         int64_t ret_ref = 0;
4874         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4875         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
4876         return ret_ref;
4877 }
4878
4879 static inline struct LDKDecodeError CResult_NodeAnnouncementInfoDecodeErrorZ_get_err(LDKCResult_NodeAnnouncementInfoDecodeErrorZ *NONNULL_PTR owner){
4880 CHECK(!owner->result_ok);
4881         return DecodeError_clone(&*owner->contents.err);
4882 }
4883 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4884         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* owner_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)untag_ptr(owner);
4885         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
4886         *ret_copy = CResult_NodeAnnouncementInfoDecodeErrorZ_get_err(owner_conv);
4887         int64_t ret_ref = tag_ptr(ret_copy, true);
4888         return ret_ref;
4889 }
4890
4891 static inline struct LDKNodeAlias CResult_NodeAliasDecodeErrorZ_get_ok(LDKCResult_NodeAliasDecodeErrorZ *NONNULL_PTR owner){
4892         LDKNodeAlias ret = *owner->contents.result;
4893         ret.is_owned = false;
4894         return ret;
4895 }
4896 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAliasDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4897         LDKCResult_NodeAliasDecodeErrorZ* owner_conv = (LDKCResult_NodeAliasDecodeErrorZ*)untag_ptr(owner);
4898         LDKNodeAlias ret_var = CResult_NodeAliasDecodeErrorZ_get_ok(owner_conv);
4899         int64_t ret_ref = 0;
4900         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4901         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
4902         return ret_ref;
4903 }
4904
4905 static inline struct LDKDecodeError CResult_NodeAliasDecodeErrorZ_get_err(LDKCResult_NodeAliasDecodeErrorZ *NONNULL_PTR owner){
4906 CHECK(!owner->result_ok);
4907         return DecodeError_clone(&*owner->contents.err);
4908 }
4909 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAliasDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4910         LDKCResult_NodeAliasDecodeErrorZ* owner_conv = (LDKCResult_NodeAliasDecodeErrorZ*)untag_ptr(owner);
4911         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
4912         *ret_copy = CResult_NodeAliasDecodeErrorZ_get_err(owner_conv);
4913         int64_t ret_ref = tag_ptr(ret_copy, true);
4914         return ret_ref;
4915 }
4916
4917 static inline struct LDKNodeInfo CResult_NodeInfoDecodeErrorZ_get_ok(LDKCResult_NodeInfoDecodeErrorZ *NONNULL_PTR owner){
4918         LDKNodeInfo ret = *owner->contents.result;
4919         ret.is_owned = false;
4920         return ret;
4921 }
4922 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4923         LDKCResult_NodeInfoDecodeErrorZ* owner_conv = (LDKCResult_NodeInfoDecodeErrorZ*)untag_ptr(owner);
4924         LDKNodeInfo ret_var = CResult_NodeInfoDecodeErrorZ_get_ok(owner_conv);
4925         int64_t ret_ref = 0;
4926         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4927         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
4928         return ret_ref;
4929 }
4930
4931 static inline struct LDKDecodeError CResult_NodeInfoDecodeErrorZ_get_err(LDKCResult_NodeInfoDecodeErrorZ *NONNULL_PTR owner){
4932 CHECK(!owner->result_ok);
4933         return DecodeError_clone(&*owner->contents.err);
4934 }
4935 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4936         LDKCResult_NodeInfoDecodeErrorZ* owner_conv = (LDKCResult_NodeInfoDecodeErrorZ*)untag_ptr(owner);
4937         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
4938         *ret_copy = CResult_NodeInfoDecodeErrorZ_get_err(owner_conv);
4939         int64_t ret_ref = tag_ptr(ret_copy, true);
4940         return ret_ref;
4941 }
4942
4943 static inline struct LDKNetworkGraph CResult_NetworkGraphDecodeErrorZ_get_ok(LDKCResult_NetworkGraphDecodeErrorZ *NONNULL_PTR owner){
4944         LDKNetworkGraph ret = *owner->contents.result;
4945         ret.is_owned = false;
4946         return ret;
4947 }
4948 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
4949         LDKCResult_NetworkGraphDecodeErrorZ* owner_conv = (LDKCResult_NetworkGraphDecodeErrorZ*)untag_ptr(owner);
4950         LDKNetworkGraph ret_var = CResult_NetworkGraphDecodeErrorZ_get_ok(owner_conv);
4951         int64_t ret_ref = 0;
4952         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4953         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
4954         return ret_ref;
4955 }
4956
4957 static inline struct LDKDecodeError CResult_NetworkGraphDecodeErrorZ_get_err(LDKCResult_NetworkGraphDecodeErrorZ *NONNULL_PTR owner){
4958 CHECK(!owner->result_ok);
4959         return DecodeError_clone(&*owner->contents.err);
4960 }
4961 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
4962         LDKCResult_NetworkGraphDecodeErrorZ* owner_conv = (LDKCResult_NetworkGraphDecodeErrorZ*)untag_ptr(owner);
4963         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
4964         *ret_copy = CResult_NetworkGraphDecodeErrorZ_get_err(owner_conv);
4965         int64_t ret_ref = tag_ptr(ret_copy, true);
4966         return ret_ref;
4967 }
4968
4969 static jclass LDKCOption_CVec_NetAddressZZ_Some_class = NULL;
4970 static jmethodID LDKCOption_CVec_NetAddressZZ_Some_meth = NULL;
4971 static jclass LDKCOption_CVec_NetAddressZZ_None_class = NULL;
4972 static jmethodID LDKCOption_CVec_NetAddressZZ_None_meth = NULL;
4973 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1CVec_1NetAddressZZ_init (JNIEnv *env, jclass clz) {
4974         LDKCOption_CVec_NetAddressZZ_Some_class =
4975                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_CVec_NetAddressZZ$Some"));
4976         CHECK(LDKCOption_CVec_NetAddressZZ_Some_class != NULL);
4977         LDKCOption_CVec_NetAddressZZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_CVec_NetAddressZZ_Some_class, "<init>", "([J)V");
4978         CHECK(LDKCOption_CVec_NetAddressZZ_Some_meth != NULL);
4979         LDKCOption_CVec_NetAddressZZ_None_class =
4980                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_CVec_NetAddressZZ$None"));
4981         CHECK(LDKCOption_CVec_NetAddressZZ_None_class != NULL);
4982         LDKCOption_CVec_NetAddressZZ_None_meth = (*env)->GetMethodID(env, LDKCOption_CVec_NetAddressZZ_None_class, "<init>", "()V");
4983         CHECK(LDKCOption_CVec_NetAddressZZ_None_meth != NULL);
4984 }
4985 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1CVec_1NetAddressZZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
4986         LDKCOption_CVec_NetAddressZZ *obj = (LDKCOption_CVec_NetAddressZZ*)untag_ptr(ptr);
4987         switch(obj->tag) {
4988                 case LDKCOption_CVec_NetAddressZZ_Some: {
4989                         LDKCVec_NetAddressZ some_var = obj->some;
4990                         int64_tArray some_arr = NULL;
4991                         some_arr = (*env)->NewLongArray(env, some_var.datalen);
4992                         int64_t *some_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, some_arr, NULL);
4993                         for (size_t m = 0; m < some_var.datalen; m++) {
4994                                 int64_t some_conv_12_ref = tag_ptr(&some_var.data[m], false);
4995                                 some_arr_ptr[m] = some_conv_12_ref;
4996                         }
4997                         (*env)->ReleasePrimitiveArrayCritical(env, some_arr, some_arr_ptr, 0);
4998                         return (*env)->NewObject(env, LDKCOption_CVec_NetAddressZZ_Some_class, LDKCOption_CVec_NetAddressZZ_Some_meth, some_arr);
4999                 }
5000                 case LDKCOption_CVec_NetAddressZZ_None: {
5001                         return (*env)->NewObject(env, LDKCOption_CVec_NetAddressZZ_None_class, LDKCOption_CVec_NetAddressZZ_None_meth);
5002                 }
5003                 default: abort();
5004         }
5005 }
5006 static inline struct LDKDelayedPaymentOutputDescriptor CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_ok(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
5007         LDKDelayedPaymentOutputDescriptor ret = *owner->contents.result;
5008         ret.is_owned = false;
5009         return ret;
5010 }
5011 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
5012         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)untag_ptr(owner);
5013         LDKDelayedPaymentOutputDescriptor ret_var = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_ok(owner_conv);
5014         int64_t ret_ref = 0;
5015         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5016         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
5017         return ret_ref;
5018 }
5019
5020 static inline struct LDKDecodeError CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_err(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
5021 CHECK(!owner->result_ok);
5022         return DecodeError_clone(&*owner->contents.err);
5023 }
5024 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
5025         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)untag_ptr(owner);
5026         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
5027         *ret_copy = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_get_err(owner_conv);
5028         int64_t ret_ref = tag_ptr(ret_copy, true);
5029         return ret_ref;
5030 }
5031
5032 static inline struct LDKStaticPaymentOutputDescriptor CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_ok(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
5033         LDKStaticPaymentOutputDescriptor ret = *owner->contents.result;
5034         ret.is_owned = false;
5035         return ret;
5036 }
5037 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
5038         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)untag_ptr(owner);
5039         LDKStaticPaymentOutputDescriptor ret_var = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_ok(owner_conv);
5040         int64_t ret_ref = 0;
5041         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5042         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
5043         return ret_ref;
5044 }
5045
5046 static inline struct LDKDecodeError CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_err(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
5047 CHECK(!owner->result_ok);
5048         return DecodeError_clone(&*owner->contents.err);
5049 }
5050 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
5051         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)untag_ptr(owner);
5052         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
5053         *ret_copy = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_get_err(owner_conv);
5054         int64_t ret_ref = tag_ptr(ret_copy, true);
5055         return ret_ref;
5056 }
5057
5058 static inline struct LDKSpendableOutputDescriptor CResult_SpendableOutputDescriptorDecodeErrorZ_get_ok(LDKCResult_SpendableOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
5059 CHECK(owner->result_ok);
5060         return SpendableOutputDescriptor_clone(&*owner->contents.result);
5061 }
5062 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
5063         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)untag_ptr(owner);
5064         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
5065         *ret_copy = CResult_SpendableOutputDescriptorDecodeErrorZ_get_ok(owner_conv);
5066         int64_t ret_ref = tag_ptr(ret_copy, true);
5067         return ret_ref;
5068 }
5069
5070 static inline struct LDKDecodeError CResult_SpendableOutputDescriptorDecodeErrorZ_get_err(LDKCResult_SpendableOutputDescriptorDecodeErrorZ *NONNULL_PTR owner){
5071 CHECK(!owner->result_ok);
5072         return DecodeError_clone(&*owner->contents.err);
5073 }
5074 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
5075         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* owner_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)untag_ptr(owner);
5076         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
5077         *ret_copy = CResult_SpendableOutputDescriptorDecodeErrorZ_get_err(owner_conv);
5078         int64_t ret_ref = tag_ptr(ret_copy, true);
5079         return ret_ref;
5080 }
5081
5082 static inline LDKCVec_PaymentPreimageZ CVec_PaymentPreimageZ_clone(const LDKCVec_PaymentPreimageZ *orig) {
5083         LDKCVec_PaymentPreimageZ ret = { .data = MALLOC(sizeof(LDKThirtyTwoBytes) * orig->datalen, "LDKCVec_PaymentPreimageZ clone bytes"), .datalen = orig->datalen };
5084         for (size_t i = 0; i < ret.datalen; i++) {
5085                 ret.data[i] = ThirtyTwoBytes_clone(&orig->data[i]);
5086         }
5087         return ret;
5088 }
5089 static inline struct LDKSignature C2Tuple_SignatureCVec_SignatureZZ_get_a(LDKC2Tuple_SignatureCVec_SignatureZZ *NONNULL_PTR owner){
5090         return owner->a;
5091 }
5092 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
5093         LDKC2Tuple_SignatureCVec_SignatureZZ* owner_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)untag_ptr(owner);
5094         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
5095         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, C2Tuple_SignatureCVec_SignatureZZ_get_a(owner_conv).compact_form);
5096         return ret_arr;
5097 }
5098
5099 static inline struct LDKCVec_SignatureZ C2Tuple_SignatureCVec_SignatureZZ_get_b(LDKC2Tuple_SignatureCVec_SignatureZZ *NONNULL_PTR owner){
5100         return owner->b;
5101 }
5102 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
5103         LDKC2Tuple_SignatureCVec_SignatureZZ* owner_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)untag_ptr(owner);
5104         LDKCVec_SignatureZ ret_var = C2Tuple_SignatureCVec_SignatureZZ_get_b(owner_conv);
5105         jobjectArray ret_arr = NULL;
5106         ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
5107         ;
5108         for (size_t i = 0; i < ret_var.datalen; i++) {
5109                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, 64);
5110                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, 64, ret_var.data[i].compact_form);
5111                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
5112         }
5113         
5114         return ret_arr;
5115 }
5116
5117 static inline struct LDKC2Tuple_SignatureCVec_SignatureZZ CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_ok(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *NONNULL_PTR owner){
5118 CHECK(owner->result_ok);
5119         return C2Tuple_SignatureCVec_SignatureZZ_clone(&*owner->contents.result);
5120 }
5121 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
5122         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* owner_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)untag_ptr(owner);
5123         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
5124         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_ok(owner_conv);
5125         return tag_ptr(ret_conv, true);
5126 }
5127
5128 static inline void CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_err(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *NONNULL_PTR owner){
5129 CHECK(!owner->result_ok);
5130         return *owner->contents.err;
5131 }
5132 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
5133         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* owner_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)untag_ptr(owner);
5134         CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_get_err(owner_conv);
5135 }
5136
5137 static inline struct LDKSignature CResult_SignatureNoneZ_get_ok(LDKCResult_SignatureNoneZ *NONNULL_PTR owner){
5138 CHECK(owner->result_ok);
5139         return *owner->contents.result;
5140 }
5141 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
5142         LDKCResult_SignatureNoneZ* owner_conv = (LDKCResult_SignatureNoneZ*)untag_ptr(owner);
5143         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
5144         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, CResult_SignatureNoneZ_get_ok(owner_conv).compact_form);
5145         return ret_arr;
5146 }
5147
5148 static inline void CResult_SignatureNoneZ_get_err(LDKCResult_SignatureNoneZ *NONNULL_PTR owner){
5149 CHECK(!owner->result_ok);
5150         return *owner->contents.err;
5151 }
5152 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
5153         LDKCResult_SignatureNoneZ* owner_conv = (LDKCResult_SignatureNoneZ*)untag_ptr(owner);
5154         CResult_SignatureNoneZ_get_err(owner_conv);
5155 }
5156
5157 static inline struct LDKSignature C2Tuple_SignatureSignatureZ_get_a(LDKC2Tuple_SignatureSignatureZ *NONNULL_PTR owner){
5158         return owner->a;
5159 }
5160 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureSignatureZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
5161         LDKC2Tuple_SignatureSignatureZ* owner_conv = (LDKC2Tuple_SignatureSignatureZ*)untag_ptr(owner);
5162         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
5163         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, C2Tuple_SignatureSignatureZ_get_a(owner_conv).compact_form);
5164         return ret_arr;
5165 }
5166
5167 static inline struct LDKSignature C2Tuple_SignatureSignatureZ_get_b(LDKC2Tuple_SignatureSignatureZ *NONNULL_PTR owner){
5168         return owner->b;
5169 }
5170 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureSignatureZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
5171         LDKC2Tuple_SignatureSignatureZ* owner_conv = (LDKC2Tuple_SignatureSignatureZ*)untag_ptr(owner);
5172         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
5173         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, C2Tuple_SignatureSignatureZ_get_b(owner_conv).compact_form);
5174         return ret_arr;
5175 }
5176
5177 static inline struct LDKC2Tuple_SignatureSignatureZ CResult_C2Tuple_SignatureSignatureZNoneZ_get_ok(LDKCResult_C2Tuple_SignatureSignatureZNoneZ *NONNULL_PTR owner){
5178 CHECK(owner->result_ok);
5179         return C2Tuple_SignatureSignatureZ_clone(&*owner->contents.result);
5180 }
5181 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureSignatureZNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
5182         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* owner_conv = (LDKCResult_C2Tuple_SignatureSignatureZNoneZ*)untag_ptr(owner);
5183         LDKC2Tuple_SignatureSignatureZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureSignatureZ), "LDKC2Tuple_SignatureSignatureZ");
5184         *ret_conv = CResult_C2Tuple_SignatureSignatureZNoneZ_get_ok(owner_conv);
5185         return tag_ptr(ret_conv, true);
5186 }
5187
5188 static inline void CResult_C2Tuple_SignatureSignatureZNoneZ_get_err(LDKCResult_C2Tuple_SignatureSignatureZNoneZ *NONNULL_PTR owner){
5189 CHECK(!owner->result_ok);
5190         return *owner->contents.err;
5191 }
5192 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureSignatureZNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
5193         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* owner_conv = (LDKCResult_C2Tuple_SignatureSignatureZNoneZ*)untag_ptr(owner);
5194         CResult_C2Tuple_SignatureSignatureZNoneZ_get_err(owner_conv);
5195 }
5196
5197 static inline struct LDKSecretKey CResult_SecretKeyNoneZ_get_ok(LDKCResult_SecretKeyNoneZ *NONNULL_PTR owner){
5198 CHECK(owner->result_ok);
5199         return *owner->contents.result;
5200 }
5201 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
5202         LDKCResult_SecretKeyNoneZ* owner_conv = (LDKCResult_SecretKeyNoneZ*)untag_ptr(owner);
5203         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
5204         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, CResult_SecretKeyNoneZ_get_ok(owner_conv).bytes);
5205         return ret_arr;
5206 }
5207
5208 static inline void CResult_SecretKeyNoneZ_get_err(LDKCResult_SecretKeyNoneZ *NONNULL_PTR owner){
5209 CHECK(!owner->result_ok);
5210         return *owner->contents.err;
5211 }
5212 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
5213         LDKCResult_SecretKeyNoneZ* owner_conv = (LDKCResult_SecretKeyNoneZ*)untag_ptr(owner);
5214         CResult_SecretKeyNoneZ_get_err(owner_conv);
5215 }
5216
5217 static inline struct LDKPublicKey CResult_PublicKeyNoneZ_get_ok(LDKCResult_PublicKeyNoneZ *NONNULL_PTR owner){
5218 CHECK(owner->result_ok);
5219         return *owner->contents.result;
5220 }
5221 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
5222         LDKCResult_PublicKeyNoneZ* owner_conv = (LDKCResult_PublicKeyNoneZ*)untag_ptr(owner);
5223         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
5224         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, CResult_PublicKeyNoneZ_get_ok(owner_conv).compressed_form);
5225         return ret_arr;
5226 }
5227
5228 static inline void CResult_PublicKeyNoneZ_get_err(LDKCResult_PublicKeyNoneZ *NONNULL_PTR owner){
5229 CHECK(!owner->result_ok);
5230         return *owner->contents.err;
5231 }
5232 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
5233         LDKCResult_PublicKeyNoneZ* owner_conv = (LDKCResult_PublicKeyNoneZ*)untag_ptr(owner);
5234         CResult_PublicKeyNoneZ_get_err(owner_conv);
5235 }
5236
5237 static jclass LDKCOption_ScalarZ_Some_class = NULL;
5238 static jmethodID LDKCOption_ScalarZ_Some_meth = NULL;
5239 static jclass LDKCOption_ScalarZ_None_class = NULL;
5240 static jmethodID LDKCOption_ScalarZ_None_meth = NULL;
5241 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1ScalarZ_init (JNIEnv *env, jclass clz) {
5242         LDKCOption_ScalarZ_Some_class =
5243                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_ScalarZ$Some"));
5244         CHECK(LDKCOption_ScalarZ_Some_class != NULL);
5245         LDKCOption_ScalarZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_ScalarZ_Some_class, "<init>", "(J)V");
5246         CHECK(LDKCOption_ScalarZ_Some_meth != NULL);
5247         LDKCOption_ScalarZ_None_class =
5248                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_ScalarZ$None"));
5249         CHECK(LDKCOption_ScalarZ_None_class != NULL);
5250         LDKCOption_ScalarZ_None_meth = (*env)->GetMethodID(env, LDKCOption_ScalarZ_None_class, "<init>", "()V");
5251         CHECK(LDKCOption_ScalarZ_None_meth != NULL);
5252 }
5253 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1ScalarZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
5254         LDKCOption_ScalarZ *obj = (LDKCOption_ScalarZ*)untag_ptr(ptr);
5255         switch(obj->tag) {
5256                 case LDKCOption_ScalarZ_Some: {
5257                         LDKBigEndianScalar* some_ref = &obj->some;
5258                         return (*env)->NewObject(env, LDKCOption_ScalarZ_Some_class, LDKCOption_ScalarZ_Some_meth, tag_ptr(some_ref, false));
5259                 }
5260                 case LDKCOption_ScalarZ_None: {
5261                         return (*env)->NewObject(env, LDKCOption_ScalarZ_None_class, LDKCOption_ScalarZ_None_meth);
5262                 }
5263                 default: abort();
5264         }
5265 }
5266 static inline struct LDKThirtyTwoBytes CResult_SharedSecretNoneZ_get_ok(LDKCResult_SharedSecretNoneZ *NONNULL_PTR owner){
5267 CHECK(owner->result_ok);
5268         return ThirtyTwoBytes_clone(&*owner->contents.result);
5269 }
5270 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1SharedSecretNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
5271         LDKCResult_SharedSecretNoneZ* owner_conv = (LDKCResult_SharedSecretNoneZ*)untag_ptr(owner);
5272         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
5273         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, CResult_SharedSecretNoneZ_get_ok(owner_conv).data);
5274         return ret_arr;
5275 }
5276
5277 static inline void CResult_SharedSecretNoneZ_get_err(LDKCResult_SharedSecretNoneZ *NONNULL_PTR owner){
5278 CHECK(!owner->result_ok);
5279         return *owner->contents.err;
5280 }
5281 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SharedSecretNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
5282         LDKCResult_SharedSecretNoneZ* owner_conv = (LDKCResult_SharedSecretNoneZ*)untag_ptr(owner);
5283         CResult_SharedSecretNoneZ_get_err(owner_conv);
5284 }
5285
5286 typedef struct LDKBaseSign_JCalls {
5287         atomic_size_t refcnt;
5288         JavaVM *vm;
5289         jweak o;
5290         jmethodID get_per_commitment_point_meth;
5291         jmethodID release_commitment_secret_meth;
5292         jmethodID validate_holder_commitment_meth;
5293         jmethodID channel_keys_id_meth;
5294         jmethodID sign_counterparty_commitment_meth;
5295         jmethodID validate_counterparty_revocation_meth;
5296         jmethodID sign_holder_commitment_and_htlcs_meth;
5297         jmethodID sign_justice_revoked_output_meth;
5298         jmethodID sign_justice_revoked_htlc_meth;
5299         jmethodID sign_counterparty_htlc_transaction_meth;
5300         jmethodID sign_closing_transaction_meth;
5301         jmethodID sign_holder_anchor_input_meth;
5302         jmethodID sign_channel_announcement_meth;
5303         jmethodID provide_channel_parameters_meth;
5304 } LDKBaseSign_JCalls;
5305 static void LDKBaseSign_JCalls_free(void* this_arg) {
5306         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
5307         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
5308                 JNIEnv *env;
5309                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5310                 if (get_jenv_res == JNI_EDETACHED) {
5311                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5312                 } else {
5313                         DO_ASSERT(get_jenv_res == JNI_OK);
5314                 }
5315                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
5316                 if (get_jenv_res == JNI_EDETACHED) {
5317                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5318                 }
5319                 FREE(j_calls);
5320         }
5321 }
5322 LDKPublicKey get_per_commitment_point_LDKBaseSign_jcall(const void* this_arg, uint64_t idx) {
5323         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
5324         JNIEnv *env;
5325         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5326         if (get_jenv_res == JNI_EDETACHED) {
5327                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5328         } else {
5329                 DO_ASSERT(get_jenv_res == JNI_OK);
5330         }
5331         int64_t idx_conv = idx;
5332         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5333         CHECK(obj != NULL);
5334         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_per_commitment_point_meth, idx_conv);
5335         if (UNLIKELY((*env)->ExceptionCheck(env))) {
5336                 (*env)->ExceptionDescribe(env);
5337                 (*env)->FatalError(env, "A call to get_per_commitment_point in LDKBaseSign from rust threw an exception.");
5338         }
5339         LDKPublicKey ret_ref;
5340         CHECK((*env)->GetArrayLength(env, ret) == 33);
5341         (*env)->GetByteArrayRegion(env, ret, 0, 33, ret_ref.compressed_form);
5342         if (get_jenv_res == JNI_EDETACHED) {
5343                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5344         }
5345         return ret_ref;
5346 }
5347 LDKThirtyTwoBytes release_commitment_secret_LDKBaseSign_jcall(const void* this_arg, uint64_t idx) {
5348         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
5349         JNIEnv *env;
5350         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5351         if (get_jenv_res == JNI_EDETACHED) {
5352                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5353         } else {
5354                 DO_ASSERT(get_jenv_res == JNI_OK);
5355         }
5356         int64_t idx_conv = idx;
5357         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5358         CHECK(obj != NULL);
5359         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->release_commitment_secret_meth, idx_conv);
5360         if (UNLIKELY((*env)->ExceptionCheck(env))) {
5361                 (*env)->ExceptionDescribe(env);
5362                 (*env)->FatalError(env, "A call to release_commitment_secret in LDKBaseSign from rust threw an exception.");
5363         }
5364         LDKThirtyTwoBytes ret_ref;
5365         CHECK((*env)->GetArrayLength(env, ret) == 32);
5366         (*env)->GetByteArrayRegion(env, ret, 0, 32, ret_ref.data);
5367         if (get_jenv_res == JNI_EDETACHED) {
5368                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5369         }
5370         return ret_ref;
5371 }
5372 LDKCResult_NoneNoneZ validate_holder_commitment_LDKBaseSign_jcall(const void* this_arg, const LDKHolderCommitmentTransaction * holder_tx, LDKCVec_PaymentPreimageZ preimages) {
5373         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
5374         JNIEnv *env;
5375         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5376         if (get_jenv_res == JNI_EDETACHED) {
5377                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5378         } else {
5379                 DO_ASSERT(get_jenv_res == JNI_OK);
5380         }
5381         LDKHolderCommitmentTransaction holder_tx_var = *holder_tx;
5382         int64_t holder_tx_ref = 0;
5383         holder_tx_var = HolderCommitmentTransaction_clone(&holder_tx_var);
5384         CHECK_INNER_FIELD_ACCESS_OR_NULL(holder_tx_var);
5385         holder_tx_ref = tag_ptr(holder_tx_var.inner, holder_tx_var.is_owned);
5386         LDKCVec_PaymentPreimageZ preimages_var = preimages;
5387         jobjectArray preimages_arr = NULL;
5388         preimages_arr = (*env)->NewObjectArray(env, preimages_var.datalen, arr_of_B_clz, NULL);
5389         ;
5390         for (size_t i = 0; i < preimages_var.datalen; i++) {
5391                 int8_tArray preimages_conv_8_arr = (*env)->NewByteArray(env, 32);
5392                 (*env)->SetByteArrayRegion(env, preimages_conv_8_arr, 0, 32, preimages_var.data[i].data);
5393                 (*env)->SetObjectArrayElement(env, preimages_arr, i, preimages_conv_8_arr);
5394         }
5395         
5396         FREE(preimages_var.data);
5397         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5398         CHECK(obj != NULL);
5399         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->validate_holder_commitment_meth, holder_tx_ref, preimages_arr);
5400         if (UNLIKELY((*env)->ExceptionCheck(env))) {
5401                 (*env)->ExceptionDescribe(env);
5402                 (*env)->FatalError(env, "A call to validate_holder_commitment in LDKBaseSign from rust threw an exception.");
5403         }
5404         void* ret_ptr = untag_ptr(ret);
5405         CHECK_ACCESS(ret_ptr);
5406         LDKCResult_NoneNoneZ ret_conv = *(LDKCResult_NoneNoneZ*)(ret_ptr);
5407         FREE(untag_ptr(ret));
5408         if (get_jenv_res == JNI_EDETACHED) {
5409                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5410         }
5411         return ret_conv;
5412 }
5413 LDKThirtyTwoBytes channel_keys_id_LDKBaseSign_jcall(const void* this_arg) {
5414         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
5415         JNIEnv *env;
5416         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5417         if (get_jenv_res == JNI_EDETACHED) {
5418                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5419         } else {
5420                 DO_ASSERT(get_jenv_res == JNI_OK);
5421         }
5422         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5423         CHECK(obj != NULL);
5424         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->channel_keys_id_meth);
5425         if (UNLIKELY((*env)->ExceptionCheck(env))) {
5426                 (*env)->ExceptionDescribe(env);
5427                 (*env)->FatalError(env, "A call to channel_keys_id in LDKBaseSign from rust threw an exception.");
5428         }
5429         LDKThirtyTwoBytes ret_ref;
5430         CHECK((*env)->GetArrayLength(env, ret) == 32);
5431         (*env)->GetByteArrayRegion(env, ret, 0, 32, ret_ref.data);
5432         if (get_jenv_res == JNI_EDETACHED) {
5433                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5434         }
5435         return ret_ref;
5436 }
5437 LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_counterparty_commitment_LDKBaseSign_jcall(const void* this_arg, const LDKCommitmentTransaction * commitment_tx, LDKCVec_PaymentPreimageZ preimages) {
5438         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
5439         JNIEnv *env;
5440         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5441         if (get_jenv_res == JNI_EDETACHED) {
5442                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5443         } else {
5444                 DO_ASSERT(get_jenv_res == JNI_OK);
5445         }
5446         LDKCommitmentTransaction commitment_tx_var = *commitment_tx;
5447         int64_t commitment_tx_ref = 0;
5448         commitment_tx_var = CommitmentTransaction_clone(&commitment_tx_var);
5449         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_var);
5450         commitment_tx_ref = tag_ptr(commitment_tx_var.inner, commitment_tx_var.is_owned);
5451         LDKCVec_PaymentPreimageZ preimages_var = preimages;
5452         jobjectArray preimages_arr = NULL;
5453         preimages_arr = (*env)->NewObjectArray(env, preimages_var.datalen, arr_of_B_clz, NULL);
5454         ;
5455         for (size_t i = 0; i < preimages_var.datalen; i++) {
5456                 int8_tArray preimages_conv_8_arr = (*env)->NewByteArray(env, 32);
5457                 (*env)->SetByteArrayRegion(env, preimages_conv_8_arr, 0, 32, preimages_var.data[i].data);
5458                 (*env)->SetObjectArrayElement(env, preimages_arr, i, preimages_conv_8_arr);
5459         }
5460         
5461         FREE(preimages_var.data);
5462         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5463         CHECK(obj != NULL);
5464         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->sign_counterparty_commitment_meth, commitment_tx_ref, preimages_arr);
5465         if (UNLIKELY((*env)->ExceptionCheck(env))) {
5466                 (*env)->ExceptionDescribe(env);
5467                 (*env)->FatalError(env, "A call to sign_counterparty_commitment in LDKBaseSign from rust threw an exception.");
5468         }
5469         void* ret_ptr = untag_ptr(ret);
5470         CHECK_ACCESS(ret_ptr);
5471         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ ret_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(ret_ptr);
5472         FREE(untag_ptr(ret));
5473         if (get_jenv_res == JNI_EDETACHED) {
5474                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5475         }
5476         return ret_conv;
5477 }
5478 LDKCResult_NoneNoneZ validate_counterparty_revocation_LDKBaseSign_jcall(const void* this_arg, uint64_t idx, const uint8_t (* secret)[32]) {
5479         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
5480         JNIEnv *env;
5481         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5482         if (get_jenv_res == JNI_EDETACHED) {
5483                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5484         } else {
5485                 DO_ASSERT(get_jenv_res == JNI_OK);
5486         }
5487         int64_t idx_conv = idx;
5488         int8_tArray secret_arr = (*env)->NewByteArray(env, 32);
5489         (*env)->SetByteArrayRegion(env, secret_arr, 0, 32, *secret);
5490         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5491         CHECK(obj != NULL);
5492         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->validate_counterparty_revocation_meth, idx_conv, secret_arr);
5493         if (UNLIKELY((*env)->ExceptionCheck(env))) {
5494                 (*env)->ExceptionDescribe(env);
5495                 (*env)->FatalError(env, "A call to validate_counterparty_revocation in LDKBaseSign from rust threw an exception.");
5496         }
5497         void* ret_ptr = untag_ptr(ret);
5498         CHECK_ACCESS(ret_ptr);
5499         LDKCResult_NoneNoneZ ret_conv = *(LDKCResult_NoneNoneZ*)(ret_ptr);
5500         FREE(untag_ptr(ret));
5501         if (get_jenv_res == JNI_EDETACHED) {
5502                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5503         }
5504         return ret_conv;
5505 }
5506 LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_holder_commitment_and_htlcs_LDKBaseSign_jcall(const void* this_arg, const LDKHolderCommitmentTransaction * commitment_tx) {
5507         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
5508         JNIEnv *env;
5509         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5510         if (get_jenv_res == JNI_EDETACHED) {
5511                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5512         } else {
5513                 DO_ASSERT(get_jenv_res == JNI_OK);
5514         }
5515         LDKHolderCommitmentTransaction commitment_tx_var = *commitment_tx;
5516         int64_t commitment_tx_ref = 0;
5517         commitment_tx_var = HolderCommitmentTransaction_clone(&commitment_tx_var);
5518         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_var);
5519         commitment_tx_ref = tag_ptr(commitment_tx_var.inner, commitment_tx_var.is_owned);
5520         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5521         CHECK(obj != NULL);
5522         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->sign_holder_commitment_and_htlcs_meth, commitment_tx_ref);
5523         if (UNLIKELY((*env)->ExceptionCheck(env))) {
5524                 (*env)->ExceptionDescribe(env);
5525                 (*env)->FatalError(env, "A call to sign_holder_commitment_and_htlcs in LDKBaseSign from rust threw an exception.");
5526         }
5527         void* ret_ptr = untag_ptr(ret);
5528         CHECK_ACCESS(ret_ptr);
5529         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ ret_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(ret_ptr);
5530         FREE(untag_ptr(ret));
5531         if (get_jenv_res == JNI_EDETACHED) {
5532                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5533         }
5534         return ret_conv;
5535 }
5536 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]) {
5537         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
5538         JNIEnv *env;
5539         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5540         if (get_jenv_res == JNI_EDETACHED) {
5541                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5542         } else {
5543                 DO_ASSERT(get_jenv_res == JNI_OK);
5544         }
5545         LDKTransaction justice_tx_var = justice_tx;
5546         int8_tArray justice_tx_arr = (*env)->NewByteArray(env, justice_tx_var.datalen);
5547         (*env)->SetByteArrayRegion(env, justice_tx_arr, 0, justice_tx_var.datalen, justice_tx_var.data);
5548         Transaction_free(justice_tx_var);
5549         int64_t input_conv = input;
5550         int64_t amount_conv = amount;
5551         int8_tArray per_commitment_key_arr = (*env)->NewByteArray(env, 32);
5552         (*env)->SetByteArrayRegion(env, per_commitment_key_arr, 0, 32, *per_commitment_key);
5553         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5554         CHECK(obj != NULL);
5555         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);
5556         if (UNLIKELY((*env)->ExceptionCheck(env))) {
5557                 (*env)->ExceptionDescribe(env);
5558                 (*env)->FatalError(env, "A call to sign_justice_revoked_output in LDKBaseSign from rust threw an exception.");
5559         }
5560         void* ret_ptr = untag_ptr(ret);
5561         CHECK_ACCESS(ret_ptr);
5562         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
5563         FREE(untag_ptr(ret));
5564         if (get_jenv_res == JNI_EDETACHED) {
5565                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5566         }
5567         return ret_conv;
5568 }
5569 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) {
5570         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
5571         JNIEnv *env;
5572         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5573         if (get_jenv_res == JNI_EDETACHED) {
5574                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5575         } else {
5576                 DO_ASSERT(get_jenv_res == JNI_OK);
5577         }
5578         LDKTransaction justice_tx_var = justice_tx;
5579         int8_tArray justice_tx_arr = (*env)->NewByteArray(env, justice_tx_var.datalen);
5580         (*env)->SetByteArrayRegion(env, justice_tx_arr, 0, justice_tx_var.datalen, justice_tx_var.data);
5581         Transaction_free(justice_tx_var);
5582         int64_t input_conv = input;
5583         int64_t amount_conv = amount;
5584         int8_tArray per_commitment_key_arr = (*env)->NewByteArray(env, 32);
5585         (*env)->SetByteArrayRegion(env, per_commitment_key_arr, 0, 32, *per_commitment_key);
5586         LDKHTLCOutputInCommitment htlc_var = *htlc;
5587         int64_t htlc_ref = 0;
5588         htlc_var = HTLCOutputInCommitment_clone(&htlc_var);
5589         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_var);
5590         htlc_ref = tag_ptr(htlc_var.inner, htlc_var.is_owned);
5591         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5592         CHECK(obj != NULL);
5593         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);
5594         if (UNLIKELY((*env)->ExceptionCheck(env))) {
5595                 (*env)->ExceptionDescribe(env);
5596                 (*env)->FatalError(env, "A call to sign_justice_revoked_htlc in LDKBaseSign from rust threw an exception.");
5597         }
5598         void* ret_ptr = untag_ptr(ret);
5599         CHECK_ACCESS(ret_ptr);
5600         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
5601         FREE(untag_ptr(ret));
5602         if (get_jenv_res == JNI_EDETACHED) {
5603                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5604         }
5605         return ret_conv;
5606 }
5607 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) {
5608         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
5609         JNIEnv *env;
5610         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5611         if (get_jenv_res == JNI_EDETACHED) {
5612                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5613         } else {
5614                 DO_ASSERT(get_jenv_res == JNI_OK);
5615         }
5616         LDKTransaction htlc_tx_var = htlc_tx;
5617         int8_tArray htlc_tx_arr = (*env)->NewByteArray(env, htlc_tx_var.datalen);
5618         (*env)->SetByteArrayRegion(env, htlc_tx_arr, 0, htlc_tx_var.datalen, htlc_tx_var.data);
5619         Transaction_free(htlc_tx_var);
5620         int64_t input_conv = input;
5621         int64_t amount_conv = amount;
5622         int8_tArray per_commitment_point_arr = (*env)->NewByteArray(env, 33);
5623         (*env)->SetByteArrayRegion(env, per_commitment_point_arr, 0, 33, per_commitment_point.compressed_form);
5624         LDKHTLCOutputInCommitment htlc_var = *htlc;
5625         int64_t htlc_ref = 0;
5626         htlc_var = HTLCOutputInCommitment_clone(&htlc_var);
5627         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_var);
5628         htlc_ref = tag_ptr(htlc_var.inner, htlc_var.is_owned);
5629         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5630         CHECK(obj != NULL);
5631         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);
5632         if (UNLIKELY((*env)->ExceptionCheck(env))) {
5633                 (*env)->ExceptionDescribe(env);
5634                 (*env)->FatalError(env, "A call to sign_counterparty_htlc_transaction in LDKBaseSign from rust threw an exception.");
5635         }
5636         void* ret_ptr = untag_ptr(ret);
5637         CHECK_ACCESS(ret_ptr);
5638         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
5639         FREE(untag_ptr(ret));
5640         if (get_jenv_res == JNI_EDETACHED) {
5641                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5642         }
5643         return ret_conv;
5644 }
5645 LDKCResult_SignatureNoneZ sign_closing_transaction_LDKBaseSign_jcall(const void* this_arg, const LDKClosingTransaction * closing_tx) {
5646         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
5647         JNIEnv *env;
5648         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5649         if (get_jenv_res == JNI_EDETACHED) {
5650                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5651         } else {
5652                 DO_ASSERT(get_jenv_res == JNI_OK);
5653         }
5654         LDKClosingTransaction closing_tx_var = *closing_tx;
5655         int64_t closing_tx_ref = 0;
5656         closing_tx_var = ClosingTransaction_clone(&closing_tx_var);
5657         CHECK_INNER_FIELD_ACCESS_OR_NULL(closing_tx_var);
5658         closing_tx_ref = tag_ptr(closing_tx_var.inner, closing_tx_var.is_owned);
5659         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5660         CHECK(obj != NULL);
5661         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->sign_closing_transaction_meth, closing_tx_ref);
5662         if (UNLIKELY((*env)->ExceptionCheck(env))) {
5663                 (*env)->ExceptionDescribe(env);
5664                 (*env)->FatalError(env, "A call to sign_closing_transaction in LDKBaseSign from rust threw an exception.");
5665         }
5666         void* ret_ptr = untag_ptr(ret);
5667         CHECK_ACCESS(ret_ptr);
5668         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
5669         FREE(untag_ptr(ret));
5670         if (get_jenv_res == JNI_EDETACHED) {
5671                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5672         }
5673         return ret_conv;
5674 }
5675 LDKCResult_SignatureNoneZ sign_holder_anchor_input_LDKBaseSign_jcall(const void* this_arg, LDKTransaction anchor_tx, uintptr_t input) {
5676         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
5677         JNIEnv *env;
5678         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5679         if (get_jenv_res == JNI_EDETACHED) {
5680                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5681         } else {
5682                 DO_ASSERT(get_jenv_res == JNI_OK);
5683         }
5684         LDKTransaction anchor_tx_var = anchor_tx;
5685         int8_tArray anchor_tx_arr = (*env)->NewByteArray(env, anchor_tx_var.datalen);
5686         (*env)->SetByteArrayRegion(env, anchor_tx_arr, 0, anchor_tx_var.datalen, anchor_tx_var.data);
5687         Transaction_free(anchor_tx_var);
5688         int64_t input_conv = input;
5689         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5690         CHECK(obj != NULL);
5691         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->sign_holder_anchor_input_meth, anchor_tx_arr, input_conv);
5692         if (UNLIKELY((*env)->ExceptionCheck(env))) {
5693                 (*env)->ExceptionDescribe(env);
5694                 (*env)->FatalError(env, "A call to sign_holder_anchor_input in LDKBaseSign from rust threw an exception.");
5695         }
5696         void* ret_ptr = untag_ptr(ret);
5697         CHECK_ACCESS(ret_ptr);
5698         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
5699         FREE(untag_ptr(ret));
5700         if (get_jenv_res == JNI_EDETACHED) {
5701                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5702         }
5703         return ret_conv;
5704 }
5705 LDKCResult_C2Tuple_SignatureSignatureZNoneZ sign_channel_announcement_LDKBaseSign_jcall(const void* this_arg, const LDKUnsignedChannelAnnouncement * msg) {
5706         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
5707         JNIEnv *env;
5708         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5709         if (get_jenv_res == JNI_EDETACHED) {
5710                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5711         } else {
5712                 DO_ASSERT(get_jenv_res == JNI_OK);
5713         }
5714         LDKUnsignedChannelAnnouncement msg_var = *msg;
5715         int64_t msg_ref = 0;
5716         msg_var = UnsignedChannelAnnouncement_clone(&msg_var);
5717         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
5718         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
5719         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5720         CHECK(obj != NULL);
5721         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->sign_channel_announcement_meth, msg_ref);
5722         if (UNLIKELY((*env)->ExceptionCheck(env))) {
5723                 (*env)->ExceptionDescribe(env);
5724                 (*env)->FatalError(env, "A call to sign_channel_announcement in LDKBaseSign from rust threw an exception.");
5725         }
5726         void* ret_ptr = untag_ptr(ret);
5727         CHECK_ACCESS(ret_ptr);
5728         LDKCResult_C2Tuple_SignatureSignatureZNoneZ ret_conv = *(LDKCResult_C2Tuple_SignatureSignatureZNoneZ*)(ret_ptr);
5729         FREE(untag_ptr(ret));
5730         if (get_jenv_res == JNI_EDETACHED) {
5731                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5732         }
5733         return ret_conv;
5734 }
5735 void provide_channel_parameters_LDKBaseSign_jcall(void* this_arg, const LDKChannelTransactionParameters * channel_parameters) {
5736         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
5737         JNIEnv *env;
5738         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5739         if (get_jenv_res == JNI_EDETACHED) {
5740                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5741         } else {
5742                 DO_ASSERT(get_jenv_res == JNI_OK);
5743         }
5744         LDKChannelTransactionParameters channel_parameters_var = *channel_parameters;
5745         int64_t channel_parameters_ref = 0;
5746         channel_parameters_var = ChannelTransactionParameters_clone(&channel_parameters_var);
5747         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_parameters_var);
5748         channel_parameters_ref = tag_ptr(channel_parameters_var.inner, channel_parameters_var.is_owned);
5749         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5750         CHECK(obj != NULL);
5751         (*env)->CallVoidMethod(env, obj, j_calls->provide_channel_parameters_meth, channel_parameters_ref);
5752         if (UNLIKELY((*env)->ExceptionCheck(env))) {
5753                 (*env)->ExceptionDescribe(env);
5754                 (*env)->FatalError(env, "A call to provide_channel_parameters in LDKBaseSign from rust threw an exception.");
5755         }
5756         if (get_jenv_res == JNI_EDETACHED) {
5757                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5758         }
5759 }
5760 static inline LDKBaseSign LDKBaseSign_init (JNIEnv *env, jclass clz, jobject o, int64_t pubkeys) {
5761         jclass c = (*env)->GetObjectClass(env, o);
5762         CHECK(c != NULL);
5763         LDKBaseSign_JCalls *calls = MALLOC(sizeof(LDKBaseSign_JCalls), "LDKBaseSign_JCalls");
5764         atomic_init(&calls->refcnt, 1);
5765         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
5766         calls->o = (*env)->NewWeakGlobalRef(env, o);
5767         calls->get_per_commitment_point_meth = (*env)->GetMethodID(env, c, "get_per_commitment_point", "(J)[B");
5768         CHECK(calls->get_per_commitment_point_meth != NULL);
5769         calls->release_commitment_secret_meth = (*env)->GetMethodID(env, c, "release_commitment_secret", "(J)[B");
5770         CHECK(calls->release_commitment_secret_meth != NULL);
5771         calls->validate_holder_commitment_meth = (*env)->GetMethodID(env, c, "validate_holder_commitment", "(J[[B)J");
5772         CHECK(calls->validate_holder_commitment_meth != NULL);
5773         calls->channel_keys_id_meth = (*env)->GetMethodID(env, c, "channel_keys_id", "()[B");
5774         CHECK(calls->channel_keys_id_meth != NULL);
5775         calls->sign_counterparty_commitment_meth = (*env)->GetMethodID(env, c, "sign_counterparty_commitment", "(J[[B)J");
5776         CHECK(calls->sign_counterparty_commitment_meth != NULL);
5777         calls->validate_counterparty_revocation_meth = (*env)->GetMethodID(env, c, "validate_counterparty_revocation", "(J[B)J");
5778         CHECK(calls->validate_counterparty_revocation_meth != NULL);
5779         calls->sign_holder_commitment_and_htlcs_meth = (*env)->GetMethodID(env, c, "sign_holder_commitment_and_htlcs", "(J)J");
5780         CHECK(calls->sign_holder_commitment_and_htlcs_meth != NULL);
5781         calls->sign_justice_revoked_output_meth = (*env)->GetMethodID(env, c, "sign_justice_revoked_output", "([BJJ[B)J");
5782         CHECK(calls->sign_justice_revoked_output_meth != NULL);
5783         calls->sign_justice_revoked_htlc_meth = (*env)->GetMethodID(env, c, "sign_justice_revoked_htlc", "([BJJ[BJ)J");
5784         CHECK(calls->sign_justice_revoked_htlc_meth != NULL);
5785         calls->sign_counterparty_htlc_transaction_meth = (*env)->GetMethodID(env, c, "sign_counterparty_htlc_transaction", "([BJJ[BJ)J");
5786         CHECK(calls->sign_counterparty_htlc_transaction_meth != NULL);
5787         calls->sign_closing_transaction_meth = (*env)->GetMethodID(env, c, "sign_closing_transaction", "(J)J");
5788         CHECK(calls->sign_closing_transaction_meth != NULL);
5789         calls->sign_holder_anchor_input_meth = (*env)->GetMethodID(env, c, "sign_holder_anchor_input", "([BJ)J");
5790         CHECK(calls->sign_holder_anchor_input_meth != NULL);
5791         calls->sign_channel_announcement_meth = (*env)->GetMethodID(env, c, "sign_channel_announcement", "(J)J");
5792         CHECK(calls->sign_channel_announcement_meth != NULL);
5793         calls->provide_channel_parameters_meth = (*env)->GetMethodID(env, c, "provide_channel_parameters", "(J)V");
5794         CHECK(calls->provide_channel_parameters_meth != NULL);
5795
5796         LDKChannelPublicKeys pubkeys_conv;
5797         pubkeys_conv.inner = untag_ptr(pubkeys);
5798         pubkeys_conv.is_owned = ptr_is_owned(pubkeys);
5799         CHECK_INNER_FIELD_ACCESS_OR_NULL(pubkeys_conv);
5800
5801         LDKBaseSign ret = {
5802                 .this_arg = (void*) calls,
5803                 .get_per_commitment_point = get_per_commitment_point_LDKBaseSign_jcall,
5804                 .release_commitment_secret = release_commitment_secret_LDKBaseSign_jcall,
5805                 .validate_holder_commitment = validate_holder_commitment_LDKBaseSign_jcall,
5806                 .channel_keys_id = channel_keys_id_LDKBaseSign_jcall,
5807                 .sign_counterparty_commitment = sign_counterparty_commitment_LDKBaseSign_jcall,
5808                 .validate_counterparty_revocation = validate_counterparty_revocation_LDKBaseSign_jcall,
5809                 .sign_holder_commitment_and_htlcs = sign_holder_commitment_and_htlcs_LDKBaseSign_jcall,
5810                 .sign_justice_revoked_output = sign_justice_revoked_output_LDKBaseSign_jcall,
5811                 .sign_justice_revoked_htlc = sign_justice_revoked_htlc_LDKBaseSign_jcall,
5812                 .sign_counterparty_htlc_transaction = sign_counterparty_htlc_transaction_LDKBaseSign_jcall,
5813                 .sign_closing_transaction = sign_closing_transaction_LDKBaseSign_jcall,
5814                 .sign_holder_anchor_input = sign_holder_anchor_input_LDKBaseSign_jcall,
5815                 .sign_channel_announcement = sign_channel_announcement_LDKBaseSign_jcall,
5816                 .provide_channel_parameters = provide_channel_parameters_LDKBaseSign_jcall,
5817                 .free = LDKBaseSign_JCalls_free,
5818                 .pubkeys = pubkeys_conv,
5819                 .set_pubkeys = NULL,
5820         };
5821         return ret;
5822 }
5823 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKBaseSign_1new(JNIEnv *env, jclass clz, jobject o, int64_t pubkeys) {
5824         LDKBaseSign *res_ptr = MALLOC(sizeof(LDKBaseSign), "LDKBaseSign");
5825         *res_ptr = LDKBaseSign_init(env, clz, o, pubkeys);
5826         return tag_ptr(res_ptr, true);
5827 }
5828 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) {
5829         void* this_arg_ptr = untag_ptr(this_arg);
5830         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
5831         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
5832         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
5833         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, (this_arg_conv->get_per_commitment_point)(this_arg_conv->this_arg, idx).compressed_form);
5834         return ret_arr;
5835 }
5836
5837 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BaseSign_1release_1commitment_1secret(JNIEnv *env, jclass clz, int64_t this_arg, int64_t idx) {
5838         void* this_arg_ptr = untag_ptr(this_arg);
5839         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
5840         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
5841         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
5842         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, (this_arg_conv->release_commitment_secret)(this_arg_conv->this_arg, idx).data);
5843         return ret_arr;
5844 }
5845
5846 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) {
5847         void* this_arg_ptr = untag_ptr(this_arg);
5848         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
5849         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
5850         LDKHolderCommitmentTransaction holder_tx_conv;
5851         holder_tx_conv.inner = untag_ptr(holder_tx);
5852         holder_tx_conv.is_owned = ptr_is_owned(holder_tx);
5853         CHECK_INNER_FIELD_ACCESS_OR_NULL(holder_tx_conv);
5854         holder_tx_conv.is_owned = false;
5855         LDKCVec_PaymentPreimageZ preimages_constr;
5856         preimages_constr.datalen = (*env)->GetArrayLength(env, preimages);
5857         if (preimages_constr.datalen > 0)
5858                 preimages_constr.data = MALLOC(preimages_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_PaymentPreimageZ Elements");
5859         else
5860                 preimages_constr.data = NULL;
5861         for (size_t i = 0; i < preimages_constr.datalen; i++) {
5862                 int8_tArray preimages_conv_8 = (*env)->GetObjectArrayElement(env, preimages, i);
5863                 LDKThirtyTwoBytes preimages_conv_8_ref;
5864                 CHECK((*env)->GetArrayLength(env, preimages_conv_8) == 32);
5865                 (*env)->GetByteArrayRegion(env, preimages_conv_8, 0, 32, preimages_conv_8_ref.data);
5866                 preimages_constr.data[i] = preimages_conv_8_ref;
5867         }
5868         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
5869         *ret_conv = (this_arg_conv->validate_holder_commitment)(this_arg_conv->this_arg, &holder_tx_conv, preimages_constr);
5870         return tag_ptr(ret_conv, true);
5871 }
5872
5873 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BaseSign_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
5874         void* this_arg_ptr = untag_ptr(this_arg);
5875         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
5876         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
5877         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
5878         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, (this_arg_conv->channel_keys_id)(this_arg_conv->this_arg).data);
5879         return ret_arr;
5880 }
5881
5882 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) {
5883         void* this_arg_ptr = untag_ptr(this_arg);
5884         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
5885         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
5886         LDKCommitmentTransaction commitment_tx_conv;
5887         commitment_tx_conv.inner = untag_ptr(commitment_tx);
5888         commitment_tx_conv.is_owned = ptr_is_owned(commitment_tx);
5889         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_conv);
5890         commitment_tx_conv.is_owned = false;
5891         LDKCVec_PaymentPreimageZ preimages_constr;
5892         preimages_constr.datalen = (*env)->GetArrayLength(env, preimages);
5893         if (preimages_constr.datalen > 0)
5894                 preimages_constr.data = MALLOC(preimages_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_PaymentPreimageZ Elements");
5895         else
5896                 preimages_constr.data = NULL;
5897         for (size_t i = 0; i < preimages_constr.datalen; i++) {
5898                 int8_tArray preimages_conv_8 = (*env)->GetObjectArrayElement(env, preimages, i);
5899                 LDKThirtyTwoBytes preimages_conv_8_ref;
5900                 CHECK((*env)->GetArrayLength(env, preimages_conv_8) == 32);
5901                 (*env)->GetByteArrayRegion(env, preimages_conv_8, 0, 32, preimages_conv_8_ref.data);
5902                 preimages_constr.data[i] = preimages_conv_8_ref;
5903         }
5904         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
5905         *ret_conv = (this_arg_conv->sign_counterparty_commitment)(this_arg_conv->this_arg, &commitment_tx_conv, preimages_constr);
5906         return tag_ptr(ret_conv, true);
5907 }
5908
5909 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) {
5910         void* this_arg_ptr = untag_ptr(this_arg);
5911         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
5912         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
5913         unsigned char secret_arr[32];
5914         CHECK((*env)->GetArrayLength(env, secret) == 32);
5915         (*env)->GetByteArrayRegion(env, secret, 0, 32, secret_arr);
5916         unsigned char (*secret_ref)[32] = &secret_arr;
5917         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
5918         *ret_conv = (this_arg_conv->validate_counterparty_revocation)(this_arg_conv->this_arg, idx, secret_ref);
5919         return tag_ptr(ret_conv, true);
5920 }
5921
5922 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) {
5923         void* this_arg_ptr = untag_ptr(this_arg);
5924         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
5925         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
5926         LDKHolderCommitmentTransaction commitment_tx_conv;
5927         commitment_tx_conv.inner = untag_ptr(commitment_tx);
5928         commitment_tx_conv.is_owned = ptr_is_owned(commitment_tx);
5929         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_conv);
5930         commitment_tx_conv.is_owned = false;
5931         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
5932         *ret_conv = (this_arg_conv->sign_holder_commitment_and_htlcs)(this_arg_conv->this_arg, &commitment_tx_conv);
5933         return tag_ptr(ret_conv, true);
5934 }
5935
5936 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) {
5937         void* this_arg_ptr = untag_ptr(this_arg);
5938         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
5939         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
5940         LDKTransaction justice_tx_ref;
5941         justice_tx_ref.datalen = (*env)->GetArrayLength(env, justice_tx);
5942         justice_tx_ref.data = MALLOC(justice_tx_ref.datalen, "LDKTransaction Bytes");
5943         (*env)->GetByteArrayRegion(env, justice_tx, 0, justice_tx_ref.datalen, justice_tx_ref.data);
5944         justice_tx_ref.data_is_owned = true;
5945         unsigned char per_commitment_key_arr[32];
5946         CHECK((*env)->GetArrayLength(env, per_commitment_key) == 32);
5947         (*env)->GetByteArrayRegion(env, per_commitment_key, 0, 32, per_commitment_key_arr);
5948         unsigned char (*per_commitment_key_ref)[32] = &per_commitment_key_arr;
5949         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
5950         *ret_conv = (this_arg_conv->sign_justice_revoked_output)(this_arg_conv->this_arg, justice_tx_ref, input, amount, per_commitment_key_ref);
5951         return tag_ptr(ret_conv, true);
5952 }
5953
5954 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) {
5955         void* this_arg_ptr = untag_ptr(this_arg);
5956         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
5957         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
5958         LDKTransaction justice_tx_ref;
5959         justice_tx_ref.datalen = (*env)->GetArrayLength(env, justice_tx);
5960         justice_tx_ref.data = MALLOC(justice_tx_ref.datalen, "LDKTransaction Bytes");
5961         (*env)->GetByteArrayRegion(env, justice_tx, 0, justice_tx_ref.datalen, justice_tx_ref.data);
5962         justice_tx_ref.data_is_owned = true;
5963         unsigned char per_commitment_key_arr[32];
5964         CHECK((*env)->GetArrayLength(env, per_commitment_key) == 32);
5965         (*env)->GetByteArrayRegion(env, per_commitment_key, 0, 32, per_commitment_key_arr);
5966         unsigned char (*per_commitment_key_ref)[32] = &per_commitment_key_arr;
5967         LDKHTLCOutputInCommitment htlc_conv;
5968         htlc_conv.inner = untag_ptr(htlc);
5969         htlc_conv.is_owned = ptr_is_owned(htlc);
5970         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_conv);
5971         htlc_conv.is_owned = false;
5972         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
5973         *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);
5974         return tag_ptr(ret_conv, true);
5975 }
5976
5977 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) {
5978         void* this_arg_ptr = untag_ptr(this_arg);
5979         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
5980         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
5981         LDKTransaction htlc_tx_ref;
5982         htlc_tx_ref.datalen = (*env)->GetArrayLength(env, htlc_tx);
5983         htlc_tx_ref.data = MALLOC(htlc_tx_ref.datalen, "LDKTransaction Bytes");
5984         (*env)->GetByteArrayRegion(env, htlc_tx, 0, htlc_tx_ref.datalen, htlc_tx_ref.data);
5985         htlc_tx_ref.data_is_owned = true;
5986         LDKPublicKey per_commitment_point_ref;
5987         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
5988         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
5989         LDKHTLCOutputInCommitment htlc_conv;
5990         htlc_conv.inner = untag_ptr(htlc);
5991         htlc_conv.is_owned = ptr_is_owned(htlc);
5992         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_conv);
5993         htlc_conv.is_owned = false;
5994         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
5995         *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);
5996         return tag_ptr(ret_conv, true);
5997 }
5998
5999 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) {
6000         void* this_arg_ptr = untag_ptr(this_arg);
6001         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
6002         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
6003         LDKClosingTransaction closing_tx_conv;
6004         closing_tx_conv.inner = untag_ptr(closing_tx);
6005         closing_tx_conv.is_owned = ptr_is_owned(closing_tx);
6006         CHECK_INNER_FIELD_ACCESS_OR_NULL(closing_tx_conv);
6007         closing_tx_conv.is_owned = false;
6008         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
6009         *ret_conv = (this_arg_conv->sign_closing_transaction)(this_arg_conv->this_arg, &closing_tx_conv);
6010         return tag_ptr(ret_conv, true);
6011 }
6012
6013 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) {
6014         void* this_arg_ptr = untag_ptr(this_arg);
6015         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
6016         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
6017         LDKTransaction anchor_tx_ref;
6018         anchor_tx_ref.datalen = (*env)->GetArrayLength(env, anchor_tx);
6019         anchor_tx_ref.data = MALLOC(anchor_tx_ref.datalen, "LDKTransaction Bytes");
6020         (*env)->GetByteArrayRegion(env, anchor_tx, 0, anchor_tx_ref.datalen, anchor_tx_ref.data);
6021         anchor_tx_ref.data_is_owned = true;
6022         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
6023         *ret_conv = (this_arg_conv->sign_holder_anchor_input)(this_arg_conv->this_arg, anchor_tx_ref, input);
6024         return tag_ptr(ret_conv, true);
6025 }
6026
6027 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BaseSign_1sign_1channel_1announcement(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
6028         void* this_arg_ptr = untag_ptr(this_arg);
6029         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
6030         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
6031         LDKUnsignedChannelAnnouncement msg_conv;
6032         msg_conv.inner = untag_ptr(msg);
6033         msg_conv.is_owned = ptr_is_owned(msg);
6034         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
6035         msg_conv.is_owned = false;
6036         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureSignatureZNoneZ), "LDKCResult_C2Tuple_SignatureSignatureZNoneZ");
6037         *ret_conv = (this_arg_conv->sign_channel_announcement)(this_arg_conv->this_arg, &msg_conv);
6038         return tag_ptr(ret_conv, true);
6039 }
6040
6041 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BaseSign_1provide_1channel_1parameters(JNIEnv *env, jclass clz, int64_t this_arg, int64_t channel_parameters) {
6042         void* this_arg_ptr = untag_ptr(this_arg);
6043         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
6044         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
6045         LDKChannelTransactionParameters channel_parameters_conv;
6046         channel_parameters_conv.inner = untag_ptr(channel_parameters);
6047         channel_parameters_conv.is_owned = ptr_is_owned(channel_parameters);
6048         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_parameters_conv);
6049         channel_parameters_conv.is_owned = false;
6050         (this_arg_conv->provide_channel_parameters)(this_arg_conv->this_arg, &channel_parameters_conv);
6051 }
6052
6053 LDKChannelPublicKeys LDKBaseSign_set_get_pubkeys(LDKBaseSign* this_arg) {
6054         if (this_arg->set_pubkeys != NULL)
6055                 this_arg->set_pubkeys(this_arg);
6056         return this_arg->pubkeys;
6057 }
6058 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BaseSign_1get_1pubkeys(JNIEnv *env, jclass clz, int64_t this_arg) {
6059         void* this_arg_ptr = untag_ptr(this_arg);
6060         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
6061         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
6062         LDKChannelPublicKeys ret_var = LDKBaseSign_set_get_pubkeys(this_arg_conv);
6063         int64_t ret_ref = 0;
6064         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6065         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
6066         return ret_ref;
6067 }
6068
6069 typedef struct LDKSign_JCalls {
6070         atomic_size_t refcnt;
6071         JavaVM *vm;
6072         jweak o;
6073         LDKBaseSign_JCalls* BaseSign;
6074         jmethodID write_meth;
6075 } LDKSign_JCalls;
6076 static void LDKSign_JCalls_free(void* this_arg) {
6077         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
6078         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
6079                 JNIEnv *env;
6080                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6081                 if (get_jenv_res == JNI_EDETACHED) {
6082                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6083                 } else {
6084                         DO_ASSERT(get_jenv_res == JNI_OK);
6085                 }
6086                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
6087                 if (get_jenv_res == JNI_EDETACHED) {
6088                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6089                 }
6090                 FREE(j_calls);
6091         }
6092 }
6093 LDKCVec_u8Z write_LDKSign_jcall(const void* this_arg) {
6094         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
6095         JNIEnv *env;
6096         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6097         if (get_jenv_res == JNI_EDETACHED) {
6098                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6099         } else {
6100                 DO_ASSERT(get_jenv_res == JNI_OK);
6101         }
6102         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6103         CHECK(obj != NULL);
6104         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->write_meth);
6105         if (UNLIKELY((*env)->ExceptionCheck(env))) {
6106                 (*env)->ExceptionDescribe(env);
6107                 (*env)->FatalError(env, "A call to write in LDKSign from rust threw an exception.");
6108         }
6109         LDKCVec_u8Z ret_ref;
6110         ret_ref.datalen = (*env)->GetArrayLength(env, ret);
6111         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
6112         (*env)->GetByteArrayRegion(env, ret, 0, ret_ref.datalen, ret_ref.data);
6113         if (get_jenv_res == JNI_EDETACHED) {
6114                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6115         }
6116         return ret_ref;
6117 }
6118 static void LDKSign_JCalls_cloned(LDKSign* new_obj) {
6119         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) new_obj->this_arg;
6120         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
6121         atomic_fetch_add_explicit(&j_calls->BaseSign->refcnt, 1, memory_order_release);
6122 }
6123 static inline LDKSign LDKSign_init (JNIEnv *env, jclass clz, jobject o, jobject BaseSign, int64_t pubkeys) {
6124         jclass c = (*env)->GetObjectClass(env, o);
6125         CHECK(c != NULL);
6126         LDKSign_JCalls *calls = MALLOC(sizeof(LDKSign_JCalls), "LDKSign_JCalls");
6127         atomic_init(&calls->refcnt, 1);
6128         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
6129         calls->o = (*env)->NewWeakGlobalRef(env, o);
6130         calls->write_meth = (*env)->GetMethodID(env, c, "write", "()[B");
6131         CHECK(calls->write_meth != NULL);
6132
6133         LDKChannelPublicKeys pubkeys_conv;
6134         pubkeys_conv.inner = untag_ptr(pubkeys);
6135         pubkeys_conv.is_owned = ptr_is_owned(pubkeys);
6136         CHECK_INNER_FIELD_ACCESS_OR_NULL(pubkeys_conv);
6137
6138         LDKSign ret = {
6139                 .this_arg = (void*) calls,
6140                 .write = write_LDKSign_jcall,
6141                 .cloned = LDKSign_JCalls_cloned,
6142                 .free = LDKSign_JCalls_free,
6143                 .BaseSign = LDKBaseSign_init(env, clz, BaseSign, pubkeys),
6144         };
6145         calls->BaseSign = ret.BaseSign.this_arg;
6146         return ret;
6147 }
6148 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKSign_1new(JNIEnv *env, jclass clz, jobject o, jobject BaseSign, int64_t pubkeys) {
6149         LDKSign *res_ptr = MALLOC(sizeof(LDKSign), "LDKSign");
6150         *res_ptr = LDKSign_init(env, clz, o, BaseSign, pubkeys);
6151         return tag_ptr(res_ptr, true);
6152 }
6153 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKSign_1get_1BaseSign(JNIEnv *env, jclass clz, int64_t arg) {
6154         LDKSign *inp = (LDKSign *)untag_ptr(arg);
6155         return tag_ptr(&inp->BaseSign, false);
6156 }
6157 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Sign_1write(JNIEnv *env, jclass clz, int64_t this_arg) {
6158         void* this_arg_ptr = untag_ptr(this_arg);
6159         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
6160         LDKSign* this_arg_conv = (LDKSign*)this_arg_ptr;
6161         LDKCVec_u8Z ret_var = (this_arg_conv->write)(this_arg_conv->this_arg);
6162         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
6163         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
6164         CVec_u8Z_free(ret_var);
6165         return ret_arr;
6166 }
6167
6168 static inline struct LDKSign CResult_SignDecodeErrorZ_get_ok(LDKCResult_SignDecodeErrorZ *NONNULL_PTR owner){
6169 CHECK(owner->result_ok);
6170         return Sign_clone(&*owner->contents.result);
6171 }
6172 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6173         LDKCResult_SignDecodeErrorZ* owner_conv = (LDKCResult_SignDecodeErrorZ*)untag_ptr(owner);
6174         LDKSign* ret_ret = MALLOC(sizeof(LDKSign), "LDKSign");
6175         *ret_ret = CResult_SignDecodeErrorZ_get_ok(owner_conv);
6176         return tag_ptr(ret_ret, true);
6177 }
6178
6179 static inline struct LDKDecodeError CResult_SignDecodeErrorZ_get_err(LDKCResult_SignDecodeErrorZ *NONNULL_PTR owner){
6180 CHECK(!owner->result_ok);
6181         return DecodeError_clone(&*owner->contents.err);
6182 }
6183 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6184         LDKCResult_SignDecodeErrorZ* owner_conv = (LDKCResult_SignDecodeErrorZ*)untag_ptr(owner);
6185         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
6186         *ret_copy = CResult_SignDecodeErrorZ_get_err(owner_conv);
6187         int64_t ret_ref = tag_ptr(ret_copy, true);
6188         return ret_ref;
6189 }
6190
6191 static inline struct LDKRecoverableSignature CResult_RecoverableSignatureNoneZ_get_ok(LDKCResult_RecoverableSignatureNoneZ *NONNULL_PTR owner){
6192 CHECK(owner->result_ok);
6193         return *owner->contents.result;
6194 }
6195 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6196         LDKCResult_RecoverableSignatureNoneZ* owner_conv = (LDKCResult_RecoverableSignatureNoneZ*)untag_ptr(owner);
6197         int8_tArray ret_arr = (*env)->NewByteArray(env, 68);
6198         (*env)->SetByteArrayRegion(env, ret_arr, 0, 68, CResult_RecoverableSignatureNoneZ_get_ok(owner_conv).serialized_form);
6199         return ret_arr;
6200 }
6201
6202 static inline void CResult_RecoverableSignatureNoneZ_get_err(LDKCResult_RecoverableSignatureNoneZ *NONNULL_PTR owner){
6203 CHECK(!owner->result_ok);
6204         return *owner->contents.err;
6205 }
6206 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6207         LDKCResult_RecoverableSignatureNoneZ* owner_conv = (LDKCResult_RecoverableSignatureNoneZ*)untag_ptr(owner);
6208         CResult_RecoverableSignatureNoneZ_get_err(owner_conv);
6209 }
6210
6211 static inline LDKCVec_CVec_u8ZZ CVec_CVec_u8ZZ_clone(const LDKCVec_CVec_u8ZZ *orig) {
6212         LDKCVec_CVec_u8ZZ ret = { .data = MALLOC(sizeof(LDKCVec_u8Z) * orig->datalen, "LDKCVec_CVec_u8ZZ clone bytes"), .datalen = orig->datalen };
6213         for (size_t i = 0; i < ret.datalen; i++) {
6214                 ret.data[i] = CVec_u8Z_clone(&orig->data[i]);
6215         }
6216         return ret;
6217 }
6218 static inline struct LDKCVec_CVec_u8ZZ CResult_CVec_CVec_u8ZZNoneZ_get_ok(LDKCResult_CVec_CVec_u8ZZNoneZ *NONNULL_PTR owner){
6219 CHECK(owner->result_ok);
6220         return CVec_CVec_u8ZZ_clone(&*owner->contents.result);
6221 }
6222 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6223         LDKCResult_CVec_CVec_u8ZZNoneZ* owner_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)untag_ptr(owner);
6224         LDKCVec_CVec_u8ZZ ret_var = CResult_CVec_CVec_u8ZZNoneZ_get_ok(owner_conv);
6225         jobjectArray ret_arr = NULL;
6226         ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
6227         ;
6228         for (size_t i = 0; i < ret_var.datalen; i++) {
6229                 LDKCVec_u8Z ret_conv_8_var = ret_var.data[i];
6230                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, ret_conv_8_var.datalen);
6231                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, ret_conv_8_var.datalen, ret_conv_8_var.data);
6232                 CVec_u8Z_free(ret_conv_8_var);
6233                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
6234         }
6235         
6236         FREE(ret_var.data);
6237         return ret_arr;
6238 }
6239
6240 static inline void CResult_CVec_CVec_u8ZZNoneZ_get_err(LDKCResult_CVec_CVec_u8ZZNoneZ *NONNULL_PTR owner){
6241 CHECK(!owner->result_ok);
6242         return *owner->contents.err;
6243 }
6244 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6245         LDKCResult_CVec_CVec_u8ZZNoneZ* owner_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)untag_ptr(owner);
6246         CResult_CVec_CVec_u8ZZNoneZ_get_err(owner_conv);
6247 }
6248
6249 static inline struct LDKInMemorySigner CResult_InMemorySignerDecodeErrorZ_get_ok(LDKCResult_InMemorySignerDecodeErrorZ *NONNULL_PTR owner){
6250         LDKInMemorySigner ret = *owner->contents.result;
6251         ret.is_owned = false;
6252         return ret;
6253 }
6254 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6255         LDKCResult_InMemorySignerDecodeErrorZ* owner_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)untag_ptr(owner);
6256         LDKInMemorySigner ret_var = CResult_InMemorySignerDecodeErrorZ_get_ok(owner_conv);
6257         int64_t ret_ref = 0;
6258         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6259         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
6260         return ret_ref;
6261 }
6262
6263 static inline struct LDKDecodeError CResult_InMemorySignerDecodeErrorZ_get_err(LDKCResult_InMemorySignerDecodeErrorZ *NONNULL_PTR owner){
6264 CHECK(!owner->result_ok);
6265         return DecodeError_clone(&*owner->contents.err);
6266 }
6267 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6268         LDKCResult_InMemorySignerDecodeErrorZ* owner_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)untag_ptr(owner);
6269         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
6270         *ret_copy = CResult_InMemorySignerDecodeErrorZ_get_err(owner_conv);
6271         int64_t ret_ref = tag_ptr(ret_copy, true);
6272         return ret_ref;
6273 }
6274
6275 static inline LDKCVec_TxOutZ CVec_TxOutZ_clone(const LDKCVec_TxOutZ *orig) {
6276         LDKCVec_TxOutZ ret = { .data = MALLOC(sizeof(LDKTxOut) * orig->datalen, "LDKCVec_TxOutZ clone bytes"), .datalen = orig->datalen };
6277         for (size_t i = 0; i < ret.datalen; i++) {
6278                 ret.data[i] = TxOut_clone(&orig->data[i]);
6279         }
6280         return ret;
6281 }
6282 static inline struct LDKTransaction CResult_TransactionNoneZ_get_ok(LDKCResult_TransactionNoneZ *NONNULL_PTR owner){
6283 CHECK(owner->result_ok);
6284         return *owner->contents.result;
6285 }
6286 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6287         LDKCResult_TransactionNoneZ* owner_conv = (LDKCResult_TransactionNoneZ*)untag_ptr(owner);
6288         LDKTransaction ret_var = CResult_TransactionNoneZ_get_ok(owner_conv);
6289         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
6290         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
6291         return ret_arr;
6292 }
6293
6294 static inline void CResult_TransactionNoneZ_get_err(LDKCResult_TransactionNoneZ *NONNULL_PTR owner){
6295 CHECK(!owner->result_ok);
6296         return *owner->contents.err;
6297 }
6298 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6299         LDKCResult_TransactionNoneZ* owner_conv = (LDKCResult_TransactionNoneZ*)untag_ptr(owner);
6300         CResult_TransactionNoneZ_get_err(owner_conv);
6301 }
6302
6303 static inline struct LDKThirtyTwoBytes C2Tuple_BlockHashChannelMonitorZ_get_a(LDKC2Tuple_BlockHashChannelMonitorZ *NONNULL_PTR owner){
6304         return ThirtyTwoBytes_clone(&owner->a);
6305 }
6306 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
6307         LDKC2Tuple_BlockHashChannelMonitorZ* owner_conv = (LDKC2Tuple_BlockHashChannelMonitorZ*)untag_ptr(owner);
6308         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
6309         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_BlockHashChannelMonitorZ_get_a(owner_conv).data);
6310         return ret_arr;
6311 }
6312
6313 static inline struct LDKChannelMonitor C2Tuple_BlockHashChannelMonitorZ_get_b(LDKC2Tuple_BlockHashChannelMonitorZ *NONNULL_PTR owner){
6314         LDKChannelMonitor ret = owner->b;
6315         ret.is_owned = false;
6316         return ret;
6317 }
6318 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
6319         LDKC2Tuple_BlockHashChannelMonitorZ* owner_conv = (LDKC2Tuple_BlockHashChannelMonitorZ*)untag_ptr(owner);
6320         LDKChannelMonitor ret_var = C2Tuple_BlockHashChannelMonitorZ_get_b(owner_conv);
6321         int64_t ret_ref = 0;
6322         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6323         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
6324         return ret_ref;
6325 }
6326
6327 static inline LDKCVec_C2Tuple_BlockHashChannelMonitorZZ CVec_C2Tuple_BlockHashChannelMonitorZZ_clone(const LDKCVec_C2Tuple_BlockHashChannelMonitorZZ *orig) {
6328         LDKCVec_C2Tuple_BlockHashChannelMonitorZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ) * orig->datalen, "LDKCVec_C2Tuple_BlockHashChannelMonitorZZ clone bytes"), .datalen = orig->datalen };
6329         for (size_t i = 0; i < ret.datalen; i++) {
6330                 ret.data[i] = C2Tuple_BlockHashChannelMonitorZ_clone(&orig->data[i]);
6331         }
6332         return ret;
6333 }
6334 static inline struct LDKCVec_C2Tuple_BlockHashChannelMonitorZZ CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_get_ok(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ *NONNULL_PTR owner){
6335 CHECK(owner->result_ok);
6336         return CVec_C2Tuple_BlockHashChannelMonitorZZ_clone(&*owner->contents.result);
6337 }
6338 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6339         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* owner_conv = (LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)untag_ptr(owner);
6340         LDKCVec_C2Tuple_BlockHashChannelMonitorZZ ret_var = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_get_ok(owner_conv);
6341         int64_tArray ret_arr = NULL;
6342         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
6343         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
6344         for (size_t j = 0; j < ret_var.datalen; j++) {
6345                 LDKC2Tuple_BlockHashChannelMonitorZ* ret_conv_35_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
6346                 *ret_conv_35_conv = ret_var.data[j];
6347                 ret_arr_ptr[j] = tag_ptr(ret_conv_35_conv, true);
6348         }
6349         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
6350         FREE(ret_var.data);
6351         return ret_arr;
6352 }
6353
6354 static inline enum LDKIOError CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_get_err(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ *NONNULL_PTR owner){
6355 CHECK(!owner->result_ok);
6356         return *owner->contents.err;
6357 }
6358 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6359         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* owner_conv = (LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)untag_ptr(owner);
6360         jclass ret_conv = LDKIOError_to_java(env, CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_get_err(owner_conv));
6361         return ret_conv;
6362 }
6363
6364 static jclass LDKCOption_u16Z_Some_class = NULL;
6365 static jmethodID LDKCOption_u16Z_Some_meth = NULL;
6366 static jclass LDKCOption_u16Z_None_class = NULL;
6367 static jmethodID LDKCOption_u16Z_None_meth = NULL;
6368 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1u16Z_init (JNIEnv *env, jclass clz) {
6369         LDKCOption_u16Z_Some_class =
6370                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_u16Z$Some"));
6371         CHECK(LDKCOption_u16Z_Some_class != NULL);
6372         LDKCOption_u16Z_Some_meth = (*env)->GetMethodID(env, LDKCOption_u16Z_Some_class, "<init>", "(S)V");
6373         CHECK(LDKCOption_u16Z_Some_meth != NULL);
6374         LDKCOption_u16Z_None_class =
6375                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_u16Z$None"));
6376         CHECK(LDKCOption_u16Z_None_class != NULL);
6377         LDKCOption_u16Z_None_meth = (*env)->GetMethodID(env, LDKCOption_u16Z_None_class, "<init>", "()V");
6378         CHECK(LDKCOption_u16Z_None_meth != NULL);
6379 }
6380 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1u16Z_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
6381         LDKCOption_u16Z *obj = (LDKCOption_u16Z*)untag_ptr(ptr);
6382         switch(obj->tag) {
6383                 case LDKCOption_u16Z_Some: {
6384                         int16_t some_conv = obj->some;
6385                         return (*env)->NewObject(env, LDKCOption_u16Z_Some_class, LDKCOption_u16Z_Some_meth, some_conv);
6386                 }
6387                 case LDKCOption_u16Z_None: {
6388                         return (*env)->NewObject(env, LDKCOption_u16Z_None_class, LDKCOption_u16Z_None_meth);
6389                 }
6390                 default: abort();
6391         }
6392 }
6393 static jclass LDKAPIError_APIMisuseError_class = NULL;
6394 static jmethodID LDKAPIError_APIMisuseError_meth = NULL;
6395 static jclass LDKAPIError_FeeRateTooHigh_class = NULL;
6396 static jmethodID LDKAPIError_FeeRateTooHigh_meth = NULL;
6397 static jclass LDKAPIError_InvalidRoute_class = NULL;
6398 static jmethodID LDKAPIError_InvalidRoute_meth = NULL;
6399 static jclass LDKAPIError_ChannelUnavailable_class = NULL;
6400 static jmethodID LDKAPIError_ChannelUnavailable_meth = NULL;
6401 static jclass LDKAPIError_MonitorUpdateInProgress_class = NULL;
6402 static jmethodID LDKAPIError_MonitorUpdateInProgress_meth = NULL;
6403 static jclass LDKAPIError_IncompatibleShutdownScript_class = NULL;
6404 static jmethodID LDKAPIError_IncompatibleShutdownScript_meth = NULL;
6405 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKAPIError_init (JNIEnv *env, jclass clz) {
6406         LDKAPIError_APIMisuseError_class =
6407                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKAPIError$APIMisuseError"));
6408         CHECK(LDKAPIError_APIMisuseError_class != NULL);
6409         LDKAPIError_APIMisuseError_meth = (*env)->GetMethodID(env, LDKAPIError_APIMisuseError_class, "<init>", "(Ljava/lang/String;)V");
6410         CHECK(LDKAPIError_APIMisuseError_meth != NULL);
6411         LDKAPIError_FeeRateTooHigh_class =
6412                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKAPIError$FeeRateTooHigh"));
6413         CHECK(LDKAPIError_FeeRateTooHigh_class != NULL);
6414         LDKAPIError_FeeRateTooHigh_meth = (*env)->GetMethodID(env, LDKAPIError_FeeRateTooHigh_class, "<init>", "(Ljava/lang/String;I)V");
6415         CHECK(LDKAPIError_FeeRateTooHigh_meth != NULL);
6416         LDKAPIError_InvalidRoute_class =
6417                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKAPIError$InvalidRoute"));
6418         CHECK(LDKAPIError_InvalidRoute_class != NULL);
6419         LDKAPIError_InvalidRoute_meth = (*env)->GetMethodID(env, LDKAPIError_InvalidRoute_class, "<init>", "(Ljava/lang/String;)V");
6420         CHECK(LDKAPIError_InvalidRoute_meth != NULL);
6421         LDKAPIError_ChannelUnavailable_class =
6422                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKAPIError$ChannelUnavailable"));
6423         CHECK(LDKAPIError_ChannelUnavailable_class != NULL);
6424         LDKAPIError_ChannelUnavailable_meth = (*env)->GetMethodID(env, LDKAPIError_ChannelUnavailable_class, "<init>", "(Ljava/lang/String;)V");
6425         CHECK(LDKAPIError_ChannelUnavailable_meth != NULL);
6426         LDKAPIError_MonitorUpdateInProgress_class =
6427                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKAPIError$MonitorUpdateInProgress"));
6428         CHECK(LDKAPIError_MonitorUpdateInProgress_class != NULL);
6429         LDKAPIError_MonitorUpdateInProgress_meth = (*env)->GetMethodID(env, LDKAPIError_MonitorUpdateInProgress_class, "<init>", "()V");
6430         CHECK(LDKAPIError_MonitorUpdateInProgress_meth != NULL);
6431         LDKAPIError_IncompatibleShutdownScript_class =
6432                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKAPIError$IncompatibleShutdownScript"));
6433         CHECK(LDKAPIError_IncompatibleShutdownScript_class != NULL);
6434         LDKAPIError_IncompatibleShutdownScript_meth = (*env)->GetMethodID(env, LDKAPIError_IncompatibleShutdownScript_class, "<init>", "(J)V");
6435         CHECK(LDKAPIError_IncompatibleShutdownScript_meth != NULL);
6436 }
6437 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKAPIError_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
6438         LDKAPIError *obj = (LDKAPIError*)untag_ptr(ptr);
6439         switch(obj->tag) {
6440                 case LDKAPIError_APIMisuseError: {
6441                         LDKStr err_str = obj->api_misuse_error.err;
6442                         jstring err_conv = str_ref_to_java(env, err_str.chars, err_str.len);
6443                         return (*env)->NewObject(env, LDKAPIError_APIMisuseError_class, LDKAPIError_APIMisuseError_meth, err_conv);
6444                 }
6445                 case LDKAPIError_FeeRateTooHigh: {
6446                         LDKStr err_str = obj->fee_rate_too_high.err;
6447                         jstring err_conv = str_ref_to_java(env, err_str.chars, err_str.len);
6448                         int32_t feerate_conv = obj->fee_rate_too_high.feerate;
6449                         return (*env)->NewObject(env, LDKAPIError_FeeRateTooHigh_class, LDKAPIError_FeeRateTooHigh_meth, err_conv, feerate_conv);
6450                 }
6451                 case LDKAPIError_InvalidRoute: {
6452                         LDKStr err_str = obj->invalid_route.err;
6453                         jstring err_conv = str_ref_to_java(env, err_str.chars, err_str.len);
6454                         return (*env)->NewObject(env, LDKAPIError_InvalidRoute_class, LDKAPIError_InvalidRoute_meth, err_conv);
6455                 }
6456                 case LDKAPIError_ChannelUnavailable: {
6457                         LDKStr err_str = obj->channel_unavailable.err;
6458                         jstring err_conv = str_ref_to_java(env, err_str.chars, err_str.len);
6459                         return (*env)->NewObject(env, LDKAPIError_ChannelUnavailable_class, LDKAPIError_ChannelUnavailable_meth, err_conv);
6460                 }
6461                 case LDKAPIError_MonitorUpdateInProgress: {
6462                         return (*env)->NewObject(env, LDKAPIError_MonitorUpdateInProgress_class, LDKAPIError_MonitorUpdateInProgress_meth);
6463                 }
6464                 case LDKAPIError_IncompatibleShutdownScript: {
6465                         LDKShutdownScript script_var = obj->incompatible_shutdown_script.script;
6466                         int64_t script_ref = 0;
6467                         CHECK_INNER_FIELD_ACCESS_OR_NULL(script_var);
6468                         script_ref = tag_ptr(script_var.inner, false);
6469                         return (*env)->NewObject(env, LDKAPIError_IncompatibleShutdownScript_class, LDKAPIError_IncompatibleShutdownScript_meth, script_ref);
6470                 }
6471                 default: abort();
6472         }
6473 }
6474 static inline void CResult_NoneAPIErrorZ_get_ok(LDKCResult_NoneAPIErrorZ *NONNULL_PTR owner){
6475 CHECK(owner->result_ok);
6476         return *owner->contents.result;
6477 }
6478 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6479         LDKCResult_NoneAPIErrorZ* owner_conv = (LDKCResult_NoneAPIErrorZ*)untag_ptr(owner);
6480         CResult_NoneAPIErrorZ_get_ok(owner_conv);
6481 }
6482
6483 static inline struct LDKAPIError CResult_NoneAPIErrorZ_get_err(LDKCResult_NoneAPIErrorZ *NONNULL_PTR owner){
6484 CHECK(!owner->result_ok);
6485         return APIError_clone(&*owner->contents.err);
6486 }
6487 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6488         LDKCResult_NoneAPIErrorZ* owner_conv = (LDKCResult_NoneAPIErrorZ*)untag_ptr(owner);
6489         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
6490         *ret_copy = CResult_NoneAPIErrorZ_get_err(owner_conv);
6491         int64_t ret_ref = tag_ptr(ret_copy, true);
6492         return ret_ref;
6493 }
6494
6495 static inline LDKCVec_CResult_NoneAPIErrorZZ CVec_CResult_NoneAPIErrorZZ_clone(const LDKCVec_CResult_NoneAPIErrorZZ *orig) {
6496         LDKCVec_CResult_NoneAPIErrorZZ ret = { .data = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ) * orig->datalen, "LDKCVec_CResult_NoneAPIErrorZZ clone bytes"), .datalen = orig->datalen };
6497         for (size_t i = 0; i < ret.datalen; i++) {
6498                 ret.data[i] = CResult_NoneAPIErrorZ_clone(&orig->data[i]);
6499         }
6500         return ret;
6501 }
6502 static inline LDKCVec_APIErrorZ CVec_APIErrorZ_clone(const LDKCVec_APIErrorZ *orig) {
6503         LDKCVec_APIErrorZ ret = { .data = MALLOC(sizeof(LDKAPIError) * orig->datalen, "LDKCVec_APIErrorZ clone bytes"), .datalen = orig->datalen };
6504         for (size_t i = 0; i < ret.datalen; i++) {
6505                 ret.data[i] = APIError_clone(&orig->data[i]);
6506         }
6507         return ret;
6508 }
6509 static inline struct LDKThirtyTwoBytes CResult__u832APIErrorZ_get_ok(LDKCResult__u832APIErrorZ *NONNULL_PTR owner){
6510 CHECK(owner->result_ok);
6511         return ThirtyTwoBytes_clone(&*owner->contents.result);
6512 }
6513 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1_1u832APIErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6514         LDKCResult__u832APIErrorZ* owner_conv = (LDKCResult__u832APIErrorZ*)untag_ptr(owner);
6515         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
6516         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, CResult__u832APIErrorZ_get_ok(owner_conv).data);
6517         return ret_arr;
6518 }
6519
6520 static inline struct LDKAPIError CResult__u832APIErrorZ_get_err(LDKCResult__u832APIErrorZ *NONNULL_PTR owner){
6521 CHECK(!owner->result_ok);
6522         return APIError_clone(&*owner->contents.err);
6523 }
6524 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1_1u832APIErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6525         LDKCResult__u832APIErrorZ* owner_conv = (LDKCResult__u832APIErrorZ*)untag_ptr(owner);
6526         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
6527         *ret_copy = CResult__u832APIErrorZ_get_err(owner_conv);
6528         int64_t ret_ref = tag_ptr(ret_copy, true);
6529         return ret_ref;
6530 }
6531
6532 static jclass LDKPaymentSendFailure_ParameterError_class = NULL;
6533 static jmethodID LDKPaymentSendFailure_ParameterError_meth = NULL;
6534 static jclass LDKPaymentSendFailure_PathParameterError_class = NULL;
6535 static jmethodID LDKPaymentSendFailure_PathParameterError_meth = NULL;
6536 static jclass LDKPaymentSendFailure_AllFailedResendSafe_class = NULL;
6537 static jmethodID LDKPaymentSendFailure_AllFailedResendSafe_meth = NULL;
6538 static jclass LDKPaymentSendFailure_DuplicatePayment_class = NULL;
6539 static jmethodID LDKPaymentSendFailure_DuplicatePayment_meth = NULL;
6540 static jclass LDKPaymentSendFailure_PartialFailure_class = NULL;
6541 static jmethodID LDKPaymentSendFailure_PartialFailure_meth = NULL;
6542 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKPaymentSendFailure_init (JNIEnv *env, jclass clz) {
6543         LDKPaymentSendFailure_ParameterError_class =
6544                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKPaymentSendFailure$ParameterError"));
6545         CHECK(LDKPaymentSendFailure_ParameterError_class != NULL);
6546         LDKPaymentSendFailure_ParameterError_meth = (*env)->GetMethodID(env, LDKPaymentSendFailure_ParameterError_class, "<init>", "(J)V");
6547         CHECK(LDKPaymentSendFailure_ParameterError_meth != NULL);
6548         LDKPaymentSendFailure_PathParameterError_class =
6549                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKPaymentSendFailure$PathParameterError"));
6550         CHECK(LDKPaymentSendFailure_PathParameterError_class != NULL);
6551         LDKPaymentSendFailure_PathParameterError_meth = (*env)->GetMethodID(env, LDKPaymentSendFailure_PathParameterError_class, "<init>", "([J)V");
6552         CHECK(LDKPaymentSendFailure_PathParameterError_meth != NULL);
6553         LDKPaymentSendFailure_AllFailedResendSafe_class =
6554                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKPaymentSendFailure$AllFailedResendSafe"));
6555         CHECK(LDKPaymentSendFailure_AllFailedResendSafe_class != NULL);
6556         LDKPaymentSendFailure_AllFailedResendSafe_meth = (*env)->GetMethodID(env, LDKPaymentSendFailure_AllFailedResendSafe_class, "<init>", "([J)V");
6557         CHECK(LDKPaymentSendFailure_AllFailedResendSafe_meth != NULL);
6558         LDKPaymentSendFailure_DuplicatePayment_class =
6559                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKPaymentSendFailure$DuplicatePayment"));
6560         CHECK(LDKPaymentSendFailure_DuplicatePayment_class != NULL);
6561         LDKPaymentSendFailure_DuplicatePayment_meth = (*env)->GetMethodID(env, LDKPaymentSendFailure_DuplicatePayment_class, "<init>", "()V");
6562         CHECK(LDKPaymentSendFailure_DuplicatePayment_meth != NULL);
6563         LDKPaymentSendFailure_PartialFailure_class =
6564                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKPaymentSendFailure$PartialFailure"));
6565         CHECK(LDKPaymentSendFailure_PartialFailure_class != NULL);
6566         LDKPaymentSendFailure_PartialFailure_meth = (*env)->GetMethodID(env, LDKPaymentSendFailure_PartialFailure_class, "<init>", "([JJ[B)V");
6567         CHECK(LDKPaymentSendFailure_PartialFailure_meth != NULL);
6568 }
6569 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKPaymentSendFailure_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
6570         LDKPaymentSendFailure *obj = (LDKPaymentSendFailure*)untag_ptr(ptr);
6571         switch(obj->tag) {
6572                 case LDKPaymentSendFailure_ParameterError: {
6573                         int64_t parameter_error_ref = tag_ptr(&obj->parameter_error, false);
6574                         return (*env)->NewObject(env, LDKPaymentSendFailure_ParameterError_class, LDKPaymentSendFailure_ParameterError_meth, parameter_error_ref);
6575                 }
6576                 case LDKPaymentSendFailure_PathParameterError: {
6577                         LDKCVec_CResult_NoneAPIErrorZZ path_parameter_error_var = obj->path_parameter_error;
6578                         int64_tArray path_parameter_error_arr = NULL;
6579                         path_parameter_error_arr = (*env)->NewLongArray(env, path_parameter_error_var.datalen);
6580                         int64_t *path_parameter_error_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, path_parameter_error_arr, NULL);
6581                         for (size_t w = 0; w < path_parameter_error_var.datalen; w++) {
6582                                 LDKCResult_NoneAPIErrorZ* path_parameter_error_conv_22_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
6583                                 *path_parameter_error_conv_22_conv = path_parameter_error_var.data[w];
6584                                 *path_parameter_error_conv_22_conv = CResult_NoneAPIErrorZ_clone(path_parameter_error_conv_22_conv);
6585                                 path_parameter_error_arr_ptr[w] = tag_ptr(path_parameter_error_conv_22_conv, true);
6586                         }
6587                         (*env)->ReleasePrimitiveArrayCritical(env, path_parameter_error_arr, path_parameter_error_arr_ptr, 0);
6588                         return (*env)->NewObject(env, LDKPaymentSendFailure_PathParameterError_class, LDKPaymentSendFailure_PathParameterError_meth, path_parameter_error_arr);
6589                 }
6590                 case LDKPaymentSendFailure_AllFailedResendSafe: {
6591                         LDKCVec_APIErrorZ all_failed_resend_safe_var = obj->all_failed_resend_safe;
6592                         int64_tArray all_failed_resend_safe_arr = NULL;
6593                         all_failed_resend_safe_arr = (*env)->NewLongArray(env, all_failed_resend_safe_var.datalen);
6594                         int64_t *all_failed_resend_safe_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, all_failed_resend_safe_arr, NULL);
6595                         for (size_t k = 0; k < all_failed_resend_safe_var.datalen; k++) {
6596                                 int64_t all_failed_resend_safe_conv_10_ref = tag_ptr(&all_failed_resend_safe_var.data[k], false);
6597                                 all_failed_resend_safe_arr_ptr[k] = all_failed_resend_safe_conv_10_ref;
6598                         }
6599                         (*env)->ReleasePrimitiveArrayCritical(env, all_failed_resend_safe_arr, all_failed_resend_safe_arr_ptr, 0);
6600                         return (*env)->NewObject(env, LDKPaymentSendFailure_AllFailedResendSafe_class, LDKPaymentSendFailure_AllFailedResendSafe_meth, all_failed_resend_safe_arr);
6601                 }
6602                 case LDKPaymentSendFailure_DuplicatePayment: {
6603                         return (*env)->NewObject(env, LDKPaymentSendFailure_DuplicatePayment_class, LDKPaymentSendFailure_DuplicatePayment_meth);
6604                 }
6605                 case LDKPaymentSendFailure_PartialFailure: {
6606                         LDKCVec_CResult_NoneAPIErrorZZ results_var = obj->partial_failure.results;
6607                         int64_tArray results_arr = NULL;
6608                         results_arr = (*env)->NewLongArray(env, results_var.datalen);
6609                         int64_t *results_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, results_arr, NULL);
6610                         for (size_t w = 0; w < results_var.datalen; w++) {
6611                                 LDKCResult_NoneAPIErrorZ* results_conv_22_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
6612                                 *results_conv_22_conv = results_var.data[w];
6613                                 *results_conv_22_conv = CResult_NoneAPIErrorZ_clone(results_conv_22_conv);
6614                                 results_arr_ptr[w] = tag_ptr(results_conv_22_conv, true);
6615                         }
6616                         (*env)->ReleasePrimitiveArrayCritical(env, results_arr, results_arr_ptr, 0);
6617                         LDKRouteParameters failed_paths_retry_var = obj->partial_failure.failed_paths_retry;
6618                         int64_t failed_paths_retry_ref = 0;
6619                         CHECK_INNER_FIELD_ACCESS_OR_NULL(failed_paths_retry_var);
6620                         failed_paths_retry_ref = tag_ptr(failed_paths_retry_var.inner, false);
6621                         int8_tArray payment_id_arr = (*env)->NewByteArray(env, 32);
6622                         (*env)->SetByteArrayRegion(env, payment_id_arr, 0, 32, obj->partial_failure.payment_id.data);
6623                         return (*env)->NewObject(env, LDKPaymentSendFailure_PartialFailure_class, LDKPaymentSendFailure_PartialFailure_meth, results_arr, failed_paths_retry_ref, payment_id_arr);
6624                 }
6625                 default: abort();
6626         }
6627 }
6628 static inline void CResult_NonePaymentSendFailureZ_get_ok(LDKCResult_NonePaymentSendFailureZ *NONNULL_PTR owner){
6629 CHECK(owner->result_ok);
6630         return *owner->contents.result;
6631 }
6632 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6633         LDKCResult_NonePaymentSendFailureZ* owner_conv = (LDKCResult_NonePaymentSendFailureZ*)untag_ptr(owner);
6634         CResult_NonePaymentSendFailureZ_get_ok(owner_conv);
6635 }
6636
6637 static inline struct LDKPaymentSendFailure CResult_NonePaymentSendFailureZ_get_err(LDKCResult_NonePaymentSendFailureZ *NONNULL_PTR owner){
6638 CHECK(!owner->result_ok);
6639         return PaymentSendFailure_clone(&*owner->contents.err);
6640 }
6641 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6642         LDKCResult_NonePaymentSendFailureZ* owner_conv = (LDKCResult_NonePaymentSendFailureZ*)untag_ptr(owner);
6643         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
6644         *ret_copy = CResult_NonePaymentSendFailureZ_get_err(owner_conv);
6645         int64_t ret_ref = tag_ptr(ret_copy, true);
6646         return ret_ref;
6647 }
6648
6649 static inline struct LDKThirtyTwoBytes CResult_PaymentHashPaymentSendFailureZ_get_ok(LDKCResult_PaymentHashPaymentSendFailureZ *NONNULL_PTR owner){
6650 CHECK(owner->result_ok);
6651         return ThirtyTwoBytes_clone(&*owner->contents.result);
6652 }
6653 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentHashPaymentSendFailureZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6654         LDKCResult_PaymentHashPaymentSendFailureZ* owner_conv = (LDKCResult_PaymentHashPaymentSendFailureZ*)untag_ptr(owner);
6655         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
6656         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, CResult_PaymentHashPaymentSendFailureZ_get_ok(owner_conv).data);
6657         return ret_arr;
6658 }
6659
6660 static inline struct LDKPaymentSendFailure CResult_PaymentHashPaymentSendFailureZ_get_err(LDKCResult_PaymentHashPaymentSendFailureZ *NONNULL_PTR owner){
6661 CHECK(!owner->result_ok);
6662         return PaymentSendFailure_clone(&*owner->contents.err);
6663 }
6664 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentHashPaymentSendFailureZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6665         LDKCResult_PaymentHashPaymentSendFailureZ* owner_conv = (LDKCResult_PaymentHashPaymentSendFailureZ*)untag_ptr(owner);
6666         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
6667         *ret_copy = CResult_PaymentHashPaymentSendFailureZ_get_err(owner_conv);
6668         int64_t ret_ref = tag_ptr(ret_copy, true);
6669         return ret_ref;
6670 }
6671
6672 static inline struct LDKThirtyTwoBytes C2Tuple_PaymentHashPaymentIdZ_get_a(LDKC2Tuple_PaymentHashPaymentIdZ *NONNULL_PTR owner){
6673         return ThirtyTwoBytes_clone(&owner->a);
6674 }
6675 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentIdZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
6676         LDKC2Tuple_PaymentHashPaymentIdZ* owner_conv = (LDKC2Tuple_PaymentHashPaymentIdZ*)untag_ptr(owner);
6677         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
6678         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_PaymentHashPaymentIdZ_get_a(owner_conv).data);
6679         return ret_arr;
6680 }
6681
6682 static inline struct LDKThirtyTwoBytes C2Tuple_PaymentHashPaymentIdZ_get_b(LDKC2Tuple_PaymentHashPaymentIdZ *NONNULL_PTR owner){
6683         return ThirtyTwoBytes_clone(&owner->b);
6684 }
6685 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentIdZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
6686         LDKC2Tuple_PaymentHashPaymentIdZ* owner_conv = (LDKC2Tuple_PaymentHashPaymentIdZ*)untag_ptr(owner);
6687         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
6688         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_PaymentHashPaymentIdZ_get_b(owner_conv).data);
6689         return ret_arr;
6690 }
6691
6692 static inline struct LDKC2Tuple_PaymentHashPaymentIdZ CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_ok(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ *NONNULL_PTR owner){
6693 CHECK(owner->result_ok);
6694         return C2Tuple_PaymentHashPaymentIdZ_clone(&*owner->contents.result);
6695 }
6696 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6697         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)untag_ptr(owner);
6698         LDKC2Tuple_PaymentHashPaymentIdZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentIdZ), "LDKC2Tuple_PaymentHashPaymentIdZ");
6699         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_ok(owner_conv);
6700         return tag_ptr(ret_conv, true);
6701 }
6702
6703 static inline struct LDKPaymentSendFailure CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_err(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ *NONNULL_PTR owner){
6704 CHECK(!owner->result_ok);
6705         return PaymentSendFailure_clone(&*owner->contents.err);
6706 }
6707 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6708         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)untag_ptr(owner);
6709         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
6710         *ret_copy = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_get_err(owner_conv);
6711         int64_t ret_ref = tag_ptr(ret_copy, true);
6712         return ret_ref;
6713 }
6714
6715 static inline LDKCVec_ThirtyTwoBytesZ CVec_ThirtyTwoBytesZ_clone(const LDKCVec_ThirtyTwoBytesZ *orig) {
6716         LDKCVec_ThirtyTwoBytesZ ret = { .data = MALLOC(sizeof(LDKThirtyTwoBytes) * orig->datalen, "LDKCVec_ThirtyTwoBytesZ clone bytes"), .datalen = orig->datalen };
6717         for (size_t i = 0; i < ret.datalen; i++) {
6718                 ret.data[i] = ThirtyTwoBytes_clone(&orig->data[i]);
6719         }
6720         return ret;
6721 }
6722 static inline struct LDKThirtyTwoBytes C2Tuple_PaymentHashPaymentSecretZ_get_a(LDKC2Tuple_PaymentHashPaymentSecretZ *NONNULL_PTR owner){
6723         return ThirtyTwoBytes_clone(&owner->a);
6724 }
6725 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentSecretZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
6726         LDKC2Tuple_PaymentHashPaymentSecretZ* owner_conv = (LDKC2Tuple_PaymentHashPaymentSecretZ*)untag_ptr(owner);
6727         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
6728         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_PaymentHashPaymentSecretZ_get_a(owner_conv).data);
6729         return ret_arr;
6730 }
6731
6732 static inline struct LDKThirtyTwoBytes C2Tuple_PaymentHashPaymentSecretZ_get_b(LDKC2Tuple_PaymentHashPaymentSecretZ *NONNULL_PTR owner){
6733         return ThirtyTwoBytes_clone(&owner->b);
6734 }
6735 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentSecretZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
6736         LDKC2Tuple_PaymentHashPaymentSecretZ* owner_conv = (LDKC2Tuple_PaymentHashPaymentSecretZ*)untag_ptr(owner);
6737         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
6738         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_PaymentHashPaymentSecretZ_get_b(owner_conv).data);
6739         return ret_arr;
6740 }
6741
6742 static inline struct LDKC2Tuple_PaymentHashPaymentSecretZ CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_ok(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ *NONNULL_PTR owner){
6743 CHECK(owner->result_ok);
6744         return C2Tuple_PaymentHashPaymentSecretZ_clone(&*owner->contents.result);
6745 }
6746 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6747         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)untag_ptr(owner);
6748         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
6749         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_ok(owner_conv);
6750         return tag_ptr(ret_conv, true);
6751 }
6752
6753 static inline void CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_err(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ *NONNULL_PTR owner){
6754 CHECK(!owner->result_ok);
6755         return *owner->contents.err;
6756 }
6757 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6758         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)untag_ptr(owner);
6759         CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_get_err(owner_conv);
6760 }
6761
6762 static inline struct LDKC2Tuple_PaymentHashPaymentSecretZ CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_ok(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ *NONNULL_PTR owner){
6763 CHECK(owner->result_ok);
6764         return C2Tuple_PaymentHashPaymentSecretZ_clone(&*owner->contents.result);
6765 }
6766 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZAPIErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6767         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)untag_ptr(owner);
6768         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
6769         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_ok(owner_conv);
6770         return tag_ptr(ret_conv, true);
6771 }
6772
6773 static inline struct LDKAPIError CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_err(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ *NONNULL_PTR owner){
6774 CHECK(!owner->result_ok);
6775         return APIError_clone(&*owner->contents.err);
6776 }
6777 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZAPIErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6778         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* owner_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)untag_ptr(owner);
6779         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
6780         *ret_copy = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_get_err(owner_conv);
6781         int64_t ret_ref = tag_ptr(ret_copy, true);
6782         return ret_ref;
6783 }
6784
6785 static inline struct LDKThirtyTwoBytes CResult_PaymentSecretNoneZ_get_ok(LDKCResult_PaymentSecretNoneZ *NONNULL_PTR owner){
6786 CHECK(owner->result_ok);
6787         return ThirtyTwoBytes_clone(&*owner->contents.result);
6788 }
6789 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6790         LDKCResult_PaymentSecretNoneZ* owner_conv = (LDKCResult_PaymentSecretNoneZ*)untag_ptr(owner);
6791         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
6792         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, CResult_PaymentSecretNoneZ_get_ok(owner_conv).data);
6793         return ret_arr;
6794 }
6795
6796 static inline void CResult_PaymentSecretNoneZ_get_err(LDKCResult_PaymentSecretNoneZ *NONNULL_PTR owner){
6797 CHECK(!owner->result_ok);
6798         return *owner->contents.err;
6799 }
6800 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6801         LDKCResult_PaymentSecretNoneZ* owner_conv = (LDKCResult_PaymentSecretNoneZ*)untag_ptr(owner);
6802         CResult_PaymentSecretNoneZ_get_err(owner_conv);
6803 }
6804
6805 static inline struct LDKThirtyTwoBytes CResult_PaymentSecretAPIErrorZ_get_ok(LDKCResult_PaymentSecretAPIErrorZ *NONNULL_PTR owner){
6806 CHECK(owner->result_ok);
6807         return ThirtyTwoBytes_clone(&*owner->contents.result);
6808 }
6809 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6810         LDKCResult_PaymentSecretAPIErrorZ* owner_conv = (LDKCResult_PaymentSecretAPIErrorZ*)untag_ptr(owner);
6811         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
6812         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, CResult_PaymentSecretAPIErrorZ_get_ok(owner_conv).data);
6813         return ret_arr;
6814 }
6815
6816 static inline struct LDKAPIError CResult_PaymentSecretAPIErrorZ_get_err(LDKCResult_PaymentSecretAPIErrorZ *NONNULL_PTR owner){
6817 CHECK(!owner->result_ok);
6818         return APIError_clone(&*owner->contents.err);
6819 }
6820 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6821         LDKCResult_PaymentSecretAPIErrorZ* owner_conv = (LDKCResult_PaymentSecretAPIErrorZ*)untag_ptr(owner);
6822         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
6823         *ret_copy = CResult_PaymentSecretAPIErrorZ_get_err(owner_conv);
6824         int64_t ret_ref = tag_ptr(ret_copy, true);
6825         return ret_ref;
6826 }
6827
6828 static inline struct LDKThirtyTwoBytes CResult_PaymentPreimageAPIErrorZ_get_ok(LDKCResult_PaymentPreimageAPIErrorZ *NONNULL_PTR owner){
6829 CHECK(owner->result_ok);
6830         return ThirtyTwoBytes_clone(&*owner->contents.result);
6831 }
6832 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPreimageAPIErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6833         LDKCResult_PaymentPreimageAPIErrorZ* owner_conv = (LDKCResult_PaymentPreimageAPIErrorZ*)untag_ptr(owner);
6834         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
6835         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, CResult_PaymentPreimageAPIErrorZ_get_ok(owner_conv).data);
6836         return ret_arr;
6837 }
6838
6839 static inline struct LDKAPIError CResult_PaymentPreimageAPIErrorZ_get_err(LDKCResult_PaymentPreimageAPIErrorZ *NONNULL_PTR owner){
6840 CHECK(!owner->result_ok);
6841         return APIError_clone(&*owner->contents.err);
6842 }
6843 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPreimageAPIErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6844         LDKCResult_PaymentPreimageAPIErrorZ* owner_conv = (LDKCResult_PaymentPreimageAPIErrorZ*)untag_ptr(owner);
6845         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
6846         *ret_copy = CResult_PaymentPreimageAPIErrorZ_get_err(owner_conv);
6847         int64_t ret_ref = tag_ptr(ret_copy, true);
6848         return ret_ref;
6849 }
6850
6851 static inline struct LDKCounterpartyForwardingInfo CResult_CounterpartyForwardingInfoDecodeErrorZ_get_ok(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ *NONNULL_PTR owner){
6852         LDKCounterpartyForwardingInfo ret = *owner->contents.result;
6853         ret.is_owned = false;
6854         return ret;
6855 }
6856 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyForwardingInfoDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6857         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* owner_conv = (LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)untag_ptr(owner);
6858         LDKCounterpartyForwardingInfo ret_var = CResult_CounterpartyForwardingInfoDecodeErrorZ_get_ok(owner_conv);
6859         int64_t ret_ref = 0;
6860         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6861         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
6862         return ret_ref;
6863 }
6864
6865 static inline struct LDKDecodeError CResult_CounterpartyForwardingInfoDecodeErrorZ_get_err(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ *NONNULL_PTR owner){
6866 CHECK(!owner->result_ok);
6867         return DecodeError_clone(&*owner->contents.err);
6868 }
6869 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyForwardingInfoDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6870         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* owner_conv = (LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)untag_ptr(owner);
6871         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
6872         *ret_copy = CResult_CounterpartyForwardingInfoDecodeErrorZ_get_err(owner_conv);
6873         int64_t ret_ref = tag_ptr(ret_copy, true);
6874         return ret_ref;
6875 }
6876
6877 static inline struct LDKChannelCounterparty CResult_ChannelCounterpartyDecodeErrorZ_get_ok(LDKCResult_ChannelCounterpartyDecodeErrorZ *NONNULL_PTR owner){
6878         LDKChannelCounterparty ret = *owner->contents.result;
6879         ret.is_owned = false;
6880         return ret;
6881 }
6882 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelCounterpartyDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6883         LDKCResult_ChannelCounterpartyDecodeErrorZ* owner_conv = (LDKCResult_ChannelCounterpartyDecodeErrorZ*)untag_ptr(owner);
6884         LDKChannelCounterparty ret_var = CResult_ChannelCounterpartyDecodeErrorZ_get_ok(owner_conv);
6885         int64_t ret_ref = 0;
6886         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6887         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
6888         return ret_ref;
6889 }
6890
6891 static inline struct LDKDecodeError CResult_ChannelCounterpartyDecodeErrorZ_get_err(LDKCResult_ChannelCounterpartyDecodeErrorZ *NONNULL_PTR owner){
6892 CHECK(!owner->result_ok);
6893         return DecodeError_clone(&*owner->contents.err);
6894 }
6895 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelCounterpartyDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6896         LDKCResult_ChannelCounterpartyDecodeErrorZ* owner_conv = (LDKCResult_ChannelCounterpartyDecodeErrorZ*)untag_ptr(owner);
6897         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
6898         *ret_copy = CResult_ChannelCounterpartyDecodeErrorZ_get_err(owner_conv);
6899         int64_t ret_ref = tag_ptr(ret_copy, true);
6900         return ret_ref;
6901 }
6902
6903 static inline struct LDKChannelDetails CResult_ChannelDetailsDecodeErrorZ_get_ok(LDKCResult_ChannelDetailsDecodeErrorZ *NONNULL_PTR owner){
6904         LDKChannelDetails ret = *owner->contents.result;
6905         ret.is_owned = false;
6906         return ret;
6907 }
6908 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelDetailsDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6909         LDKCResult_ChannelDetailsDecodeErrorZ* owner_conv = (LDKCResult_ChannelDetailsDecodeErrorZ*)untag_ptr(owner);
6910         LDKChannelDetails ret_var = CResult_ChannelDetailsDecodeErrorZ_get_ok(owner_conv);
6911         int64_t ret_ref = 0;
6912         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6913         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
6914         return ret_ref;
6915 }
6916
6917 static inline struct LDKDecodeError CResult_ChannelDetailsDecodeErrorZ_get_err(LDKCResult_ChannelDetailsDecodeErrorZ *NONNULL_PTR owner){
6918 CHECK(!owner->result_ok);
6919         return DecodeError_clone(&*owner->contents.err);
6920 }
6921 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelDetailsDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6922         LDKCResult_ChannelDetailsDecodeErrorZ* owner_conv = (LDKCResult_ChannelDetailsDecodeErrorZ*)untag_ptr(owner);
6923         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
6924         *ret_copy = CResult_ChannelDetailsDecodeErrorZ_get_err(owner_conv);
6925         int64_t ret_ref = tag_ptr(ret_copy, true);
6926         return ret_ref;
6927 }
6928
6929 static inline struct LDKPhantomRouteHints CResult_PhantomRouteHintsDecodeErrorZ_get_ok(LDKCResult_PhantomRouteHintsDecodeErrorZ *NONNULL_PTR owner){
6930         LDKPhantomRouteHints ret = *owner->contents.result;
6931         ret.is_owned = false;
6932         return ret;
6933 }
6934 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PhantomRouteHintsDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
6935         LDKCResult_PhantomRouteHintsDecodeErrorZ* owner_conv = (LDKCResult_PhantomRouteHintsDecodeErrorZ*)untag_ptr(owner);
6936         LDKPhantomRouteHints ret_var = CResult_PhantomRouteHintsDecodeErrorZ_get_ok(owner_conv);
6937         int64_t ret_ref = 0;
6938         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
6939         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
6940         return ret_ref;
6941 }
6942
6943 static inline struct LDKDecodeError CResult_PhantomRouteHintsDecodeErrorZ_get_err(LDKCResult_PhantomRouteHintsDecodeErrorZ *NONNULL_PTR owner){
6944 CHECK(!owner->result_ok);
6945         return DecodeError_clone(&*owner->contents.err);
6946 }
6947 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PhantomRouteHintsDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
6948         LDKCResult_PhantomRouteHintsDecodeErrorZ* owner_conv = (LDKCResult_PhantomRouteHintsDecodeErrorZ*)untag_ptr(owner);
6949         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
6950         *ret_copy = CResult_PhantomRouteHintsDecodeErrorZ_get_err(owner_conv);
6951         int64_t ret_ref = tag_ptr(ret_copy, true);
6952         return ret_ref;
6953 }
6954
6955 static inline LDKCVec_ChannelMonitorZ CVec_ChannelMonitorZ_clone(const LDKCVec_ChannelMonitorZ *orig) {
6956         LDKCVec_ChannelMonitorZ ret = { .data = MALLOC(sizeof(LDKChannelMonitor) * orig->datalen, "LDKCVec_ChannelMonitorZ clone bytes"), .datalen = orig->datalen };
6957         for (size_t i = 0; i < ret.datalen; i++) {
6958                 ret.data[i] = ChannelMonitor_clone(&orig->data[i]);
6959         }
6960         return ret;
6961 }
6962 typedef struct LDKWatch_JCalls {
6963         atomic_size_t refcnt;
6964         JavaVM *vm;
6965         jweak o;
6966         jmethodID watch_channel_meth;
6967         jmethodID update_channel_meth;
6968         jmethodID release_pending_monitor_events_meth;
6969 } LDKWatch_JCalls;
6970 static void LDKWatch_JCalls_free(void* this_arg) {
6971         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
6972         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
6973                 JNIEnv *env;
6974                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6975                 if (get_jenv_res == JNI_EDETACHED) {
6976                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6977                 } else {
6978                         DO_ASSERT(get_jenv_res == JNI_OK);
6979                 }
6980                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
6981                 if (get_jenv_res == JNI_EDETACHED) {
6982                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6983                 }
6984                 FREE(j_calls);
6985         }
6986 }
6987 LDKChannelMonitorUpdateStatus watch_channel_LDKWatch_jcall(const void* this_arg, LDKOutPoint funding_txo, LDKChannelMonitor monitor) {
6988         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
6989         JNIEnv *env;
6990         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6991         if (get_jenv_res == JNI_EDETACHED) {
6992                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6993         } else {
6994                 DO_ASSERT(get_jenv_res == JNI_OK);
6995         }
6996         LDKOutPoint funding_txo_var = funding_txo;
6997         int64_t funding_txo_ref = 0;
6998         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_var);
6999         funding_txo_ref = tag_ptr(funding_txo_var.inner, funding_txo_var.is_owned);
7000         LDKChannelMonitor monitor_var = monitor;
7001         int64_t monitor_ref = 0;
7002         CHECK_INNER_FIELD_ACCESS_OR_NULL(monitor_var);
7003         monitor_ref = tag_ptr(monitor_var.inner, monitor_var.is_owned);
7004         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7005         CHECK(obj != NULL);
7006         jclass ret = (*env)->CallObjectMethod(env, obj, j_calls->watch_channel_meth, funding_txo_ref, monitor_ref);
7007         if (UNLIKELY((*env)->ExceptionCheck(env))) {
7008                 (*env)->ExceptionDescribe(env);
7009                 (*env)->FatalError(env, "A call to watch_channel in LDKWatch from rust threw an exception.");
7010         }
7011         LDKChannelMonitorUpdateStatus ret_conv = LDKChannelMonitorUpdateStatus_from_java(env, ret);
7012         if (get_jenv_res == JNI_EDETACHED) {
7013                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7014         }
7015         return ret_conv;
7016 }
7017 LDKChannelMonitorUpdateStatus update_channel_LDKWatch_jcall(const void* this_arg, LDKOutPoint funding_txo, LDKChannelMonitorUpdate update) {
7018         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
7019         JNIEnv *env;
7020         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7021         if (get_jenv_res == JNI_EDETACHED) {
7022                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7023         } else {
7024                 DO_ASSERT(get_jenv_res == JNI_OK);
7025         }
7026         LDKOutPoint funding_txo_var = funding_txo;
7027         int64_t funding_txo_ref = 0;
7028         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_var);
7029         funding_txo_ref = tag_ptr(funding_txo_var.inner, funding_txo_var.is_owned);
7030         LDKChannelMonitorUpdate update_var = update;
7031         int64_t update_ref = 0;
7032         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_var);
7033         update_ref = tag_ptr(update_var.inner, update_var.is_owned);
7034         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7035         CHECK(obj != NULL);
7036         jclass ret = (*env)->CallObjectMethod(env, obj, j_calls->update_channel_meth, funding_txo_ref, update_ref);
7037         if (UNLIKELY((*env)->ExceptionCheck(env))) {
7038                 (*env)->ExceptionDescribe(env);
7039                 (*env)->FatalError(env, "A call to update_channel in LDKWatch from rust threw an exception.");
7040         }
7041         LDKChannelMonitorUpdateStatus ret_conv = LDKChannelMonitorUpdateStatus_from_java(env, ret);
7042         if (get_jenv_res == JNI_EDETACHED) {
7043                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7044         }
7045         return ret_conv;
7046 }
7047 LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ release_pending_monitor_events_LDKWatch_jcall(const void* this_arg) {
7048         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
7049         JNIEnv *env;
7050         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7051         if (get_jenv_res == JNI_EDETACHED) {
7052                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7053         } else {
7054                 DO_ASSERT(get_jenv_res == JNI_OK);
7055         }
7056         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7057         CHECK(obj != NULL);
7058         int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->release_pending_monitor_events_meth);
7059         if (UNLIKELY((*env)->ExceptionCheck(env))) {
7060                 (*env)->ExceptionDescribe(env);
7061                 (*env)->FatalError(env, "A call to release_pending_monitor_events in LDKWatch from rust threw an exception.");
7062         }
7063         LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ ret_constr;
7064         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
7065         if (ret_constr.datalen > 0)
7066                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ), "LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ Elements");
7067         else
7068                 ret_constr.data = NULL;
7069         int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
7070         for (size_t x = 0; x < ret_constr.datalen; x++) {
7071                 int64_t ret_conv_49 = ret_vals[x];
7072                 void* ret_conv_49_ptr = untag_ptr(ret_conv_49);
7073                 CHECK_ACCESS(ret_conv_49_ptr);
7074                 LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ ret_conv_49_conv = *(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ*)(ret_conv_49_ptr);
7075                 FREE(untag_ptr(ret_conv_49));
7076                 ret_constr.data[x] = ret_conv_49_conv;
7077         }
7078         (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
7079         if (get_jenv_res == JNI_EDETACHED) {
7080                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7081         }
7082         return ret_constr;
7083 }
7084 static void LDKWatch_JCalls_cloned(LDKWatch* new_obj) {
7085         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) new_obj->this_arg;
7086         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
7087 }
7088 static inline LDKWatch LDKWatch_init (JNIEnv *env, jclass clz, jobject o) {
7089         jclass c = (*env)->GetObjectClass(env, o);
7090         CHECK(c != NULL);
7091         LDKWatch_JCalls *calls = MALLOC(sizeof(LDKWatch_JCalls), "LDKWatch_JCalls");
7092         atomic_init(&calls->refcnt, 1);
7093         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
7094         calls->o = (*env)->NewWeakGlobalRef(env, o);
7095         calls->watch_channel_meth = (*env)->GetMethodID(env, c, "watch_channel", "(JJ)Lorg/ldk/enums/ChannelMonitorUpdateStatus;");
7096         CHECK(calls->watch_channel_meth != NULL);
7097         calls->update_channel_meth = (*env)->GetMethodID(env, c, "update_channel", "(JJ)Lorg/ldk/enums/ChannelMonitorUpdateStatus;");
7098         CHECK(calls->update_channel_meth != NULL);
7099         calls->release_pending_monitor_events_meth = (*env)->GetMethodID(env, c, "release_pending_monitor_events", "()[J");
7100         CHECK(calls->release_pending_monitor_events_meth != NULL);
7101
7102         LDKWatch ret = {
7103                 .this_arg = (void*) calls,
7104                 .watch_channel = watch_channel_LDKWatch_jcall,
7105                 .update_channel = update_channel_LDKWatch_jcall,
7106                 .release_pending_monitor_events = release_pending_monitor_events_LDKWatch_jcall,
7107                 .free = LDKWatch_JCalls_free,
7108         };
7109         return ret;
7110 }
7111 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKWatch_1new(JNIEnv *env, jclass clz, jobject o) {
7112         LDKWatch *res_ptr = MALLOC(sizeof(LDKWatch), "LDKWatch");
7113         *res_ptr = LDKWatch_init(env, clz, o);
7114         return tag_ptr(res_ptr, true);
7115 }
7116 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) {
7117         void* this_arg_ptr = untag_ptr(this_arg);
7118         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
7119         LDKWatch* this_arg_conv = (LDKWatch*)this_arg_ptr;
7120         LDKOutPoint funding_txo_conv;
7121         funding_txo_conv.inner = untag_ptr(funding_txo);
7122         funding_txo_conv.is_owned = ptr_is_owned(funding_txo);
7123         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
7124         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
7125         LDKChannelMonitor monitor_conv;
7126         monitor_conv.inner = untag_ptr(monitor);
7127         monitor_conv.is_owned = ptr_is_owned(monitor);
7128         CHECK_INNER_FIELD_ACCESS_OR_NULL(monitor_conv);
7129         monitor_conv = ChannelMonitor_clone(&monitor_conv);
7130         jclass ret_conv = LDKChannelMonitorUpdateStatus_to_java(env, (this_arg_conv->watch_channel)(this_arg_conv->this_arg, funding_txo_conv, monitor_conv));
7131         return ret_conv;
7132 }
7133
7134 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) {
7135         void* this_arg_ptr = untag_ptr(this_arg);
7136         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
7137         LDKWatch* this_arg_conv = (LDKWatch*)this_arg_ptr;
7138         LDKOutPoint funding_txo_conv;
7139         funding_txo_conv.inner = untag_ptr(funding_txo);
7140         funding_txo_conv.is_owned = ptr_is_owned(funding_txo);
7141         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
7142         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
7143         LDKChannelMonitorUpdate update_conv;
7144         update_conv.inner = untag_ptr(update);
7145         update_conv.is_owned = ptr_is_owned(update);
7146         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_conv);
7147         update_conv = ChannelMonitorUpdate_clone(&update_conv);
7148         jclass ret_conv = LDKChannelMonitorUpdateStatus_to_java(env, (this_arg_conv->update_channel)(this_arg_conv->this_arg, funding_txo_conv, update_conv));
7149         return ret_conv;
7150 }
7151
7152 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_Watch_1release_1pending_1monitor_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
7153         void* this_arg_ptr = untag_ptr(this_arg);
7154         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
7155         LDKWatch* this_arg_conv = (LDKWatch*)this_arg_ptr;
7156         LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ ret_var = (this_arg_conv->release_pending_monitor_events)(this_arg_conv->this_arg);
7157         int64_tArray ret_arr = NULL;
7158         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
7159         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
7160         for (size_t x = 0; x < ret_var.datalen; x++) {
7161                 LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ* ret_conv_49_conv = MALLOC(sizeof(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ), "LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ");
7162                 *ret_conv_49_conv = ret_var.data[x];
7163                 ret_arr_ptr[x] = tag_ptr(ret_conv_49_conv, true);
7164         }
7165         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
7166         FREE(ret_var.data);
7167         return ret_arr;
7168 }
7169
7170 typedef struct LDKBroadcasterInterface_JCalls {
7171         atomic_size_t refcnt;
7172         JavaVM *vm;
7173         jweak o;
7174         jmethodID broadcast_transaction_meth;
7175 } LDKBroadcasterInterface_JCalls;
7176 static void LDKBroadcasterInterface_JCalls_free(void* this_arg) {
7177         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) this_arg;
7178         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
7179                 JNIEnv *env;
7180                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7181                 if (get_jenv_res == JNI_EDETACHED) {
7182                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7183                 } else {
7184                         DO_ASSERT(get_jenv_res == JNI_OK);
7185                 }
7186                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
7187                 if (get_jenv_res == JNI_EDETACHED) {
7188                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7189                 }
7190                 FREE(j_calls);
7191         }
7192 }
7193 void broadcast_transaction_LDKBroadcasterInterface_jcall(const void* this_arg, LDKTransaction tx) {
7194         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) this_arg;
7195         JNIEnv *env;
7196         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7197         if (get_jenv_res == JNI_EDETACHED) {
7198                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7199         } else {
7200                 DO_ASSERT(get_jenv_res == JNI_OK);
7201         }
7202         LDKTransaction tx_var = tx;
7203         int8_tArray tx_arr = (*env)->NewByteArray(env, tx_var.datalen);
7204         (*env)->SetByteArrayRegion(env, tx_arr, 0, tx_var.datalen, tx_var.data);
7205         Transaction_free(tx_var);
7206         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7207         CHECK(obj != NULL);
7208         (*env)->CallVoidMethod(env, obj, j_calls->broadcast_transaction_meth, tx_arr);
7209         if (UNLIKELY((*env)->ExceptionCheck(env))) {
7210                 (*env)->ExceptionDescribe(env);
7211                 (*env)->FatalError(env, "A call to broadcast_transaction in LDKBroadcasterInterface from rust threw an exception.");
7212         }
7213         if (get_jenv_res == JNI_EDETACHED) {
7214                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7215         }
7216 }
7217 static void LDKBroadcasterInterface_JCalls_cloned(LDKBroadcasterInterface* new_obj) {
7218         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) new_obj->this_arg;
7219         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
7220 }
7221 static inline LDKBroadcasterInterface LDKBroadcasterInterface_init (JNIEnv *env, jclass clz, jobject o) {
7222         jclass c = (*env)->GetObjectClass(env, o);
7223         CHECK(c != NULL);
7224         LDKBroadcasterInterface_JCalls *calls = MALLOC(sizeof(LDKBroadcasterInterface_JCalls), "LDKBroadcasterInterface_JCalls");
7225         atomic_init(&calls->refcnt, 1);
7226         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
7227         calls->o = (*env)->NewWeakGlobalRef(env, o);
7228         calls->broadcast_transaction_meth = (*env)->GetMethodID(env, c, "broadcast_transaction", "([B)V");
7229         CHECK(calls->broadcast_transaction_meth != NULL);
7230
7231         LDKBroadcasterInterface ret = {
7232                 .this_arg = (void*) calls,
7233                 .broadcast_transaction = broadcast_transaction_LDKBroadcasterInterface_jcall,
7234                 .free = LDKBroadcasterInterface_JCalls_free,
7235         };
7236         return ret;
7237 }
7238 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKBroadcasterInterface_1new(JNIEnv *env, jclass clz, jobject o) {
7239         LDKBroadcasterInterface *res_ptr = MALLOC(sizeof(LDKBroadcasterInterface), "LDKBroadcasterInterface");
7240         *res_ptr = LDKBroadcasterInterface_init(env, clz, o);
7241         return tag_ptr(res_ptr, true);
7242 }
7243 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BroadcasterInterface_1broadcast_1transaction(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray tx) {
7244         void* this_arg_ptr = untag_ptr(this_arg);
7245         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
7246         LDKBroadcasterInterface* this_arg_conv = (LDKBroadcasterInterface*)this_arg_ptr;
7247         LDKTransaction tx_ref;
7248         tx_ref.datalen = (*env)->GetArrayLength(env, tx);
7249         tx_ref.data = MALLOC(tx_ref.datalen, "LDKTransaction Bytes");
7250         (*env)->GetByteArrayRegion(env, tx, 0, tx_ref.datalen, tx_ref.data);
7251         tx_ref.data_is_owned = true;
7252         (this_arg_conv->broadcast_transaction)(this_arg_conv->this_arg, tx_ref);
7253 }
7254
7255 typedef struct LDKKeysInterface_JCalls {
7256         atomic_size_t refcnt;
7257         JavaVM *vm;
7258         jweak o;
7259         jmethodID get_node_secret_meth;
7260         jmethodID get_node_id_meth;
7261         jmethodID ecdh_meth;
7262         jmethodID get_destination_script_meth;
7263         jmethodID get_shutdown_scriptpubkey_meth;
7264         jmethodID generate_channel_keys_id_meth;
7265         jmethodID derive_channel_signer_meth;
7266         jmethodID get_secure_random_bytes_meth;
7267         jmethodID read_chan_signer_meth;
7268         jmethodID sign_invoice_meth;
7269         jmethodID get_inbound_payment_key_material_meth;
7270 } LDKKeysInterface_JCalls;
7271 static void LDKKeysInterface_JCalls_free(void* this_arg) {
7272         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
7273         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
7274                 JNIEnv *env;
7275                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7276                 if (get_jenv_res == JNI_EDETACHED) {
7277                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7278                 } else {
7279                         DO_ASSERT(get_jenv_res == JNI_OK);
7280                 }
7281                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
7282                 if (get_jenv_res == JNI_EDETACHED) {
7283                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7284                 }
7285                 FREE(j_calls);
7286         }
7287 }
7288 LDKCResult_SecretKeyNoneZ get_node_secret_LDKKeysInterface_jcall(const void* this_arg, LDKRecipient recipient) {
7289         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
7290         JNIEnv *env;
7291         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7292         if (get_jenv_res == JNI_EDETACHED) {
7293                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7294         } else {
7295                 DO_ASSERT(get_jenv_res == JNI_OK);
7296         }
7297         jclass recipient_conv = LDKRecipient_to_java(env, recipient);
7298         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7299         CHECK(obj != NULL);
7300         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->get_node_secret_meth, recipient_conv);
7301         if (UNLIKELY((*env)->ExceptionCheck(env))) {
7302                 (*env)->ExceptionDescribe(env);
7303                 (*env)->FatalError(env, "A call to get_node_secret in LDKKeysInterface from rust threw an exception.");
7304         }
7305         void* ret_ptr = untag_ptr(ret);
7306         CHECK_ACCESS(ret_ptr);
7307         LDKCResult_SecretKeyNoneZ ret_conv = *(LDKCResult_SecretKeyNoneZ*)(ret_ptr);
7308         FREE(untag_ptr(ret));
7309         if (get_jenv_res == JNI_EDETACHED) {
7310                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7311         }
7312         return ret_conv;
7313 }
7314 LDKCResult_PublicKeyNoneZ get_node_id_LDKKeysInterface_jcall(const void* this_arg, LDKRecipient recipient) {
7315         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
7316         JNIEnv *env;
7317         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7318         if (get_jenv_res == JNI_EDETACHED) {
7319                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7320         } else {
7321                 DO_ASSERT(get_jenv_res == JNI_OK);
7322         }
7323         jclass recipient_conv = LDKRecipient_to_java(env, recipient);
7324         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7325         CHECK(obj != NULL);
7326         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->get_node_id_meth, recipient_conv);
7327         if (UNLIKELY((*env)->ExceptionCheck(env))) {
7328                 (*env)->ExceptionDescribe(env);
7329                 (*env)->FatalError(env, "A call to get_node_id in LDKKeysInterface from rust threw an exception.");
7330         }
7331         void* ret_ptr = untag_ptr(ret);
7332         CHECK_ACCESS(ret_ptr);
7333         LDKCResult_PublicKeyNoneZ ret_conv = *(LDKCResult_PublicKeyNoneZ*)(ret_ptr);
7334         FREE(untag_ptr(ret));
7335         if (get_jenv_res == JNI_EDETACHED) {
7336                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7337         }
7338         return ret_conv;
7339 }
7340 LDKCResult_SharedSecretNoneZ ecdh_LDKKeysInterface_jcall(const void* this_arg, LDKRecipient recipient, LDKPublicKey other_key, LDKCOption_ScalarZ tweak) {
7341         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
7342         JNIEnv *env;
7343         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7344         if (get_jenv_res == JNI_EDETACHED) {
7345                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7346         } else {
7347                 DO_ASSERT(get_jenv_res == JNI_OK);
7348         }
7349         jclass recipient_conv = LDKRecipient_to_java(env, recipient);
7350         int8_tArray other_key_arr = (*env)->NewByteArray(env, 33);
7351         (*env)->SetByteArrayRegion(env, other_key_arr, 0, 33, other_key.compressed_form);
7352         LDKCOption_ScalarZ *tweak_copy = MALLOC(sizeof(LDKCOption_ScalarZ), "LDKCOption_ScalarZ");
7353         *tweak_copy = tweak;
7354         int64_t tweak_ref = tag_ptr(tweak_copy, true);
7355         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7356         CHECK(obj != NULL);
7357         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->ecdh_meth, recipient_conv, other_key_arr, tweak_ref);
7358         if (UNLIKELY((*env)->ExceptionCheck(env))) {
7359                 (*env)->ExceptionDescribe(env);
7360                 (*env)->FatalError(env, "A call to ecdh in LDKKeysInterface from rust threw an exception.");
7361         }
7362         void* ret_ptr = untag_ptr(ret);
7363         CHECK_ACCESS(ret_ptr);
7364         LDKCResult_SharedSecretNoneZ ret_conv = *(LDKCResult_SharedSecretNoneZ*)(ret_ptr);
7365         FREE(untag_ptr(ret));
7366         if (get_jenv_res == JNI_EDETACHED) {
7367                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7368         }
7369         return ret_conv;
7370 }
7371 LDKCVec_u8Z get_destination_script_LDKKeysInterface_jcall(const void* this_arg) {
7372         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
7373         JNIEnv *env;
7374         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7375         if (get_jenv_res == JNI_EDETACHED) {
7376                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7377         } else {
7378                 DO_ASSERT(get_jenv_res == JNI_OK);
7379         }
7380         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7381         CHECK(obj != NULL);
7382         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_destination_script_meth);
7383         if (UNLIKELY((*env)->ExceptionCheck(env))) {
7384                 (*env)->ExceptionDescribe(env);
7385                 (*env)->FatalError(env, "A call to get_destination_script in LDKKeysInterface from rust threw an exception.");
7386         }
7387         LDKCVec_u8Z ret_ref;
7388         ret_ref.datalen = (*env)->GetArrayLength(env, ret);
7389         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
7390         (*env)->GetByteArrayRegion(env, ret, 0, ret_ref.datalen, ret_ref.data);
7391         if (get_jenv_res == JNI_EDETACHED) {
7392                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7393         }
7394         return ret_ref;
7395 }
7396 LDKShutdownScript get_shutdown_scriptpubkey_LDKKeysInterface_jcall(const void* this_arg) {
7397         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
7398         JNIEnv *env;
7399         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7400         if (get_jenv_res == JNI_EDETACHED) {
7401                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7402         } else {
7403                 DO_ASSERT(get_jenv_res == JNI_OK);
7404         }
7405         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7406         CHECK(obj != NULL);
7407         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->get_shutdown_scriptpubkey_meth);
7408         if (UNLIKELY((*env)->ExceptionCheck(env))) {
7409                 (*env)->ExceptionDescribe(env);
7410                 (*env)->FatalError(env, "A call to get_shutdown_scriptpubkey in LDKKeysInterface from rust threw an exception.");
7411         }
7412         LDKShutdownScript ret_conv;
7413         ret_conv.inner = untag_ptr(ret);
7414         ret_conv.is_owned = ptr_is_owned(ret);
7415         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv);
7416         if (get_jenv_res == JNI_EDETACHED) {
7417                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7418         }
7419         return ret_conv;
7420 }
7421 LDKThirtyTwoBytes generate_channel_keys_id_LDKKeysInterface_jcall(const void* this_arg, bool inbound, uint64_t channel_value_satoshis, LDKU128 user_channel_id) {
7422         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
7423         JNIEnv *env;
7424         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7425         if (get_jenv_res == JNI_EDETACHED) {
7426                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7427         } else {
7428                 DO_ASSERT(get_jenv_res == JNI_OK);
7429         }
7430         jboolean inbound_conv = inbound;
7431         int64_t channel_value_satoshis_conv = channel_value_satoshis;
7432         int8_tArray user_channel_id_arr = (*env)->NewByteArray(env, 16);
7433         (*env)->SetByteArrayRegion(env, user_channel_id_arr, 0, 16, user_channel_id.le_bytes);
7434         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7435         CHECK(obj != NULL);
7436         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->generate_channel_keys_id_meth, inbound_conv, channel_value_satoshis_conv, user_channel_id_arr);
7437         if (UNLIKELY((*env)->ExceptionCheck(env))) {
7438                 (*env)->ExceptionDescribe(env);
7439                 (*env)->FatalError(env, "A call to generate_channel_keys_id in LDKKeysInterface from rust threw an exception.");
7440         }
7441         LDKThirtyTwoBytes ret_ref;
7442         CHECK((*env)->GetArrayLength(env, ret) == 32);
7443         (*env)->GetByteArrayRegion(env, ret, 0, 32, ret_ref.data);
7444         if (get_jenv_res == JNI_EDETACHED) {
7445                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7446         }
7447         return ret_ref;
7448 }
7449 LDKSign derive_channel_signer_LDKKeysInterface_jcall(const void* this_arg, uint64_t channel_value_satoshis, LDKThirtyTwoBytes channel_keys_id) {
7450         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
7451         JNIEnv *env;
7452         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7453         if (get_jenv_res == JNI_EDETACHED) {
7454                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7455         } else {
7456                 DO_ASSERT(get_jenv_res == JNI_OK);
7457         }
7458         int64_t channel_value_satoshis_conv = channel_value_satoshis;
7459         int8_tArray channel_keys_id_arr = (*env)->NewByteArray(env, 32);
7460         (*env)->SetByteArrayRegion(env, channel_keys_id_arr, 0, 32, channel_keys_id.data);
7461         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7462         CHECK(obj != NULL);
7463         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->derive_channel_signer_meth, channel_value_satoshis_conv, channel_keys_id_arr);
7464         if (UNLIKELY((*env)->ExceptionCheck(env))) {
7465                 (*env)->ExceptionDescribe(env);
7466                 (*env)->FatalError(env, "A call to derive_channel_signer in LDKKeysInterface from rust threw an exception.");
7467         }
7468         void* ret_ptr = untag_ptr(ret);
7469         CHECK_ACCESS(ret_ptr);
7470         LDKSign ret_conv = *(LDKSign*)(ret_ptr);
7471         FREE(untag_ptr(ret));
7472         if (get_jenv_res == JNI_EDETACHED) {
7473                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7474         }
7475         return ret_conv;
7476 }
7477 LDKThirtyTwoBytes get_secure_random_bytes_LDKKeysInterface_jcall(const void* this_arg) {
7478         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
7479         JNIEnv *env;
7480         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7481         if (get_jenv_res == JNI_EDETACHED) {
7482                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7483         } else {
7484                 DO_ASSERT(get_jenv_res == JNI_OK);
7485         }
7486         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7487         CHECK(obj != NULL);
7488         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_secure_random_bytes_meth);
7489         if (UNLIKELY((*env)->ExceptionCheck(env))) {
7490                 (*env)->ExceptionDescribe(env);
7491                 (*env)->FatalError(env, "A call to get_secure_random_bytes in LDKKeysInterface from rust threw an exception.");
7492         }
7493         LDKThirtyTwoBytes ret_ref;
7494         CHECK((*env)->GetArrayLength(env, ret) == 32);
7495         (*env)->GetByteArrayRegion(env, ret, 0, 32, ret_ref.data);
7496         if (get_jenv_res == JNI_EDETACHED) {
7497                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7498         }
7499         return ret_ref;
7500 }
7501 LDKCResult_SignDecodeErrorZ read_chan_signer_LDKKeysInterface_jcall(const void* this_arg, LDKu8slice reader) {
7502         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
7503         JNIEnv *env;
7504         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7505         if (get_jenv_res == JNI_EDETACHED) {
7506                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7507         } else {
7508                 DO_ASSERT(get_jenv_res == JNI_OK);
7509         }
7510         LDKu8slice reader_var = reader;
7511         int8_tArray reader_arr = (*env)->NewByteArray(env, reader_var.datalen);
7512         (*env)->SetByteArrayRegion(env, reader_arr, 0, reader_var.datalen, reader_var.data);
7513         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7514         CHECK(obj != NULL);
7515         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->read_chan_signer_meth, reader_arr);
7516         if (UNLIKELY((*env)->ExceptionCheck(env))) {
7517                 (*env)->ExceptionDescribe(env);
7518                 (*env)->FatalError(env, "A call to read_chan_signer in LDKKeysInterface from rust threw an exception.");
7519         }
7520         void* ret_ptr = untag_ptr(ret);
7521         CHECK_ACCESS(ret_ptr);
7522         LDKCResult_SignDecodeErrorZ ret_conv = *(LDKCResult_SignDecodeErrorZ*)(ret_ptr);
7523         FREE(untag_ptr(ret));
7524         if (get_jenv_res == JNI_EDETACHED) {
7525                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7526         }
7527         return ret_conv;
7528 }
7529 LDKCResult_RecoverableSignatureNoneZ sign_invoice_LDKKeysInterface_jcall(const void* this_arg, LDKu8slice hrp_bytes, LDKCVec_U5Z invoice_data, LDKRecipient receipient) {
7530         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
7531         JNIEnv *env;
7532         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7533         if (get_jenv_res == JNI_EDETACHED) {
7534                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7535         } else {
7536                 DO_ASSERT(get_jenv_res == JNI_OK);
7537         }
7538         LDKu8slice hrp_bytes_var = hrp_bytes;
7539         int8_tArray hrp_bytes_arr = (*env)->NewByteArray(env, hrp_bytes_var.datalen);
7540         (*env)->SetByteArrayRegion(env, hrp_bytes_arr, 0, hrp_bytes_var.datalen, hrp_bytes_var.data);
7541         LDKCVec_U5Z invoice_data_var = invoice_data;
7542         jobjectArray invoice_data_arr = NULL;
7543         invoice_data_arr = (*env)->NewByteArray(env, invoice_data_var.datalen);
7544         int8_t *invoice_data_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, invoice_data_arr, NULL);
7545         for (size_t h = 0; h < invoice_data_var.datalen; h++) {
7546                 uint8_t invoice_data_conv_7_val = invoice_data_var.data[h]._0;
7547                 invoice_data_arr_ptr[h] = invoice_data_conv_7_val;
7548         }
7549         (*env)->ReleasePrimitiveArrayCritical(env, invoice_data_arr, invoice_data_arr_ptr, 0);
7550         FREE(invoice_data_var.data);
7551         jclass receipient_conv = LDKRecipient_to_java(env, receipient);
7552         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7553         CHECK(obj != NULL);
7554         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->sign_invoice_meth, hrp_bytes_arr, invoice_data_arr, receipient_conv);
7555         if (UNLIKELY((*env)->ExceptionCheck(env))) {
7556                 (*env)->ExceptionDescribe(env);
7557                 (*env)->FatalError(env, "A call to sign_invoice in LDKKeysInterface from rust threw an exception.");
7558         }
7559         void* ret_ptr = untag_ptr(ret);
7560         CHECK_ACCESS(ret_ptr);
7561         LDKCResult_RecoverableSignatureNoneZ ret_conv = *(LDKCResult_RecoverableSignatureNoneZ*)(ret_ptr);
7562         FREE(untag_ptr(ret));
7563         if (get_jenv_res == JNI_EDETACHED) {
7564                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7565         }
7566         return ret_conv;
7567 }
7568 LDKThirtyTwoBytes get_inbound_payment_key_material_LDKKeysInterface_jcall(const void* this_arg) {
7569         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
7570         JNIEnv *env;
7571         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7572         if (get_jenv_res == JNI_EDETACHED) {
7573                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7574         } else {
7575                 DO_ASSERT(get_jenv_res == JNI_OK);
7576         }
7577         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7578         CHECK(obj != NULL);
7579         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_inbound_payment_key_material_meth);
7580         if (UNLIKELY((*env)->ExceptionCheck(env))) {
7581                 (*env)->ExceptionDescribe(env);
7582                 (*env)->FatalError(env, "A call to get_inbound_payment_key_material in LDKKeysInterface from rust threw an exception.");
7583         }
7584         LDKThirtyTwoBytes ret_ref;
7585         CHECK((*env)->GetArrayLength(env, ret) == 32);
7586         (*env)->GetByteArrayRegion(env, ret, 0, 32, ret_ref.data);
7587         if (get_jenv_res == JNI_EDETACHED) {
7588                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7589         }
7590         return ret_ref;
7591 }
7592 static void LDKKeysInterface_JCalls_cloned(LDKKeysInterface* new_obj) {
7593         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) new_obj->this_arg;
7594         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
7595 }
7596 static inline LDKKeysInterface LDKKeysInterface_init (JNIEnv *env, jclass clz, jobject o) {
7597         jclass c = (*env)->GetObjectClass(env, o);
7598         CHECK(c != NULL);
7599         LDKKeysInterface_JCalls *calls = MALLOC(sizeof(LDKKeysInterface_JCalls), "LDKKeysInterface_JCalls");
7600         atomic_init(&calls->refcnt, 1);
7601         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
7602         calls->o = (*env)->NewWeakGlobalRef(env, o);
7603         calls->get_node_secret_meth = (*env)->GetMethodID(env, c, "get_node_secret", "(Lorg/ldk/enums/Recipient;)J");
7604         CHECK(calls->get_node_secret_meth != NULL);
7605         calls->get_node_id_meth = (*env)->GetMethodID(env, c, "get_node_id", "(Lorg/ldk/enums/Recipient;)J");
7606         CHECK(calls->get_node_id_meth != NULL);
7607         calls->ecdh_meth = (*env)->GetMethodID(env, c, "ecdh", "(Lorg/ldk/enums/Recipient;[BJ)J");
7608         CHECK(calls->ecdh_meth != NULL);
7609         calls->get_destination_script_meth = (*env)->GetMethodID(env, c, "get_destination_script", "()[B");
7610         CHECK(calls->get_destination_script_meth != NULL);
7611         calls->get_shutdown_scriptpubkey_meth = (*env)->GetMethodID(env, c, "get_shutdown_scriptpubkey", "()J");
7612         CHECK(calls->get_shutdown_scriptpubkey_meth != NULL);
7613         calls->generate_channel_keys_id_meth = (*env)->GetMethodID(env, c, "generate_channel_keys_id", "(ZJ[B)[B");
7614         CHECK(calls->generate_channel_keys_id_meth != NULL);
7615         calls->derive_channel_signer_meth = (*env)->GetMethodID(env, c, "derive_channel_signer", "(J[B)J");
7616         CHECK(calls->derive_channel_signer_meth != NULL);
7617         calls->get_secure_random_bytes_meth = (*env)->GetMethodID(env, c, "get_secure_random_bytes", "()[B");
7618         CHECK(calls->get_secure_random_bytes_meth != NULL);
7619         calls->read_chan_signer_meth = (*env)->GetMethodID(env, c, "read_chan_signer", "([B)J");
7620         CHECK(calls->read_chan_signer_meth != NULL);
7621         calls->sign_invoice_meth = (*env)->GetMethodID(env, c, "sign_invoice", "([B[BLorg/ldk/enums/Recipient;)J");
7622         CHECK(calls->sign_invoice_meth != NULL);
7623         calls->get_inbound_payment_key_material_meth = (*env)->GetMethodID(env, c, "get_inbound_payment_key_material", "()[B");
7624         CHECK(calls->get_inbound_payment_key_material_meth != NULL);
7625
7626         LDKKeysInterface ret = {
7627                 .this_arg = (void*) calls,
7628                 .get_node_secret = get_node_secret_LDKKeysInterface_jcall,
7629                 .get_node_id = get_node_id_LDKKeysInterface_jcall,
7630                 .ecdh = ecdh_LDKKeysInterface_jcall,
7631                 .get_destination_script = get_destination_script_LDKKeysInterface_jcall,
7632                 .get_shutdown_scriptpubkey = get_shutdown_scriptpubkey_LDKKeysInterface_jcall,
7633                 .generate_channel_keys_id = generate_channel_keys_id_LDKKeysInterface_jcall,
7634                 .derive_channel_signer = derive_channel_signer_LDKKeysInterface_jcall,
7635                 .get_secure_random_bytes = get_secure_random_bytes_LDKKeysInterface_jcall,
7636                 .read_chan_signer = read_chan_signer_LDKKeysInterface_jcall,
7637                 .sign_invoice = sign_invoice_LDKKeysInterface_jcall,
7638                 .get_inbound_payment_key_material = get_inbound_payment_key_material_LDKKeysInterface_jcall,
7639                 .free = LDKKeysInterface_JCalls_free,
7640         };
7641         return ret;
7642 }
7643 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKKeysInterface_1new(JNIEnv *env, jclass clz, jobject o) {
7644         LDKKeysInterface *res_ptr = MALLOC(sizeof(LDKKeysInterface), "LDKKeysInterface");
7645         *res_ptr = LDKKeysInterface_init(env, clz, o);
7646         return tag_ptr(res_ptr, true);
7647 }
7648 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1node_1secret(JNIEnv *env, jclass clz, int64_t this_arg, jclass recipient) {
7649         void* this_arg_ptr = untag_ptr(this_arg);
7650         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
7651         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
7652         LDKRecipient recipient_conv = LDKRecipient_from_java(env, recipient);
7653         LDKCResult_SecretKeyNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyNoneZ), "LDKCResult_SecretKeyNoneZ");
7654         *ret_conv = (this_arg_conv->get_node_secret)(this_arg_conv->this_arg, recipient_conv);
7655         return tag_ptr(ret_conv, true);
7656 }
7657
7658 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1node_1id(JNIEnv *env, jclass clz, int64_t this_arg, jclass recipient) {
7659         void* this_arg_ptr = untag_ptr(this_arg);
7660         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
7661         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
7662         LDKRecipient recipient_conv = LDKRecipient_from_java(env, recipient);
7663         LDKCResult_PublicKeyNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyNoneZ), "LDKCResult_PublicKeyNoneZ");
7664         *ret_conv = (this_arg_conv->get_node_id)(this_arg_conv->this_arg, recipient_conv);
7665         return tag_ptr(ret_conv, true);
7666 }
7667
7668 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) {
7669         void* this_arg_ptr = untag_ptr(this_arg);
7670         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
7671         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
7672         LDKRecipient recipient_conv = LDKRecipient_from_java(env, recipient);
7673         LDKPublicKey other_key_ref;
7674         CHECK((*env)->GetArrayLength(env, other_key) == 33);
7675         (*env)->GetByteArrayRegion(env, other_key, 0, 33, other_key_ref.compressed_form);
7676         void* tweak_ptr = untag_ptr(tweak);
7677         CHECK_ACCESS(tweak_ptr);
7678         LDKCOption_ScalarZ tweak_conv = *(LDKCOption_ScalarZ*)(tweak_ptr);
7679         // WARNING: we may need a move here but no clone is available for LDKCOption_ScalarZ
7680         LDKCResult_SharedSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SharedSecretNoneZ), "LDKCResult_SharedSecretNoneZ");
7681         *ret_conv = (this_arg_conv->ecdh)(this_arg_conv->this_arg, recipient_conv, other_key_ref, tweak_conv);
7682         return tag_ptr(ret_conv, true);
7683 }
7684
7685 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1destination_1script(JNIEnv *env, jclass clz, int64_t this_arg) {
7686         void* this_arg_ptr = untag_ptr(this_arg);
7687         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
7688         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
7689         LDKCVec_u8Z ret_var = (this_arg_conv->get_destination_script)(this_arg_conv->this_arg);
7690         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
7691         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
7692         CVec_u8Z_free(ret_var);
7693         return ret_arr;
7694 }
7695
7696 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1shutdown_1scriptpubkey(JNIEnv *env, jclass clz, int64_t this_arg) {
7697         void* this_arg_ptr = untag_ptr(this_arg);
7698         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
7699         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
7700         LDKShutdownScript ret_var = (this_arg_conv->get_shutdown_scriptpubkey)(this_arg_conv->this_arg);
7701         int64_t ret_ref = 0;
7702         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7703         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
7704         return ret_ref;
7705 }
7706
7707 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_KeysInterface_1generate_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_arg, jboolean inbound, int64_t channel_value_satoshis, int8_tArray user_channel_id) {
7708         void* this_arg_ptr = untag_ptr(this_arg);
7709         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
7710         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
7711         LDKU128 user_channel_id_ref;
7712         CHECK((*env)->GetArrayLength(env, user_channel_id) == 16);
7713         (*env)->GetByteArrayRegion(env, user_channel_id, 0, 16, user_channel_id_ref.le_bytes);
7714         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
7715         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, (this_arg_conv->generate_channel_keys_id)(this_arg_conv->this_arg, inbound, channel_value_satoshis, user_channel_id_ref).data);
7716         return ret_arr;
7717 }
7718
7719 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_KeysInterface_1derive_1channel_1signer(JNIEnv *env, jclass clz, int64_t this_arg, int64_t channel_value_satoshis, int8_tArray channel_keys_id) {
7720         void* this_arg_ptr = untag_ptr(this_arg);
7721         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
7722         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
7723         LDKThirtyTwoBytes channel_keys_id_ref;
7724         CHECK((*env)->GetArrayLength(env, channel_keys_id) == 32);
7725         (*env)->GetByteArrayRegion(env, channel_keys_id, 0, 32, channel_keys_id_ref.data);
7726         LDKSign* ret_ret = MALLOC(sizeof(LDKSign), "LDKSign");
7727         *ret_ret = (this_arg_conv->derive_channel_signer)(this_arg_conv->this_arg, channel_value_satoshis, channel_keys_id_ref);
7728         return tag_ptr(ret_ret, true);
7729 }
7730
7731 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1secure_1random_1bytes(JNIEnv *env, jclass clz, int64_t this_arg) {
7732         void* this_arg_ptr = untag_ptr(this_arg);
7733         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
7734         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
7735         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
7736         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, (this_arg_conv->get_secure_random_bytes)(this_arg_conv->this_arg).data);
7737         return ret_arr;
7738 }
7739
7740 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_KeysInterface_1read_1chan_1signer(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray reader) {
7741         void* this_arg_ptr = untag_ptr(this_arg);
7742         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
7743         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
7744         LDKu8slice reader_ref;
7745         reader_ref.datalen = (*env)->GetArrayLength(env, reader);
7746         reader_ref.data = (*env)->GetByteArrayElements (env, reader, NULL);
7747         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
7748         *ret_conv = (this_arg_conv->read_chan_signer)(this_arg_conv->this_arg, reader_ref);
7749         (*env)->ReleaseByteArrayElements(env, reader, (int8_t*)reader_ref.data, 0);
7750         return tag_ptr(ret_conv, true);
7751 }
7752
7753 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) {
7754         void* this_arg_ptr = untag_ptr(this_arg);
7755         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
7756         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
7757         LDKu8slice hrp_bytes_ref;
7758         hrp_bytes_ref.datalen = (*env)->GetArrayLength(env, hrp_bytes);
7759         hrp_bytes_ref.data = (*env)->GetByteArrayElements (env, hrp_bytes, NULL);
7760         LDKCVec_U5Z invoice_data_constr;
7761         invoice_data_constr.datalen = (*env)->GetArrayLength(env, invoice_data);
7762         if (invoice_data_constr.datalen > 0)
7763                 invoice_data_constr.data = MALLOC(invoice_data_constr.datalen * sizeof(LDKU5), "LDKCVec_U5Z Elements");
7764         else
7765                 invoice_data_constr.data = NULL;
7766         int8_t* invoice_data_vals = (*env)->GetByteArrayElements (env, invoice_data, NULL);
7767         for (size_t h = 0; h < invoice_data_constr.datalen; h++) {
7768                 int8_t invoice_data_conv_7 = invoice_data_vals[h];
7769                 
7770                 invoice_data_constr.data[h] = (LDKU5){ ._0 = invoice_data_conv_7 };
7771         }
7772         (*env)->ReleaseByteArrayElements(env, invoice_data, invoice_data_vals, 0);
7773         LDKRecipient receipient_conv = LDKRecipient_from_java(env, receipient);
7774         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
7775         *ret_conv = (this_arg_conv->sign_invoice)(this_arg_conv->this_arg, hrp_bytes_ref, invoice_data_constr, receipient_conv);
7776         (*env)->ReleaseByteArrayElements(env, hrp_bytes, (int8_t*)hrp_bytes_ref.data, 0);
7777         return tag_ptr(ret_conv, true);
7778 }
7779
7780 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1inbound_1payment_1key_1material(JNIEnv *env, jclass clz, int64_t this_arg) {
7781         void* this_arg_ptr = untag_ptr(this_arg);
7782         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
7783         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
7784         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
7785         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, (this_arg_conv->get_inbound_payment_key_material)(this_arg_conv->this_arg).data);
7786         return ret_arr;
7787 }
7788
7789 typedef struct LDKFeeEstimator_JCalls {
7790         atomic_size_t refcnt;
7791         JavaVM *vm;
7792         jweak o;
7793         jmethodID get_est_sat_per_1000_weight_meth;
7794 } LDKFeeEstimator_JCalls;
7795 static void LDKFeeEstimator_JCalls_free(void* this_arg) {
7796         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) this_arg;
7797         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
7798                 JNIEnv *env;
7799                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7800                 if (get_jenv_res == JNI_EDETACHED) {
7801                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7802                 } else {
7803                         DO_ASSERT(get_jenv_res == JNI_OK);
7804                 }
7805                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
7806                 if (get_jenv_res == JNI_EDETACHED) {
7807                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7808                 }
7809                 FREE(j_calls);
7810         }
7811 }
7812 uint32_t get_est_sat_per_1000_weight_LDKFeeEstimator_jcall(const void* this_arg, LDKConfirmationTarget confirmation_target) {
7813         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) this_arg;
7814         JNIEnv *env;
7815         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7816         if (get_jenv_res == JNI_EDETACHED) {
7817                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7818         } else {
7819                 DO_ASSERT(get_jenv_res == JNI_OK);
7820         }
7821         jclass confirmation_target_conv = LDKConfirmationTarget_to_java(env, confirmation_target);
7822         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7823         CHECK(obj != NULL);
7824         int32_t ret = (*env)->CallIntMethod(env, obj, j_calls->get_est_sat_per_1000_weight_meth, confirmation_target_conv);
7825         if (UNLIKELY((*env)->ExceptionCheck(env))) {
7826                 (*env)->ExceptionDescribe(env);
7827                 (*env)->FatalError(env, "A call to get_est_sat_per_1000_weight in LDKFeeEstimator from rust threw an exception.");
7828         }
7829         if (get_jenv_res == JNI_EDETACHED) {
7830                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7831         }
7832         return ret;
7833 }
7834 static void LDKFeeEstimator_JCalls_cloned(LDKFeeEstimator* new_obj) {
7835         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) new_obj->this_arg;
7836         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
7837 }
7838 static inline LDKFeeEstimator LDKFeeEstimator_init (JNIEnv *env, jclass clz, jobject o) {
7839         jclass c = (*env)->GetObjectClass(env, o);
7840         CHECK(c != NULL);
7841         LDKFeeEstimator_JCalls *calls = MALLOC(sizeof(LDKFeeEstimator_JCalls), "LDKFeeEstimator_JCalls");
7842         atomic_init(&calls->refcnt, 1);
7843         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
7844         calls->o = (*env)->NewWeakGlobalRef(env, o);
7845         calls->get_est_sat_per_1000_weight_meth = (*env)->GetMethodID(env, c, "get_est_sat_per_1000_weight", "(Lorg/ldk/enums/ConfirmationTarget;)I");
7846         CHECK(calls->get_est_sat_per_1000_weight_meth != NULL);
7847
7848         LDKFeeEstimator ret = {
7849                 .this_arg = (void*) calls,
7850                 .get_est_sat_per_1000_weight = get_est_sat_per_1000_weight_LDKFeeEstimator_jcall,
7851                 .free = LDKFeeEstimator_JCalls_free,
7852         };
7853         return ret;
7854 }
7855 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKFeeEstimator_1new(JNIEnv *env, jclass clz, jobject o) {
7856         LDKFeeEstimator *res_ptr = MALLOC(sizeof(LDKFeeEstimator), "LDKFeeEstimator");
7857         *res_ptr = LDKFeeEstimator_init(env, clz, o);
7858         return tag_ptr(res_ptr, true);
7859 }
7860 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) {
7861         void* this_arg_ptr = untag_ptr(this_arg);
7862         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
7863         LDKFeeEstimator* this_arg_conv = (LDKFeeEstimator*)this_arg_ptr;
7864         LDKConfirmationTarget confirmation_target_conv = LDKConfirmationTarget_from_java(env, confirmation_target);
7865         int32_t ret_conv = (this_arg_conv->get_est_sat_per_1000_weight)(this_arg_conv->this_arg, confirmation_target_conv);
7866         return ret_conv;
7867 }
7868
7869 static inline struct LDKThirtyTwoBytes C2Tuple_BlockHashChannelManagerZ_get_a(LDKC2Tuple_BlockHashChannelManagerZ *NONNULL_PTR owner){
7870         return ThirtyTwoBytes_clone(&owner->a);
7871 }
7872 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelManagerZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
7873         LDKC2Tuple_BlockHashChannelManagerZ* owner_conv = (LDKC2Tuple_BlockHashChannelManagerZ*)untag_ptr(owner);
7874         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
7875         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_BlockHashChannelManagerZ_get_a(owner_conv).data);
7876         return ret_arr;
7877 }
7878
7879 static inline struct LDKChannelManager C2Tuple_BlockHashChannelManagerZ_get_b(LDKC2Tuple_BlockHashChannelManagerZ *NONNULL_PTR owner){
7880         LDKChannelManager ret = owner->b;
7881         ret.is_owned = false;
7882         return ret;
7883 }
7884 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelManagerZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
7885         LDKC2Tuple_BlockHashChannelManagerZ* owner_conv = (LDKC2Tuple_BlockHashChannelManagerZ*)untag_ptr(owner);
7886         LDKChannelManager ret_var = C2Tuple_BlockHashChannelManagerZ_get_b(owner_conv);
7887         int64_t ret_ref = 0;
7888         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7889         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
7890         return ret_ref;
7891 }
7892
7893 static inline struct LDKC2Tuple_BlockHashChannelManagerZ *CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_ok(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ *NONNULL_PTR owner){
7894 CHECK(owner->result_ok);
7895         return &*owner->contents.result;
7896 }
7897 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7898         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* owner_conv = (LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)untag_ptr(owner);
7899         int64_t ret_ret = tag_ptr(CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_ok(owner_conv), false);
7900         return ret_ret;
7901 }
7902
7903 static inline struct LDKDecodeError CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_err(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ *NONNULL_PTR owner){
7904 CHECK(!owner->result_ok);
7905         return DecodeError_clone(&*owner->contents.err);
7906 }
7907 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7908         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* owner_conv = (LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)untag_ptr(owner);
7909         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
7910         *ret_copy = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_get_err(owner_conv);
7911         int64_t ret_ref = tag_ptr(ret_copy, true);
7912         return ret_ref;
7913 }
7914
7915 static inline struct LDKChannelConfig CResult_ChannelConfigDecodeErrorZ_get_ok(LDKCResult_ChannelConfigDecodeErrorZ *NONNULL_PTR owner){
7916         LDKChannelConfig ret = *owner->contents.result;
7917         ret.is_owned = false;
7918         return ret;
7919 }
7920 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7921         LDKCResult_ChannelConfigDecodeErrorZ* owner_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)untag_ptr(owner);
7922         LDKChannelConfig ret_var = CResult_ChannelConfigDecodeErrorZ_get_ok(owner_conv);
7923         int64_t ret_ref = 0;
7924         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7925         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
7926         return ret_ref;
7927 }
7928
7929 static inline struct LDKDecodeError CResult_ChannelConfigDecodeErrorZ_get_err(LDKCResult_ChannelConfigDecodeErrorZ *NONNULL_PTR owner){
7930 CHECK(!owner->result_ok);
7931         return DecodeError_clone(&*owner->contents.err);
7932 }
7933 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7934         LDKCResult_ChannelConfigDecodeErrorZ* owner_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)untag_ptr(owner);
7935         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
7936         *ret_copy = CResult_ChannelConfigDecodeErrorZ_get_err(owner_conv);
7937         int64_t ret_ref = tag_ptr(ret_copy, true);
7938         return ret_ref;
7939 }
7940
7941 static inline struct LDKOutPoint CResult_OutPointDecodeErrorZ_get_ok(LDKCResult_OutPointDecodeErrorZ *NONNULL_PTR owner){
7942         LDKOutPoint ret = *owner->contents.result;
7943         ret.is_owned = false;
7944         return ret;
7945 }
7946 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
7947         LDKCResult_OutPointDecodeErrorZ* owner_conv = (LDKCResult_OutPointDecodeErrorZ*)untag_ptr(owner);
7948         LDKOutPoint ret_var = CResult_OutPointDecodeErrorZ_get_ok(owner_conv);
7949         int64_t ret_ref = 0;
7950         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
7951         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
7952         return ret_ref;
7953 }
7954
7955 static inline struct LDKDecodeError CResult_OutPointDecodeErrorZ_get_err(LDKCResult_OutPointDecodeErrorZ *NONNULL_PTR owner){
7956 CHECK(!owner->result_ok);
7957         return DecodeError_clone(&*owner->contents.err);
7958 }
7959 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
7960         LDKCResult_OutPointDecodeErrorZ* owner_conv = (LDKCResult_OutPointDecodeErrorZ*)untag_ptr(owner);
7961         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
7962         *ret_copy = CResult_OutPointDecodeErrorZ_get_err(owner_conv);
7963         int64_t ret_ref = tag_ptr(ret_copy, true);
7964         return ret_ref;
7965 }
7966
7967 typedef struct LDKType_JCalls {
7968         atomic_size_t refcnt;
7969         JavaVM *vm;
7970         jweak o;
7971         jmethodID type_id_meth;
7972         jmethodID debug_str_meth;
7973         jmethodID write_meth;
7974 } LDKType_JCalls;
7975 static void LDKType_JCalls_free(void* this_arg) {
7976         LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg;
7977         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
7978                 JNIEnv *env;
7979                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7980                 if (get_jenv_res == JNI_EDETACHED) {
7981                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7982                 } else {
7983                         DO_ASSERT(get_jenv_res == JNI_OK);
7984                 }
7985                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
7986                 if (get_jenv_res == JNI_EDETACHED) {
7987                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7988                 }
7989                 FREE(j_calls);
7990         }
7991 }
7992 uint16_t type_id_LDKType_jcall(const void* this_arg) {
7993         LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg;
7994         JNIEnv *env;
7995         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7996         if (get_jenv_res == JNI_EDETACHED) {
7997                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7998         } else {
7999                 DO_ASSERT(get_jenv_res == JNI_OK);
8000         }
8001         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8002         CHECK(obj != NULL);
8003         int16_t ret = (*env)->CallShortMethod(env, obj, j_calls->type_id_meth);
8004         if (UNLIKELY((*env)->ExceptionCheck(env))) {
8005                 (*env)->ExceptionDescribe(env);
8006                 (*env)->FatalError(env, "A call to type_id in LDKType from rust threw an exception.");
8007         }
8008         if (get_jenv_res == JNI_EDETACHED) {
8009                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8010         }
8011         return ret;
8012 }
8013 LDKStr debug_str_LDKType_jcall(const void* this_arg) {
8014         LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg;
8015         JNIEnv *env;
8016         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8017         if (get_jenv_res == JNI_EDETACHED) {
8018                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8019         } else {
8020                 DO_ASSERT(get_jenv_res == JNI_OK);
8021         }
8022         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8023         CHECK(obj != NULL);
8024         jstring ret = (*env)->CallObjectMethod(env, obj, j_calls->debug_str_meth);
8025         if (UNLIKELY((*env)->ExceptionCheck(env))) {
8026                 (*env)->ExceptionDescribe(env);
8027                 (*env)->FatalError(env, "A call to debug_str in LDKType from rust threw an exception.");
8028         }
8029         LDKStr ret_conv = java_to_owned_str(env, ret);
8030         if (get_jenv_res == JNI_EDETACHED) {
8031                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8032         }
8033         return ret_conv;
8034 }
8035 LDKCVec_u8Z write_LDKType_jcall(const void* this_arg) {
8036         LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg;
8037         JNIEnv *env;
8038         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8039         if (get_jenv_res == JNI_EDETACHED) {
8040                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8041         } else {
8042                 DO_ASSERT(get_jenv_res == JNI_OK);
8043         }
8044         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8045         CHECK(obj != NULL);
8046         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->write_meth);
8047         if (UNLIKELY((*env)->ExceptionCheck(env))) {
8048                 (*env)->ExceptionDescribe(env);
8049                 (*env)->FatalError(env, "A call to write in LDKType from rust threw an exception.");
8050         }
8051         LDKCVec_u8Z ret_ref;
8052         ret_ref.datalen = (*env)->GetArrayLength(env, ret);
8053         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
8054         (*env)->GetByteArrayRegion(env, ret, 0, ret_ref.datalen, ret_ref.data);
8055         if (get_jenv_res == JNI_EDETACHED) {
8056                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8057         }
8058         return ret_ref;
8059 }
8060 static void LDKType_JCalls_cloned(LDKType* new_obj) {
8061         LDKType_JCalls *j_calls = (LDKType_JCalls*) new_obj->this_arg;
8062         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
8063 }
8064 static inline LDKType LDKType_init (JNIEnv *env, jclass clz, jobject o) {
8065         jclass c = (*env)->GetObjectClass(env, o);
8066         CHECK(c != NULL);
8067         LDKType_JCalls *calls = MALLOC(sizeof(LDKType_JCalls), "LDKType_JCalls");
8068         atomic_init(&calls->refcnt, 1);
8069         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
8070         calls->o = (*env)->NewWeakGlobalRef(env, o);
8071         calls->type_id_meth = (*env)->GetMethodID(env, c, "type_id", "()S");
8072         CHECK(calls->type_id_meth != NULL);
8073         calls->debug_str_meth = (*env)->GetMethodID(env, c, "debug_str", "()Ljava/lang/String;");
8074         CHECK(calls->debug_str_meth != NULL);
8075         calls->write_meth = (*env)->GetMethodID(env, c, "write", "()[B");
8076         CHECK(calls->write_meth != NULL);
8077
8078         LDKType ret = {
8079                 .this_arg = (void*) calls,
8080                 .type_id = type_id_LDKType_jcall,
8081                 .debug_str = debug_str_LDKType_jcall,
8082                 .write = write_LDKType_jcall,
8083                 .cloned = LDKType_JCalls_cloned,
8084                 .free = LDKType_JCalls_free,
8085         };
8086         return ret;
8087 }
8088 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKType_1new(JNIEnv *env, jclass clz, jobject o) {
8089         LDKType *res_ptr = MALLOC(sizeof(LDKType), "LDKType");
8090         *res_ptr = LDKType_init(env, clz, o);
8091         return tag_ptr(res_ptr, true);
8092 }
8093 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_Type_1type_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
8094         void* this_arg_ptr = untag_ptr(this_arg);
8095         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
8096         LDKType* this_arg_conv = (LDKType*)this_arg_ptr;
8097         int16_t ret_conv = (this_arg_conv->type_id)(this_arg_conv->this_arg);
8098         return ret_conv;
8099 }
8100
8101 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Type_1debug_1str(JNIEnv *env, jclass clz, int64_t this_arg) {
8102         void* this_arg_ptr = untag_ptr(this_arg);
8103         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
8104         LDKType* this_arg_conv = (LDKType*)this_arg_ptr;
8105         LDKStr ret_str = (this_arg_conv->debug_str)(this_arg_conv->this_arg);
8106         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
8107         Str_free(ret_str);
8108         return ret_conv;
8109 }
8110
8111 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Type_1write(JNIEnv *env, jclass clz, int64_t this_arg) {
8112         void* this_arg_ptr = untag_ptr(this_arg);
8113         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
8114         LDKType* this_arg_conv = (LDKType*)this_arg_ptr;
8115         LDKCVec_u8Z ret_var = (this_arg_conv->write)(this_arg_conv->this_arg);
8116         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
8117         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
8118         CVec_u8Z_free(ret_var);
8119         return ret_arr;
8120 }
8121
8122 static jclass LDKCOption_TypeZ_Some_class = NULL;
8123 static jmethodID LDKCOption_TypeZ_Some_meth = NULL;
8124 static jclass LDKCOption_TypeZ_None_class = NULL;
8125 static jmethodID LDKCOption_TypeZ_None_meth = NULL;
8126 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1TypeZ_init (JNIEnv *env, jclass clz) {
8127         LDKCOption_TypeZ_Some_class =
8128                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_TypeZ$Some"));
8129         CHECK(LDKCOption_TypeZ_Some_class != NULL);
8130         LDKCOption_TypeZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_TypeZ_Some_class, "<init>", "(J)V");
8131         CHECK(LDKCOption_TypeZ_Some_meth != NULL);
8132         LDKCOption_TypeZ_None_class =
8133                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_TypeZ$None"));
8134         CHECK(LDKCOption_TypeZ_None_class != NULL);
8135         LDKCOption_TypeZ_None_meth = (*env)->GetMethodID(env, LDKCOption_TypeZ_None_class, "<init>", "()V");
8136         CHECK(LDKCOption_TypeZ_None_meth != NULL);
8137 }
8138 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1TypeZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
8139         LDKCOption_TypeZ *obj = (LDKCOption_TypeZ*)untag_ptr(ptr);
8140         switch(obj->tag) {
8141                 case LDKCOption_TypeZ_Some: {
8142                         LDKType* some_ret = MALLOC(sizeof(LDKType), "LDKType");
8143                         *some_ret = Type_clone(&obj->some);
8144                         return (*env)->NewObject(env, LDKCOption_TypeZ_Some_class, LDKCOption_TypeZ_Some_meth, tag_ptr(some_ret, true));
8145                 }
8146                 case LDKCOption_TypeZ_None: {
8147                         return (*env)->NewObject(env, LDKCOption_TypeZ_None_class, LDKCOption_TypeZ_None_meth);
8148                 }
8149                 default: abort();
8150         }
8151 }
8152 static inline struct LDKCOption_TypeZ CResult_COption_TypeZDecodeErrorZ_get_ok(LDKCResult_COption_TypeZDecodeErrorZ *NONNULL_PTR owner){
8153 CHECK(owner->result_ok);
8154         return COption_TypeZ_clone(&*owner->contents.result);
8155 }
8156 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8157         LDKCResult_COption_TypeZDecodeErrorZ* owner_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)untag_ptr(owner);
8158         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
8159         *ret_copy = CResult_COption_TypeZDecodeErrorZ_get_ok(owner_conv);
8160         int64_t ret_ref = tag_ptr(ret_copy, true);
8161         return ret_ref;
8162 }
8163
8164 static inline struct LDKDecodeError CResult_COption_TypeZDecodeErrorZ_get_err(LDKCResult_COption_TypeZDecodeErrorZ *NONNULL_PTR owner){
8165 CHECK(!owner->result_ok);
8166         return DecodeError_clone(&*owner->contents.err);
8167 }
8168 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8169         LDKCResult_COption_TypeZDecodeErrorZ* owner_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)untag_ptr(owner);
8170         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
8171         *ret_copy = CResult_COption_TypeZDecodeErrorZ_get_err(owner_conv);
8172         int64_t ret_ref = tag_ptr(ret_copy, true);
8173         return ret_ref;
8174 }
8175
8176 static jclass LDKPaymentError_Invoice_class = NULL;
8177 static jmethodID LDKPaymentError_Invoice_meth = NULL;
8178 static jclass LDKPaymentError_Routing_class = NULL;
8179 static jmethodID LDKPaymentError_Routing_meth = NULL;
8180 static jclass LDKPaymentError_Sending_class = NULL;
8181 static jmethodID LDKPaymentError_Sending_meth = NULL;
8182 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKPaymentError_init (JNIEnv *env, jclass clz) {
8183         LDKPaymentError_Invoice_class =
8184                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKPaymentError$Invoice"));
8185         CHECK(LDKPaymentError_Invoice_class != NULL);
8186         LDKPaymentError_Invoice_meth = (*env)->GetMethodID(env, LDKPaymentError_Invoice_class, "<init>", "(Ljava/lang/String;)V");
8187         CHECK(LDKPaymentError_Invoice_meth != NULL);
8188         LDKPaymentError_Routing_class =
8189                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKPaymentError$Routing"));
8190         CHECK(LDKPaymentError_Routing_class != NULL);
8191         LDKPaymentError_Routing_meth = (*env)->GetMethodID(env, LDKPaymentError_Routing_class, "<init>", "(J)V");
8192         CHECK(LDKPaymentError_Routing_meth != NULL);
8193         LDKPaymentError_Sending_class =
8194                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKPaymentError$Sending"));
8195         CHECK(LDKPaymentError_Sending_class != NULL);
8196         LDKPaymentError_Sending_meth = (*env)->GetMethodID(env, LDKPaymentError_Sending_class, "<init>", "(J)V");
8197         CHECK(LDKPaymentError_Sending_meth != NULL);
8198 }
8199 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKPaymentError_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
8200         LDKPaymentError *obj = (LDKPaymentError*)untag_ptr(ptr);
8201         switch(obj->tag) {
8202                 case LDKPaymentError_Invoice: {
8203                         LDKStr invoice_str = obj->invoice;
8204                         jstring invoice_conv = str_ref_to_java(env, invoice_str.chars, invoice_str.len);
8205                         return (*env)->NewObject(env, LDKPaymentError_Invoice_class, LDKPaymentError_Invoice_meth, invoice_conv);
8206                 }
8207                 case LDKPaymentError_Routing: {
8208                         LDKLightningError routing_var = obj->routing;
8209                         int64_t routing_ref = 0;
8210                         CHECK_INNER_FIELD_ACCESS_OR_NULL(routing_var);
8211                         routing_ref = tag_ptr(routing_var.inner, false);
8212                         return (*env)->NewObject(env, LDKPaymentError_Routing_class, LDKPaymentError_Routing_meth, routing_ref);
8213                 }
8214                 case LDKPaymentError_Sending: {
8215                         int64_t sending_ref = tag_ptr(&obj->sending, false);
8216                         return (*env)->NewObject(env, LDKPaymentError_Sending_class, LDKPaymentError_Sending_meth, sending_ref);
8217                 }
8218                 default: abort();
8219         }
8220 }
8221 static inline struct LDKThirtyTwoBytes CResult_PaymentIdPaymentErrorZ_get_ok(LDKCResult_PaymentIdPaymentErrorZ *NONNULL_PTR owner){
8222 CHECK(owner->result_ok);
8223         return ThirtyTwoBytes_clone(&*owner->contents.result);
8224 }
8225 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8226         LDKCResult_PaymentIdPaymentErrorZ* owner_conv = (LDKCResult_PaymentIdPaymentErrorZ*)untag_ptr(owner);
8227         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
8228         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, CResult_PaymentIdPaymentErrorZ_get_ok(owner_conv).data);
8229         return ret_arr;
8230 }
8231
8232 static inline struct LDKPaymentError CResult_PaymentIdPaymentErrorZ_get_err(LDKCResult_PaymentIdPaymentErrorZ *NONNULL_PTR owner){
8233 CHECK(!owner->result_ok);
8234         return PaymentError_clone(&*owner->contents.err);
8235 }
8236 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8237         LDKCResult_PaymentIdPaymentErrorZ* owner_conv = (LDKCResult_PaymentIdPaymentErrorZ*)untag_ptr(owner);
8238         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
8239         *ret_copy = CResult_PaymentIdPaymentErrorZ_get_err(owner_conv);
8240         int64_t ret_ref = tag_ptr(ret_copy, true);
8241         return ret_ref;
8242 }
8243
8244 static inline void CResult_NonePaymentErrorZ_get_ok(LDKCResult_NonePaymentErrorZ *NONNULL_PTR owner){
8245 CHECK(owner->result_ok);
8246         return *owner->contents.result;
8247 }
8248 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8249         LDKCResult_NonePaymentErrorZ* owner_conv = (LDKCResult_NonePaymentErrorZ*)untag_ptr(owner);
8250         CResult_NonePaymentErrorZ_get_ok(owner_conv);
8251 }
8252
8253 static inline struct LDKPaymentError CResult_NonePaymentErrorZ_get_err(LDKCResult_NonePaymentErrorZ *NONNULL_PTR owner){
8254 CHECK(!owner->result_ok);
8255         return PaymentError_clone(&*owner->contents.err);
8256 }
8257 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8258         LDKCResult_NonePaymentErrorZ* owner_conv = (LDKCResult_NonePaymentErrorZ*)untag_ptr(owner);
8259         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
8260         *ret_copy = CResult_NonePaymentErrorZ_get_err(owner_conv);
8261         int64_t ret_ref = tag_ptr(ret_copy, true);
8262         return ret_ref;
8263 }
8264
8265 static inline struct LDKStr CResult_StringErrorZ_get_ok(LDKCResult_StringErrorZ *NONNULL_PTR owner){
8266 CHECK(owner->result_ok);
8267         return *owner->contents.result;
8268 }
8269 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8270         LDKCResult_StringErrorZ* owner_conv = (LDKCResult_StringErrorZ*)untag_ptr(owner);
8271         LDKStr ret_str = CResult_StringErrorZ_get_ok(owner_conv);
8272         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
8273         return ret_conv;
8274 }
8275
8276 static inline enum LDKSecp256k1Error CResult_StringErrorZ_get_err(LDKCResult_StringErrorZ *NONNULL_PTR owner){
8277 CHECK(!owner->result_ok);
8278         return *owner->contents.err;
8279 }
8280 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8281         LDKCResult_StringErrorZ* owner_conv = (LDKCResult_StringErrorZ*)untag_ptr(owner);
8282         jclass ret_conv = LDKSecp256k1Error_to_java(env, CResult_StringErrorZ_get_err(owner_conv));
8283         return ret_conv;
8284 }
8285
8286 static inline struct LDKPublicKey CResult_PublicKeyErrorZ_get_ok(LDKCResult_PublicKeyErrorZ *NONNULL_PTR owner){
8287 CHECK(owner->result_ok);
8288         return *owner->contents.result;
8289 }
8290 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8291         LDKCResult_PublicKeyErrorZ* owner_conv = (LDKCResult_PublicKeyErrorZ*)untag_ptr(owner);
8292         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
8293         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, CResult_PublicKeyErrorZ_get_ok(owner_conv).compressed_form);
8294         return ret_arr;
8295 }
8296
8297 static inline enum LDKSecp256k1Error CResult_PublicKeyErrorZ_get_err(LDKCResult_PublicKeyErrorZ *NONNULL_PTR owner){
8298 CHECK(!owner->result_ok);
8299         return *owner->contents.err;
8300 }
8301 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8302         LDKCResult_PublicKeyErrorZ* owner_conv = (LDKCResult_PublicKeyErrorZ*)untag_ptr(owner);
8303         jclass ret_conv = LDKSecp256k1Error_to_java(env, CResult_PublicKeyErrorZ_get_err(owner_conv));
8304         return ret_conv;
8305 }
8306
8307 static inline struct LDKChannelMonitorUpdate CResult_ChannelMonitorUpdateDecodeErrorZ_get_ok(LDKCResult_ChannelMonitorUpdateDecodeErrorZ *NONNULL_PTR owner){
8308         LDKChannelMonitorUpdate ret = *owner->contents.result;
8309         ret.is_owned = false;
8310         return ret;
8311 }
8312 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8313         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* owner_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)untag_ptr(owner);
8314         LDKChannelMonitorUpdate ret_var = CResult_ChannelMonitorUpdateDecodeErrorZ_get_ok(owner_conv);
8315         int64_t ret_ref = 0;
8316         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8317         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
8318         return ret_ref;
8319 }
8320
8321 static inline struct LDKDecodeError CResult_ChannelMonitorUpdateDecodeErrorZ_get_err(LDKCResult_ChannelMonitorUpdateDecodeErrorZ *NONNULL_PTR owner){
8322 CHECK(!owner->result_ok);
8323         return DecodeError_clone(&*owner->contents.err);
8324 }
8325 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8326         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* owner_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)untag_ptr(owner);
8327         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
8328         *ret_copy = CResult_ChannelMonitorUpdateDecodeErrorZ_get_err(owner_conv);
8329         int64_t ret_ref = tag_ptr(ret_copy, true);
8330         return ret_ref;
8331 }
8332
8333 static jclass LDKCOption_MonitorEventZ_Some_class = NULL;
8334 static jmethodID LDKCOption_MonitorEventZ_Some_meth = NULL;
8335 static jclass LDKCOption_MonitorEventZ_None_class = NULL;
8336 static jmethodID LDKCOption_MonitorEventZ_None_meth = NULL;
8337 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1MonitorEventZ_init (JNIEnv *env, jclass clz) {
8338         LDKCOption_MonitorEventZ_Some_class =
8339                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_MonitorEventZ$Some"));
8340         CHECK(LDKCOption_MonitorEventZ_Some_class != NULL);
8341         LDKCOption_MonitorEventZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_MonitorEventZ_Some_class, "<init>", "(J)V");
8342         CHECK(LDKCOption_MonitorEventZ_Some_meth != NULL);
8343         LDKCOption_MonitorEventZ_None_class =
8344                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_MonitorEventZ$None"));
8345         CHECK(LDKCOption_MonitorEventZ_None_class != NULL);
8346         LDKCOption_MonitorEventZ_None_meth = (*env)->GetMethodID(env, LDKCOption_MonitorEventZ_None_class, "<init>", "()V");
8347         CHECK(LDKCOption_MonitorEventZ_None_meth != NULL);
8348 }
8349 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1MonitorEventZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
8350         LDKCOption_MonitorEventZ *obj = (LDKCOption_MonitorEventZ*)untag_ptr(ptr);
8351         switch(obj->tag) {
8352                 case LDKCOption_MonitorEventZ_Some: {
8353                         int64_t some_ref = tag_ptr(&obj->some, false);
8354                         return (*env)->NewObject(env, LDKCOption_MonitorEventZ_Some_class, LDKCOption_MonitorEventZ_Some_meth, some_ref);
8355                 }
8356                 case LDKCOption_MonitorEventZ_None: {
8357                         return (*env)->NewObject(env, LDKCOption_MonitorEventZ_None_class, LDKCOption_MonitorEventZ_None_meth);
8358                 }
8359                 default: abort();
8360         }
8361 }
8362 static inline struct LDKCOption_MonitorEventZ CResult_COption_MonitorEventZDecodeErrorZ_get_ok(LDKCResult_COption_MonitorEventZDecodeErrorZ *NONNULL_PTR owner){
8363 CHECK(owner->result_ok);
8364         return COption_MonitorEventZ_clone(&*owner->contents.result);
8365 }
8366 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1MonitorEventZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8367         LDKCResult_COption_MonitorEventZDecodeErrorZ* owner_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)untag_ptr(owner);
8368         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
8369         *ret_copy = CResult_COption_MonitorEventZDecodeErrorZ_get_ok(owner_conv);
8370         int64_t ret_ref = tag_ptr(ret_copy, true);
8371         return ret_ref;
8372 }
8373
8374 static inline struct LDKDecodeError CResult_COption_MonitorEventZDecodeErrorZ_get_err(LDKCResult_COption_MonitorEventZDecodeErrorZ *NONNULL_PTR owner){
8375 CHECK(!owner->result_ok);
8376         return DecodeError_clone(&*owner->contents.err);
8377 }
8378 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1MonitorEventZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8379         LDKCResult_COption_MonitorEventZDecodeErrorZ* owner_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)untag_ptr(owner);
8380         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
8381         *ret_copy = CResult_COption_MonitorEventZDecodeErrorZ_get_err(owner_conv);
8382         int64_t ret_ref = tag_ptr(ret_copy, true);
8383         return ret_ref;
8384 }
8385
8386 static inline struct LDKHTLCUpdate CResult_HTLCUpdateDecodeErrorZ_get_ok(LDKCResult_HTLCUpdateDecodeErrorZ *NONNULL_PTR owner){
8387         LDKHTLCUpdate ret = *owner->contents.result;
8388         ret.is_owned = false;
8389         return ret;
8390 }
8391 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8392         LDKCResult_HTLCUpdateDecodeErrorZ* owner_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)untag_ptr(owner);
8393         LDKHTLCUpdate ret_var = CResult_HTLCUpdateDecodeErrorZ_get_ok(owner_conv);
8394         int64_t ret_ref = 0;
8395         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8396         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
8397         return ret_ref;
8398 }
8399
8400 static inline struct LDKDecodeError CResult_HTLCUpdateDecodeErrorZ_get_err(LDKCResult_HTLCUpdateDecodeErrorZ *NONNULL_PTR owner){
8401 CHECK(!owner->result_ok);
8402         return DecodeError_clone(&*owner->contents.err);
8403 }
8404 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8405         LDKCResult_HTLCUpdateDecodeErrorZ* owner_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)untag_ptr(owner);
8406         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
8407         *ret_copy = CResult_HTLCUpdateDecodeErrorZ_get_err(owner_conv);
8408         int64_t ret_ref = tag_ptr(ret_copy, true);
8409         return ret_ref;
8410 }
8411
8412 static inline struct LDKOutPoint C2Tuple_OutPointScriptZ_get_a(LDKC2Tuple_OutPointScriptZ *NONNULL_PTR owner){
8413         LDKOutPoint ret = owner->a;
8414         ret.is_owned = false;
8415         return ret;
8416 }
8417 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
8418         LDKC2Tuple_OutPointScriptZ* owner_conv = (LDKC2Tuple_OutPointScriptZ*)untag_ptr(owner);
8419         LDKOutPoint ret_var = C2Tuple_OutPointScriptZ_get_a(owner_conv);
8420         int64_t ret_ref = 0;
8421         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8422         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
8423         return ret_ref;
8424 }
8425
8426 static inline struct LDKCVec_u8Z C2Tuple_OutPointScriptZ_get_b(LDKC2Tuple_OutPointScriptZ *NONNULL_PTR owner){
8427         return CVec_u8Z_clone(&owner->b);
8428 }
8429 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
8430         LDKC2Tuple_OutPointScriptZ* owner_conv = (LDKC2Tuple_OutPointScriptZ*)untag_ptr(owner);
8431         LDKCVec_u8Z ret_var = C2Tuple_OutPointScriptZ_get_b(owner_conv);
8432         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
8433         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
8434         CVec_u8Z_free(ret_var);
8435         return ret_arr;
8436 }
8437
8438 static inline uint32_t C2Tuple_u32ScriptZ_get_a(LDKC2Tuple_u32ScriptZ *NONNULL_PTR owner){
8439         return owner->a;
8440 }
8441 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32ScriptZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
8442         LDKC2Tuple_u32ScriptZ* owner_conv = (LDKC2Tuple_u32ScriptZ*)untag_ptr(owner);
8443         int32_t ret_conv = C2Tuple_u32ScriptZ_get_a(owner_conv);
8444         return ret_conv;
8445 }
8446
8447 static inline struct LDKCVec_u8Z C2Tuple_u32ScriptZ_get_b(LDKC2Tuple_u32ScriptZ *NONNULL_PTR owner){
8448         return CVec_u8Z_clone(&owner->b);
8449 }
8450 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32ScriptZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
8451         LDKC2Tuple_u32ScriptZ* owner_conv = (LDKC2Tuple_u32ScriptZ*)untag_ptr(owner);
8452         LDKCVec_u8Z ret_var = C2Tuple_u32ScriptZ_get_b(owner_conv);
8453         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
8454         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
8455         CVec_u8Z_free(ret_var);
8456         return ret_arr;
8457 }
8458
8459 static inline LDKCVec_C2Tuple_u32ScriptZZ CVec_C2Tuple_u32ScriptZZ_clone(const LDKCVec_C2Tuple_u32ScriptZZ *orig) {
8460         LDKCVec_C2Tuple_u32ScriptZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ) * orig->datalen, "LDKCVec_C2Tuple_u32ScriptZZ clone bytes"), .datalen = orig->datalen };
8461         for (size_t i = 0; i < ret.datalen; i++) {
8462                 ret.data[i] = C2Tuple_u32ScriptZ_clone(&orig->data[i]);
8463         }
8464         return ret;
8465 }
8466 static inline struct LDKThirtyTwoBytes C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_a(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ *NONNULL_PTR owner){
8467         return ThirtyTwoBytes_clone(&owner->a);
8468 }
8469 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
8470         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* owner_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)untag_ptr(owner);
8471         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
8472         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_a(owner_conv).data);
8473         return ret_arr;
8474 }
8475
8476 static inline struct LDKCVec_C2Tuple_u32ScriptZZ C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_b(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ *NONNULL_PTR owner){
8477         return CVec_C2Tuple_u32ScriptZZ_clone(&owner->b);
8478 }
8479 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
8480         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* owner_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)untag_ptr(owner);
8481         LDKCVec_C2Tuple_u32ScriptZZ ret_var = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_b(owner_conv);
8482         int64_tArray ret_arr = NULL;
8483         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
8484         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
8485         for (size_t v = 0; v < ret_var.datalen; v++) {
8486                 LDKC2Tuple_u32ScriptZ* ret_conv_21_conv = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
8487                 *ret_conv_21_conv = ret_var.data[v];
8488                 ret_arr_ptr[v] = tag_ptr(ret_conv_21_conv, true);
8489         }
8490         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
8491         FREE(ret_var.data);
8492         return ret_arr;
8493 }
8494
8495 static inline LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ_clone(const LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ *orig) {
8496         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 };
8497         for (size_t i = 0; i < ret.datalen; i++) {
8498                 ret.data[i] = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone(&orig->data[i]);
8499         }
8500         return ret;
8501 }
8502 static inline LDKCVec_EventZ CVec_EventZ_clone(const LDKCVec_EventZ *orig) {
8503         LDKCVec_EventZ ret = { .data = MALLOC(sizeof(LDKEvent) * orig->datalen, "LDKCVec_EventZ clone bytes"), .datalen = orig->datalen };
8504         for (size_t i = 0; i < ret.datalen; i++) {
8505                 ret.data[i] = Event_clone(&orig->data[i]);
8506         }
8507         return ret;
8508 }
8509 static inline uint32_t C2Tuple_u32TxOutZ_get_a(LDKC2Tuple_u32TxOutZ *NONNULL_PTR owner){
8510         return owner->a;
8511 }
8512 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
8513         LDKC2Tuple_u32TxOutZ* owner_conv = (LDKC2Tuple_u32TxOutZ*)untag_ptr(owner);
8514         int32_t ret_conv = C2Tuple_u32TxOutZ_get_a(owner_conv);
8515         return ret_conv;
8516 }
8517
8518 static inline struct LDKTxOut C2Tuple_u32TxOutZ_get_b(LDKC2Tuple_u32TxOutZ *NONNULL_PTR owner){
8519         return TxOut_clone(&owner->b);
8520 }
8521 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
8522         LDKC2Tuple_u32TxOutZ* owner_conv = (LDKC2Tuple_u32TxOutZ*)untag_ptr(owner);
8523         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
8524         *ret_ref = C2Tuple_u32TxOutZ_get_b(owner_conv);
8525         return tag_ptr(ret_ref, true);
8526 }
8527
8528 static inline LDKCVec_C2Tuple_u32TxOutZZ CVec_C2Tuple_u32TxOutZZ_clone(const LDKCVec_C2Tuple_u32TxOutZZ *orig) {
8529         LDKCVec_C2Tuple_u32TxOutZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ) * orig->datalen, "LDKCVec_C2Tuple_u32TxOutZZ clone bytes"), .datalen = orig->datalen };
8530         for (size_t i = 0; i < ret.datalen; i++) {
8531                 ret.data[i] = C2Tuple_u32TxOutZ_clone(&orig->data[i]);
8532         }
8533         return ret;
8534 }
8535 static inline struct LDKThirtyTwoBytes C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_a(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *NONNULL_PTR owner){
8536         return ThirtyTwoBytes_clone(&owner->a);
8537 }
8538 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
8539         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* owner_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)untag_ptr(owner);
8540         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
8541         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_a(owner_conv).data);
8542         return ret_arr;
8543 }
8544
8545 static inline struct LDKCVec_C2Tuple_u32TxOutZZ C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_b(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *NONNULL_PTR owner){
8546         return CVec_C2Tuple_u32TxOutZZ_clone(&owner->b);
8547 }
8548 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
8549         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* owner_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)untag_ptr(owner);
8550         LDKCVec_C2Tuple_u32TxOutZZ ret_var = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_b(owner_conv);
8551         int64_tArray ret_arr = NULL;
8552         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
8553         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
8554         for (size_t u = 0; u < ret_var.datalen; u++) {
8555                 LDKC2Tuple_u32TxOutZ* ret_conv_20_conv = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
8556                 *ret_conv_20_conv = ret_var.data[u];
8557                 ret_arr_ptr[u] = tag_ptr(ret_conv_20_conv, true);
8558         }
8559         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
8560         FREE(ret_var.data);
8561         return ret_arr;
8562 }
8563
8564 static inline LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_clone(const LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ *orig) {
8565         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 };
8566         for (size_t i = 0; i < ret.datalen; i++) {
8567                 ret.data[i] = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(&orig->data[i]);
8568         }
8569         return ret;
8570 }
8571 static jclass LDKBalance_ClaimableOnChannelClose_class = NULL;
8572 static jmethodID LDKBalance_ClaimableOnChannelClose_meth = NULL;
8573 static jclass LDKBalance_ClaimableAwaitingConfirmations_class = NULL;
8574 static jmethodID LDKBalance_ClaimableAwaitingConfirmations_meth = NULL;
8575 static jclass LDKBalance_ContentiousClaimable_class = NULL;
8576 static jmethodID LDKBalance_ContentiousClaimable_meth = NULL;
8577 static jclass LDKBalance_MaybeTimeoutClaimableHTLC_class = NULL;
8578 static jmethodID LDKBalance_MaybeTimeoutClaimableHTLC_meth = NULL;
8579 static jclass LDKBalance_MaybePreimageClaimableHTLC_class = NULL;
8580 static jmethodID LDKBalance_MaybePreimageClaimableHTLC_meth = NULL;
8581 static jclass LDKBalance_CounterpartyRevokedOutputClaimable_class = NULL;
8582 static jmethodID LDKBalance_CounterpartyRevokedOutputClaimable_meth = NULL;
8583 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKBalance_init (JNIEnv *env, jclass clz) {
8584         LDKBalance_ClaimableOnChannelClose_class =
8585                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBalance$ClaimableOnChannelClose"));
8586         CHECK(LDKBalance_ClaimableOnChannelClose_class != NULL);
8587         LDKBalance_ClaimableOnChannelClose_meth = (*env)->GetMethodID(env, LDKBalance_ClaimableOnChannelClose_class, "<init>", "(J)V");
8588         CHECK(LDKBalance_ClaimableOnChannelClose_meth != NULL);
8589         LDKBalance_ClaimableAwaitingConfirmations_class =
8590                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBalance$ClaimableAwaitingConfirmations"));
8591         CHECK(LDKBalance_ClaimableAwaitingConfirmations_class != NULL);
8592         LDKBalance_ClaimableAwaitingConfirmations_meth = (*env)->GetMethodID(env, LDKBalance_ClaimableAwaitingConfirmations_class, "<init>", "(JI)V");
8593         CHECK(LDKBalance_ClaimableAwaitingConfirmations_meth != NULL);
8594         LDKBalance_ContentiousClaimable_class =
8595                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBalance$ContentiousClaimable"));
8596         CHECK(LDKBalance_ContentiousClaimable_class != NULL);
8597         LDKBalance_ContentiousClaimable_meth = (*env)->GetMethodID(env, LDKBalance_ContentiousClaimable_class, "<init>", "(JI)V");
8598         CHECK(LDKBalance_ContentiousClaimable_meth != NULL);
8599         LDKBalance_MaybeTimeoutClaimableHTLC_class =
8600                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBalance$MaybeTimeoutClaimableHTLC"));
8601         CHECK(LDKBalance_MaybeTimeoutClaimableHTLC_class != NULL);
8602         LDKBalance_MaybeTimeoutClaimableHTLC_meth = (*env)->GetMethodID(env, LDKBalance_MaybeTimeoutClaimableHTLC_class, "<init>", "(JI)V");
8603         CHECK(LDKBalance_MaybeTimeoutClaimableHTLC_meth != NULL);
8604         LDKBalance_MaybePreimageClaimableHTLC_class =
8605                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBalance$MaybePreimageClaimableHTLC"));
8606         CHECK(LDKBalance_MaybePreimageClaimableHTLC_class != NULL);
8607         LDKBalance_MaybePreimageClaimableHTLC_meth = (*env)->GetMethodID(env, LDKBalance_MaybePreimageClaimableHTLC_class, "<init>", "(JI)V");
8608         CHECK(LDKBalance_MaybePreimageClaimableHTLC_meth != NULL);
8609         LDKBalance_CounterpartyRevokedOutputClaimable_class =
8610                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKBalance$CounterpartyRevokedOutputClaimable"));
8611         CHECK(LDKBalance_CounterpartyRevokedOutputClaimable_class != NULL);
8612         LDKBalance_CounterpartyRevokedOutputClaimable_meth = (*env)->GetMethodID(env, LDKBalance_CounterpartyRevokedOutputClaimable_class, "<init>", "(J)V");
8613         CHECK(LDKBalance_CounterpartyRevokedOutputClaimable_meth != NULL);
8614 }
8615 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKBalance_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
8616         LDKBalance *obj = (LDKBalance*)untag_ptr(ptr);
8617         switch(obj->tag) {
8618                 case LDKBalance_ClaimableOnChannelClose: {
8619                         int64_t claimable_amount_satoshis_conv = obj->claimable_on_channel_close.claimable_amount_satoshis;
8620                         return (*env)->NewObject(env, LDKBalance_ClaimableOnChannelClose_class, LDKBalance_ClaimableOnChannelClose_meth, claimable_amount_satoshis_conv);
8621                 }
8622                 case LDKBalance_ClaimableAwaitingConfirmations: {
8623                         int64_t claimable_amount_satoshis_conv = obj->claimable_awaiting_confirmations.claimable_amount_satoshis;
8624                         int32_t confirmation_height_conv = obj->claimable_awaiting_confirmations.confirmation_height;
8625                         return (*env)->NewObject(env, LDKBalance_ClaimableAwaitingConfirmations_class, LDKBalance_ClaimableAwaitingConfirmations_meth, claimable_amount_satoshis_conv, confirmation_height_conv);
8626                 }
8627                 case LDKBalance_ContentiousClaimable: {
8628                         int64_t claimable_amount_satoshis_conv = obj->contentious_claimable.claimable_amount_satoshis;
8629                         int32_t timeout_height_conv = obj->contentious_claimable.timeout_height;
8630                         return (*env)->NewObject(env, LDKBalance_ContentiousClaimable_class, LDKBalance_ContentiousClaimable_meth, claimable_amount_satoshis_conv, timeout_height_conv);
8631                 }
8632                 case LDKBalance_MaybeTimeoutClaimableHTLC: {
8633                         int64_t claimable_amount_satoshis_conv = obj->maybe_timeout_claimable_htlc.claimable_amount_satoshis;
8634                         int32_t claimable_height_conv = obj->maybe_timeout_claimable_htlc.claimable_height;
8635                         return (*env)->NewObject(env, LDKBalance_MaybeTimeoutClaimableHTLC_class, LDKBalance_MaybeTimeoutClaimableHTLC_meth, claimable_amount_satoshis_conv, claimable_height_conv);
8636                 }
8637                 case LDKBalance_MaybePreimageClaimableHTLC: {
8638                         int64_t claimable_amount_satoshis_conv = obj->maybe_preimage_claimable_htlc.claimable_amount_satoshis;
8639                         int32_t expiry_height_conv = obj->maybe_preimage_claimable_htlc.expiry_height;
8640                         return (*env)->NewObject(env, LDKBalance_MaybePreimageClaimableHTLC_class, LDKBalance_MaybePreimageClaimableHTLC_meth, claimable_amount_satoshis_conv, expiry_height_conv);
8641                 }
8642                 case LDKBalance_CounterpartyRevokedOutputClaimable: {
8643                         int64_t claimable_amount_satoshis_conv = obj->counterparty_revoked_output_claimable.claimable_amount_satoshis;
8644                         return (*env)->NewObject(env, LDKBalance_CounterpartyRevokedOutputClaimable_class, LDKBalance_CounterpartyRevokedOutputClaimable_meth, claimable_amount_satoshis_conv);
8645                 }
8646                 default: abort();
8647         }
8648 }
8649 static inline LDKCVec_BalanceZ CVec_BalanceZ_clone(const LDKCVec_BalanceZ *orig) {
8650         LDKCVec_BalanceZ ret = { .data = MALLOC(sizeof(LDKBalance) * orig->datalen, "LDKCVec_BalanceZ clone bytes"), .datalen = orig->datalen };
8651         for (size_t i = 0; i < ret.datalen; i++) {
8652                 ret.data[i] = Balance_clone(&orig->data[i]);
8653         }
8654         return ret;
8655 }
8656 static inline struct LDKC2Tuple_BlockHashChannelMonitorZ CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_ok(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *NONNULL_PTR owner){
8657 CHECK(owner->result_ok);
8658         return C2Tuple_BlockHashChannelMonitorZ_clone(&*owner->contents.result);
8659 }
8660 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8661         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* owner_conv = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)untag_ptr(owner);
8662         LDKC2Tuple_BlockHashChannelMonitorZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
8663         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_ok(owner_conv);
8664         return tag_ptr(ret_conv, true);
8665 }
8666
8667 static inline struct LDKDecodeError CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_err(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *NONNULL_PTR owner){
8668 CHECK(!owner->result_ok);
8669         return DecodeError_clone(&*owner->contents.err);
8670 }
8671 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8672         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* owner_conv = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)untag_ptr(owner);
8673         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
8674         *ret_copy = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_get_err(owner_conv);
8675         int64_t ret_ref = tag_ptr(ret_copy, true);
8676         return ret_ref;
8677 }
8678
8679 static inline struct LDKPublicKey C2Tuple_PublicKeyTypeZ_get_a(LDKC2Tuple_PublicKeyTypeZ *NONNULL_PTR owner){
8680         return owner->a;
8681 }
8682 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PublicKeyTypeZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
8683         LDKC2Tuple_PublicKeyTypeZ* owner_conv = (LDKC2Tuple_PublicKeyTypeZ*)untag_ptr(owner);
8684         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
8685         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, C2Tuple_PublicKeyTypeZ_get_a(owner_conv).compressed_form);
8686         return ret_arr;
8687 }
8688
8689 static inline struct LDKType C2Tuple_PublicKeyTypeZ_get_b(LDKC2Tuple_PublicKeyTypeZ *NONNULL_PTR owner){
8690         return Type_clone(&owner->b);
8691 }
8692 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PublicKeyTypeZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
8693         LDKC2Tuple_PublicKeyTypeZ* owner_conv = (LDKC2Tuple_PublicKeyTypeZ*)untag_ptr(owner);
8694         LDKType* ret_ret = MALLOC(sizeof(LDKType), "LDKType");
8695         *ret_ret = C2Tuple_PublicKeyTypeZ_get_b(owner_conv);
8696         return tag_ptr(ret_ret, true);
8697 }
8698
8699 static inline LDKCVec_C2Tuple_PublicKeyTypeZZ CVec_C2Tuple_PublicKeyTypeZZ_clone(const LDKCVec_C2Tuple_PublicKeyTypeZZ *orig) {
8700         LDKCVec_C2Tuple_PublicKeyTypeZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ) * orig->datalen, "LDKCVec_C2Tuple_PublicKeyTypeZZ clone bytes"), .datalen = orig->datalen };
8701         for (size_t i = 0; i < ret.datalen; i++) {
8702                 ret.data[i] = C2Tuple_PublicKeyTypeZ_clone(&orig->data[i]);
8703         }
8704         return ret;
8705 }
8706 typedef struct LDKCustomOnionMessageContents_JCalls {
8707         atomic_size_t refcnt;
8708         JavaVM *vm;
8709         jweak o;
8710         jmethodID tlv_type_meth;
8711         jmethodID write_meth;
8712 } LDKCustomOnionMessageContents_JCalls;
8713 static void LDKCustomOnionMessageContents_JCalls_free(void* this_arg) {
8714         LDKCustomOnionMessageContents_JCalls *j_calls = (LDKCustomOnionMessageContents_JCalls*) this_arg;
8715         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
8716                 JNIEnv *env;
8717                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8718                 if (get_jenv_res == JNI_EDETACHED) {
8719                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8720                 } else {
8721                         DO_ASSERT(get_jenv_res == JNI_OK);
8722                 }
8723                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
8724                 if (get_jenv_res == JNI_EDETACHED) {
8725                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8726                 }
8727                 FREE(j_calls);
8728         }
8729 }
8730 uint64_t tlv_type_LDKCustomOnionMessageContents_jcall(const void* this_arg) {
8731         LDKCustomOnionMessageContents_JCalls *j_calls = (LDKCustomOnionMessageContents_JCalls*) this_arg;
8732         JNIEnv *env;
8733         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8734         if (get_jenv_res == JNI_EDETACHED) {
8735                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8736         } else {
8737                 DO_ASSERT(get_jenv_res == JNI_OK);
8738         }
8739         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8740         CHECK(obj != NULL);
8741         int64_t ret = (*env)->CallLongMethod(env, obj, j_calls->tlv_type_meth);
8742         if (UNLIKELY((*env)->ExceptionCheck(env))) {
8743                 (*env)->ExceptionDescribe(env);
8744                 (*env)->FatalError(env, "A call to tlv_type in LDKCustomOnionMessageContents from rust threw an exception.");
8745         }
8746         if (get_jenv_res == JNI_EDETACHED) {
8747                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8748         }
8749         return ret;
8750 }
8751 LDKCVec_u8Z write_LDKCustomOnionMessageContents_jcall(const void* this_arg) {
8752         LDKCustomOnionMessageContents_JCalls *j_calls = (LDKCustomOnionMessageContents_JCalls*) this_arg;
8753         JNIEnv *env;
8754         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8755         if (get_jenv_res == JNI_EDETACHED) {
8756                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8757         } else {
8758                 DO_ASSERT(get_jenv_res == JNI_OK);
8759         }
8760         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8761         CHECK(obj != NULL);
8762         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->write_meth);
8763         if (UNLIKELY((*env)->ExceptionCheck(env))) {
8764                 (*env)->ExceptionDescribe(env);
8765                 (*env)->FatalError(env, "A call to write in LDKCustomOnionMessageContents from rust threw an exception.");
8766         }
8767         LDKCVec_u8Z ret_ref;
8768         ret_ref.datalen = (*env)->GetArrayLength(env, ret);
8769         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
8770         (*env)->GetByteArrayRegion(env, ret, 0, ret_ref.datalen, ret_ref.data);
8771         if (get_jenv_res == JNI_EDETACHED) {
8772                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8773         }
8774         return ret_ref;
8775 }
8776 static void LDKCustomOnionMessageContents_JCalls_cloned(LDKCustomOnionMessageContents* new_obj) {
8777         LDKCustomOnionMessageContents_JCalls *j_calls = (LDKCustomOnionMessageContents_JCalls*) new_obj->this_arg;
8778         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
8779 }
8780 static inline LDKCustomOnionMessageContents LDKCustomOnionMessageContents_init (JNIEnv *env, jclass clz, jobject o) {
8781         jclass c = (*env)->GetObjectClass(env, o);
8782         CHECK(c != NULL);
8783         LDKCustomOnionMessageContents_JCalls *calls = MALLOC(sizeof(LDKCustomOnionMessageContents_JCalls), "LDKCustomOnionMessageContents_JCalls");
8784         atomic_init(&calls->refcnt, 1);
8785         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
8786         calls->o = (*env)->NewWeakGlobalRef(env, o);
8787         calls->tlv_type_meth = (*env)->GetMethodID(env, c, "tlv_type", "()J");
8788         CHECK(calls->tlv_type_meth != NULL);
8789         calls->write_meth = (*env)->GetMethodID(env, c, "write", "()[B");
8790         CHECK(calls->write_meth != NULL);
8791
8792         LDKCustomOnionMessageContents ret = {
8793                 .this_arg = (void*) calls,
8794                 .tlv_type = tlv_type_LDKCustomOnionMessageContents_jcall,
8795                 .write = write_LDKCustomOnionMessageContents_jcall,
8796                 .cloned = LDKCustomOnionMessageContents_JCalls_cloned,
8797                 .free = LDKCustomOnionMessageContents_JCalls_free,
8798         };
8799         return ret;
8800 }
8801 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCustomOnionMessageContents_1new(JNIEnv *env, jclass clz, jobject o) {
8802         LDKCustomOnionMessageContents *res_ptr = MALLOC(sizeof(LDKCustomOnionMessageContents), "LDKCustomOnionMessageContents");
8803         *res_ptr = LDKCustomOnionMessageContents_init(env, clz, o);
8804         return tag_ptr(res_ptr, true);
8805 }
8806 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CustomOnionMessageContents_1tlv_1type(JNIEnv *env, jclass clz, int64_t this_arg) {
8807         void* this_arg_ptr = untag_ptr(this_arg);
8808         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
8809         LDKCustomOnionMessageContents* this_arg_conv = (LDKCustomOnionMessageContents*)this_arg_ptr;
8810         int64_t ret_conv = (this_arg_conv->tlv_type)(this_arg_conv->this_arg);
8811         return ret_conv;
8812 }
8813
8814 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CustomOnionMessageContents_1write(JNIEnv *env, jclass clz, int64_t this_arg) {
8815         void* this_arg_ptr = untag_ptr(this_arg);
8816         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
8817         LDKCustomOnionMessageContents* this_arg_conv = (LDKCustomOnionMessageContents*)this_arg_ptr;
8818         LDKCVec_u8Z ret_var = (this_arg_conv->write)(this_arg_conv->this_arg);
8819         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
8820         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
8821         CVec_u8Z_free(ret_var);
8822         return ret_arr;
8823 }
8824
8825 static jclass LDKCOption_CustomOnionMessageContentsZ_Some_class = NULL;
8826 static jmethodID LDKCOption_CustomOnionMessageContentsZ_Some_meth = NULL;
8827 static jclass LDKCOption_CustomOnionMessageContentsZ_None_class = NULL;
8828 static jmethodID LDKCOption_CustomOnionMessageContentsZ_None_meth = NULL;
8829 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1CustomOnionMessageContentsZ_init (JNIEnv *env, jclass clz) {
8830         LDKCOption_CustomOnionMessageContentsZ_Some_class =
8831                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_CustomOnionMessageContentsZ$Some"));
8832         CHECK(LDKCOption_CustomOnionMessageContentsZ_Some_class != NULL);
8833         LDKCOption_CustomOnionMessageContentsZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_CustomOnionMessageContentsZ_Some_class, "<init>", "(J)V");
8834         CHECK(LDKCOption_CustomOnionMessageContentsZ_Some_meth != NULL);
8835         LDKCOption_CustomOnionMessageContentsZ_None_class =
8836                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_CustomOnionMessageContentsZ$None"));
8837         CHECK(LDKCOption_CustomOnionMessageContentsZ_None_class != NULL);
8838         LDKCOption_CustomOnionMessageContentsZ_None_meth = (*env)->GetMethodID(env, LDKCOption_CustomOnionMessageContentsZ_None_class, "<init>", "()V");
8839         CHECK(LDKCOption_CustomOnionMessageContentsZ_None_meth != NULL);
8840 }
8841 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1CustomOnionMessageContentsZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
8842         LDKCOption_CustomOnionMessageContentsZ *obj = (LDKCOption_CustomOnionMessageContentsZ*)untag_ptr(ptr);
8843         switch(obj->tag) {
8844                 case LDKCOption_CustomOnionMessageContentsZ_Some: {
8845                         LDKCustomOnionMessageContents* some_ret = MALLOC(sizeof(LDKCustomOnionMessageContents), "LDKCustomOnionMessageContents");
8846                         *some_ret = CustomOnionMessageContents_clone(&obj->some);
8847                         return (*env)->NewObject(env, LDKCOption_CustomOnionMessageContentsZ_Some_class, LDKCOption_CustomOnionMessageContentsZ_Some_meth, tag_ptr(some_ret, true));
8848                 }
8849                 case LDKCOption_CustomOnionMessageContentsZ_None: {
8850                         return (*env)->NewObject(env, LDKCOption_CustomOnionMessageContentsZ_None_class, LDKCOption_CustomOnionMessageContentsZ_None_meth);
8851                 }
8852                 default: abort();
8853         }
8854 }
8855 static inline struct LDKCOption_CustomOnionMessageContentsZ CResult_COption_CustomOnionMessageContentsZDecodeErrorZ_get_ok(LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ *NONNULL_PTR owner){
8856 CHECK(owner->result_ok);
8857         return COption_CustomOnionMessageContentsZ_clone(&*owner->contents.result);
8858 }
8859 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1CustomOnionMessageContentsZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8860         LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ* owner_conv = (LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ*)untag_ptr(owner);
8861         LDKCOption_CustomOnionMessageContentsZ *ret_copy = MALLOC(sizeof(LDKCOption_CustomOnionMessageContentsZ), "LDKCOption_CustomOnionMessageContentsZ");
8862         *ret_copy = CResult_COption_CustomOnionMessageContentsZDecodeErrorZ_get_ok(owner_conv);
8863         int64_t ret_ref = tag_ptr(ret_copy, true);
8864         return ret_ref;
8865 }
8866
8867 static inline struct LDKDecodeError CResult_COption_CustomOnionMessageContentsZDecodeErrorZ_get_err(LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ *NONNULL_PTR owner){
8868 CHECK(!owner->result_ok);
8869         return DecodeError_clone(&*owner->contents.err);
8870 }
8871 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1CustomOnionMessageContentsZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8872         LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ* owner_conv = (LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ*)untag_ptr(owner);
8873         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
8874         *ret_copy = CResult_COption_CustomOnionMessageContentsZDecodeErrorZ_get_err(owner_conv);
8875         int64_t ret_ref = tag_ptr(ret_copy, true);
8876         return ret_ref;
8877 }
8878
8879 static jclass LDKCOption_NetAddressZ_Some_class = NULL;
8880 static jmethodID LDKCOption_NetAddressZ_Some_meth = NULL;
8881 static jclass LDKCOption_NetAddressZ_None_class = NULL;
8882 static jmethodID LDKCOption_NetAddressZ_None_meth = NULL;
8883 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1NetAddressZ_init (JNIEnv *env, jclass clz) {
8884         LDKCOption_NetAddressZ_Some_class =
8885                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_NetAddressZ$Some"));
8886         CHECK(LDKCOption_NetAddressZ_Some_class != NULL);
8887         LDKCOption_NetAddressZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_NetAddressZ_Some_class, "<init>", "(J)V");
8888         CHECK(LDKCOption_NetAddressZ_Some_meth != NULL);
8889         LDKCOption_NetAddressZ_None_class =
8890                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_NetAddressZ$None"));
8891         CHECK(LDKCOption_NetAddressZ_None_class != NULL);
8892         LDKCOption_NetAddressZ_None_meth = (*env)->GetMethodID(env, LDKCOption_NetAddressZ_None_class, "<init>", "()V");
8893         CHECK(LDKCOption_NetAddressZ_None_meth != NULL);
8894 }
8895 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1NetAddressZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
8896         LDKCOption_NetAddressZ *obj = (LDKCOption_NetAddressZ*)untag_ptr(ptr);
8897         switch(obj->tag) {
8898                 case LDKCOption_NetAddressZ_Some: {
8899                         int64_t some_ref = tag_ptr(&obj->some, false);
8900                         return (*env)->NewObject(env, LDKCOption_NetAddressZ_Some_class, LDKCOption_NetAddressZ_Some_meth, some_ref);
8901                 }
8902                 case LDKCOption_NetAddressZ_None: {
8903                         return (*env)->NewObject(env, LDKCOption_NetAddressZ_None_class, LDKCOption_NetAddressZ_None_meth);
8904                 }
8905                 default: abort();
8906         }
8907 }
8908 static inline struct LDKCVec_u8Z CResult_CVec_u8ZPeerHandleErrorZ_get_ok(LDKCResult_CVec_u8ZPeerHandleErrorZ *NONNULL_PTR owner){
8909 CHECK(owner->result_ok);
8910         return CVec_u8Z_clone(&*owner->contents.result);
8911 }
8912 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8913         LDKCResult_CVec_u8ZPeerHandleErrorZ* owner_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)untag_ptr(owner);
8914         LDKCVec_u8Z ret_var = CResult_CVec_u8ZPeerHandleErrorZ_get_ok(owner_conv);
8915         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
8916         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
8917         CVec_u8Z_free(ret_var);
8918         return ret_arr;
8919 }
8920
8921 static inline struct LDKPeerHandleError CResult_CVec_u8ZPeerHandleErrorZ_get_err(LDKCResult_CVec_u8ZPeerHandleErrorZ *NONNULL_PTR owner){
8922         LDKPeerHandleError ret = *owner->contents.err;
8923         ret.is_owned = false;
8924         return ret;
8925 }
8926 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8927         LDKCResult_CVec_u8ZPeerHandleErrorZ* owner_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)untag_ptr(owner);
8928         LDKPeerHandleError ret_var = CResult_CVec_u8ZPeerHandleErrorZ_get_err(owner_conv);
8929         int64_t ret_ref = 0;
8930         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8931         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
8932         return ret_ref;
8933 }
8934
8935 static inline void CResult_NonePeerHandleErrorZ_get_ok(LDKCResult_NonePeerHandleErrorZ *NONNULL_PTR owner){
8936 CHECK(owner->result_ok);
8937         return *owner->contents.result;
8938 }
8939 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8940         LDKCResult_NonePeerHandleErrorZ* owner_conv = (LDKCResult_NonePeerHandleErrorZ*)untag_ptr(owner);
8941         CResult_NonePeerHandleErrorZ_get_ok(owner_conv);
8942 }
8943
8944 static inline struct LDKPeerHandleError CResult_NonePeerHandleErrorZ_get_err(LDKCResult_NonePeerHandleErrorZ *NONNULL_PTR owner){
8945         LDKPeerHandleError ret = *owner->contents.err;
8946         ret.is_owned = false;
8947         return ret;
8948 }
8949 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8950         LDKCResult_NonePeerHandleErrorZ* owner_conv = (LDKCResult_NonePeerHandleErrorZ*)untag_ptr(owner);
8951         LDKPeerHandleError ret_var = CResult_NonePeerHandleErrorZ_get_err(owner_conv);
8952         int64_t ret_ref = 0;
8953         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8954         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
8955         return ret_ref;
8956 }
8957
8958 static inline bool CResult_boolPeerHandleErrorZ_get_ok(LDKCResult_boolPeerHandleErrorZ *NONNULL_PTR owner){
8959 CHECK(owner->result_ok);
8960         return *owner->contents.result;
8961 }
8962 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
8963         LDKCResult_boolPeerHandleErrorZ* owner_conv = (LDKCResult_boolPeerHandleErrorZ*)untag_ptr(owner);
8964         jboolean ret_conv = CResult_boolPeerHandleErrorZ_get_ok(owner_conv);
8965         return ret_conv;
8966 }
8967
8968 static inline struct LDKPeerHandleError CResult_boolPeerHandleErrorZ_get_err(LDKCResult_boolPeerHandleErrorZ *NONNULL_PTR owner){
8969         LDKPeerHandleError ret = *owner->contents.err;
8970         ret.is_owned = false;
8971         return ret;
8972 }
8973 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
8974         LDKCResult_boolPeerHandleErrorZ* owner_conv = (LDKCResult_boolPeerHandleErrorZ*)untag_ptr(owner);
8975         LDKPeerHandleError ret_var = CResult_boolPeerHandleErrorZ_get_err(owner_conv);
8976         int64_t ret_ref = 0;
8977         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
8978         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
8979         return ret_ref;
8980 }
8981
8982 static jclass LDKSendError_Secp256k1_class = NULL;
8983 static jmethodID LDKSendError_Secp256k1_meth = NULL;
8984 static jclass LDKSendError_TooBigPacket_class = NULL;
8985 static jmethodID LDKSendError_TooBigPacket_meth = NULL;
8986 static jclass LDKSendError_TooFewBlindedHops_class = NULL;
8987 static jmethodID LDKSendError_TooFewBlindedHops_meth = NULL;
8988 static jclass LDKSendError_InvalidFirstHop_class = NULL;
8989 static jmethodID LDKSendError_InvalidFirstHop_meth = NULL;
8990 static jclass LDKSendError_InvalidMessage_class = NULL;
8991 static jmethodID LDKSendError_InvalidMessage_meth = NULL;
8992 static jclass LDKSendError_BufferFull_class = NULL;
8993 static jmethodID LDKSendError_BufferFull_meth = NULL;
8994 static jclass LDKSendError_GetNodeIdFailed_class = NULL;
8995 static jmethodID LDKSendError_GetNodeIdFailed_meth = NULL;
8996 static jclass LDKSendError_BlindedPathAdvanceFailed_class = NULL;
8997 static jmethodID LDKSendError_BlindedPathAdvanceFailed_meth = NULL;
8998 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKSendError_init (JNIEnv *env, jclass clz) {
8999         LDKSendError_Secp256k1_class =
9000                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKSendError$Secp256k1"));
9001         CHECK(LDKSendError_Secp256k1_class != NULL);
9002         LDKSendError_Secp256k1_meth = (*env)->GetMethodID(env, LDKSendError_Secp256k1_class, "<init>", "(Lorg/ldk/enums/Secp256k1Error;)V");
9003         CHECK(LDKSendError_Secp256k1_meth != NULL);
9004         LDKSendError_TooBigPacket_class =
9005                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKSendError$TooBigPacket"));
9006         CHECK(LDKSendError_TooBigPacket_class != NULL);
9007         LDKSendError_TooBigPacket_meth = (*env)->GetMethodID(env, LDKSendError_TooBigPacket_class, "<init>", "()V");
9008         CHECK(LDKSendError_TooBigPacket_meth != NULL);
9009         LDKSendError_TooFewBlindedHops_class =
9010                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKSendError$TooFewBlindedHops"));
9011         CHECK(LDKSendError_TooFewBlindedHops_class != NULL);
9012         LDKSendError_TooFewBlindedHops_meth = (*env)->GetMethodID(env, LDKSendError_TooFewBlindedHops_class, "<init>", "()V");
9013         CHECK(LDKSendError_TooFewBlindedHops_meth != NULL);
9014         LDKSendError_InvalidFirstHop_class =
9015                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKSendError$InvalidFirstHop"));
9016         CHECK(LDKSendError_InvalidFirstHop_class != NULL);
9017         LDKSendError_InvalidFirstHop_meth = (*env)->GetMethodID(env, LDKSendError_InvalidFirstHop_class, "<init>", "()V");
9018         CHECK(LDKSendError_InvalidFirstHop_meth != NULL);
9019         LDKSendError_InvalidMessage_class =
9020                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKSendError$InvalidMessage"));
9021         CHECK(LDKSendError_InvalidMessage_class != NULL);
9022         LDKSendError_InvalidMessage_meth = (*env)->GetMethodID(env, LDKSendError_InvalidMessage_class, "<init>", "()V");
9023         CHECK(LDKSendError_InvalidMessage_meth != NULL);
9024         LDKSendError_BufferFull_class =
9025                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKSendError$BufferFull"));
9026         CHECK(LDKSendError_BufferFull_class != NULL);
9027         LDKSendError_BufferFull_meth = (*env)->GetMethodID(env, LDKSendError_BufferFull_class, "<init>", "()V");
9028         CHECK(LDKSendError_BufferFull_meth != NULL);
9029         LDKSendError_GetNodeIdFailed_class =
9030                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKSendError$GetNodeIdFailed"));
9031         CHECK(LDKSendError_GetNodeIdFailed_class != NULL);
9032         LDKSendError_GetNodeIdFailed_meth = (*env)->GetMethodID(env, LDKSendError_GetNodeIdFailed_class, "<init>", "()V");
9033         CHECK(LDKSendError_GetNodeIdFailed_meth != NULL);
9034         LDKSendError_BlindedPathAdvanceFailed_class =
9035                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKSendError$BlindedPathAdvanceFailed"));
9036         CHECK(LDKSendError_BlindedPathAdvanceFailed_class != NULL);
9037         LDKSendError_BlindedPathAdvanceFailed_meth = (*env)->GetMethodID(env, LDKSendError_BlindedPathAdvanceFailed_class, "<init>", "()V");
9038         CHECK(LDKSendError_BlindedPathAdvanceFailed_meth != NULL);
9039 }
9040 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKSendError_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
9041         LDKSendError *obj = (LDKSendError*)untag_ptr(ptr);
9042         switch(obj->tag) {
9043                 case LDKSendError_Secp256k1: {
9044                         jclass secp256k1_conv = LDKSecp256k1Error_to_java(env, obj->secp256k1);
9045                         return (*env)->NewObject(env, LDKSendError_Secp256k1_class, LDKSendError_Secp256k1_meth, secp256k1_conv);
9046                 }
9047                 case LDKSendError_TooBigPacket: {
9048                         return (*env)->NewObject(env, LDKSendError_TooBigPacket_class, LDKSendError_TooBigPacket_meth);
9049                 }
9050                 case LDKSendError_TooFewBlindedHops: {
9051                         return (*env)->NewObject(env, LDKSendError_TooFewBlindedHops_class, LDKSendError_TooFewBlindedHops_meth);
9052                 }
9053                 case LDKSendError_InvalidFirstHop: {
9054                         return (*env)->NewObject(env, LDKSendError_InvalidFirstHop_class, LDKSendError_InvalidFirstHop_meth);
9055                 }
9056                 case LDKSendError_InvalidMessage: {
9057                         return (*env)->NewObject(env, LDKSendError_InvalidMessage_class, LDKSendError_InvalidMessage_meth);
9058                 }
9059                 case LDKSendError_BufferFull: {
9060                         return (*env)->NewObject(env, LDKSendError_BufferFull_class, LDKSendError_BufferFull_meth);
9061                 }
9062                 case LDKSendError_GetNodeIdFailed: {
9063                         return (*env)->NewObject(env, LDKSendError_GetNodeIdFailed_class, LDKSendError_GetNodeIdFailed_meth);
9064                 }
9065                 case LDKSendError_BlindedPathAdvanceFailed: {
9066                         return (*env)->NewObject(env, LDKSendError_BlindedPathAdvanceFailed_class, LDKSendError_BlindedPathAdvanceFailed_meth);
9067                 }
9068                 default: abort();
9069         }
9070 }
9071 static inline void CResult_NoneSendErrorZ_get_ok(LDKCResult_NoneSendErrorZ *NONNULL_PTR owner){
9072 CHECK(owner->result_ok);
9073         return *owner->contents.result;
9074 }
9075 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSendErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9076         LDKCResult_NoneSendErrorZ* owner_conv = (LDKCResult_NoneSendErrorZ*)untag_ptr(owner);
9077         CResult_NoneSendErrorZ_get_ok(owner_conv);
9078 }
9079
9080 static inline struct LDKSendError CResult_NoneSendErrorZ_get_err(LDKCResult_NoneSendErrorZ *NONNULL_PTR owner){
9081 CHECK(!owner->result_ok);
9082         return SendError_clone(&*owner->contents.err);
9083 }
9084 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSendErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9085         LDKCResult_NoneSendErrorZ* owner_conv = (LDKCResult_NoneSendErrorZ*)untag_ptr(owner);
9086         LDKSendError *ret_copy = MALLOC(sizeof(LDKSendError), "LDKSendError");
9087         *ret_copy = CResult_NoneSendErrorZ_get_err(owner_conv);
9088         int64_t ret_ref = tag_ptr(ret_copy, true);
9089         return ret_ref;
9090 }
9091
9092 static jclass LDKParseError_Bech32Error_class = NULL;
9093 static jmethodID LDKParseError_Bech32Error_meth = NULL;
9094 static jclass LDKParseError_ParseAmountError_class = NULL;
9095 static jmethodID LDKParseError_ParseAmountError_meth = NULL;
9096 static jclass LDKParseError_MalformedSignature_class = NULL;
9097 static jmethodID LDKParseError_MalformedSignature_meth = NULL;
9098 static jclass LDKParseError_BadPrefix_class = NULL;
9099 static jmethodID LDKParseError_BadPrefix_meth = NULL;
9100 static jclass LDKParseError_UnknownCurrency_class = NULL;
9101 static jmethodID LDKParseError_UnknownCurrency_meth = NULL;
9102 static jclass LDKParseError_UnknownSiPrefix_class = NULL;
9103 static jmethodID LDKParseError_UnknownSiPrefix_meth = NULL;
9104 static jclass LDKParseError_MalformedHRP_class = NULL;
9105 static jmethodID LDKParseError_MalformedHRP_meth = NULL;
9106 static jclass LDKParseError_TooShortDataPart_class = NULL;
9107 static jmethodID LDKParseError_TooShortDataPart_meth = NULL;
9108 static jclass LDKParseError_UnexpectedEndOfTaggedFields_class = NULL;
9109 static jmethodID LDKParseError_UnexpectedEndOfTaggedFields_meth = NULL;
9110 static jclass LDKParseError_DescriptionDecodeError_class = NULL;
9111 static jmethodID LDKParseError_DescriptionDecodeError_meth = NULL;
9112 static jclass LDKParseError_PaddingError_class = NULL;
9113 static jmethodID LDKParseError_PaddingError_meth = NULL;
9114 static jclass LDKParseError_IntegerOverflowError_class = NULL;
9115 static jmethodID LDKParseError_IntegerOverflowError_meth = NULL;
9116 static jclass LDKParseError_InvalidSegWitProgramLength_class = NULL;
9117 static jmethodID LDKParseError_InvalidSegWitProgramLength_meth = NULL;
9118 static jclass LDKParseError_InvalidPubKeyHashLength_class = NULL;
9119 static jmethodID LDKParseError_InvalidPubKeyHashLength_meth = NULL;
9120 static jclass LDKParseError_InvalidScriptHashLength_class = NULL;
9121 static jmethodID LDKParseError_InvalidScriptHashLength_meth = NULL;
9122 static jclass LDKParseError_InvalidRecoveryId_class = NULL;
9123 static jmethodID LDKParseError_InvalidRecoveryId_meth = NULL;
9124 static jclass LDKParseError_InvalidSliceLength_class = NULL;
9125 static jmethodID LDKParseError_InvalidSliceLength_meth = NULL;
9126 static jclass LDKParseError_Skip_class = NULL;
9127 static jmethodID LDKParseError_Skip_meth = NULL;
9128 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKParseError_init (JNIEnv *env, jclass clz) {
9129         LDKParseError_Bech32Error_class =
9130                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$Bech32Error"));
9131         CHECK(LDKParseError_Bech32Error_class != NULL);
9132         LDKParseError_Bech32Error_meth = (*env)->GetMethodID(env, LDKParseError_Bech32Error_class, "<init>", "(J)V");
9133         CHECK(LDKParseError_Bech32Error_meth != NULL);
9134         LDKParseError_ParseAmountError_class =
9135                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$ParseAmountError"));
9136         CHECK(LDKParseError_ParseAmountError_class != NULL);
9137         LDKParseError_ParseAmountError_meth = (*env)->GetMethodID(env, LDKParseError_ParseAmountError_class, "<init>", "(I)V");
9138         CHECK(LDKParseError_ParseAmountError_meth != NULL);
9139         LDKParseError_MalformedSignature_class =
9140                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$MalformedSignature"));
9141         CHECK(LDKParseError_MalformedSignature_class != NULL);
9142         LDKParseError_MalformedSignature_meth = (*env)->GetMethodID(env, LDKParseError_MalformedSignature_class, "<init>", "(Lorg/ldk/enums/Secp256k1Error;)V");
9143         CHECK(LDKParseError_MalformedSignature_meth != NULL);
9144         LDKParseError_BadPrefix_class =
9145                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$BadPrefix"));
9146         CHECK(LDKParseError_BadPrefix_class != NULL);
9147         LDKParseError_BadPrefix_meth = (*env)->GetMethodID(env, LDKParseError_BadPrefix_class, "<init>", "()V");
9148         CHECK(LDKParseError_BadPrefix_meth != NULL);
9149         LDKParseError_UnknownCurrency_class =
9150                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$UnknownCurrency"));
9151         CHECK(LDKParseError_UnknownCurrency_class != NULL);
9152         LDKParseError_UnknownCurrency_meth = (*env)->GetMethodID(env, LDKParseError_UnknownCurrency_class, "<init>", "()V");
9153         CHECK(LDKParseError_UnknownCurrency_meth != NULL);
9154         LDKParseError_UnknownSiPrefix_class =
9155                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$UnknownSiPrefix"));
9156         CHECK(LDKParseError_UnknownSiPrefix_class != NULL);
9157         LDKParseError_UnknownSiPrefix_meth = (*env)->GetMethodID(env, LDKParseError_UnknownSiPrefix_class, "<init>", "()V");
9158         CHECK(LDKParseError_UnknownSiPrefix_meth != NULL);
9159         LDKParseError_MalformedHRP_class =
9160                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$MalformedHRP"));
9161         CHECK(LDKParseError_MalformedHRP_class != NULL);
9162         LDKParseError_MalformedHRP_meth = (*env)->GetMethodID(env, LDKParseError_MalformedHRP_class, "<init>", "()V");
9163         CHECK(LDKParseError_MalformedHRP_meth != NULL);
9164         LDKParseError_TooShortDataPart_class =
9165                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$TooShortDataPart"));
9166         CHECK(LDKParseError_TooShortDataPart_class != NULL);
9167         LDKParseError_TooShortDataPart_meth = (*env)->GetMethodID(env, LDKParseError_TooShortDataPart_class, "<init>", "()V");
9168         CHECK(LDKParseError_TooShortDataPart_meth != NULL);
9169         LDKParseError_UnexpectedEndOfTaggedFields_class =
9170                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$UnexpectedEndOfTaggedFields"));
9171         CHECK(LDKParseError_UnexpectedEndOfTaggedFields_class != NULL);
9172         LDKParseError_UnexpectedEndOfTaggedFields_meth = (*env)->GetMethodID(env, LDKParseError_UnexpectedEndOfTaggedFields_class, "<init>", "()V");
9173         CHECK(LDKParseError_UnexpectedEndOfTaggedFields_meth != NULL);
9174         LDKParseError_DescriptionDecodeError_class =
9175                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$DescriptionDecodeError"));
9176         CHECK(LDKParseError_DescriptionDecodeError_class != NULL);
9177         LDKParseError_DescriptionDecodeError_meth = (*env)->GetMethodID(env, LDKParseError_DescriptionDecodeError_class, "<init>", "(I)V");
9178         CHECK(LDKParseError_DescriptionDecodeError_meth != NULL);
9179         LDKParseError_PaddingError_class =
9180                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$PaddingError"));
9181         CHECK(LDKParseError_PaddingError_class != NULL);
9182         LDKParseError_PaddingError_meth = (*env)->GetMethodID(env, LDKParseError_PaddingError_class, "<init>", "()V");
9183         CHECK(LDKParseError_PaddingError_meth != NULL);
9184         LDKParseError_IntegerOverflowError_class =
9185                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$IntegerOverflowError"));
9186         CHECK(LDKParseError_IntegerOverflowError_class != NULL);
9187         LDKParseError_IntegerOverflowError_meth = (*env)->GetMethodID(env, LDKParseError_IntegerOverflowError_class, "<init>", "()V");
9188         CHECK(LDKParseError_IntegerOverflowError_meth != NULL);
9189         LDKParseError_InvalidSegWitProgramLength_class =
9190                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$InvalidSegWitProgramLength"));
9191         CHECK(LDKParseError_InvalidSegWitProgramLength_class != NULL);
9192         LDKParseError_InvalidSegWitProgramLength_meth = (*env)->GetMethodID(env, LDKParseError_InvalidSegWitProgramLength_class, "<init>", "()V");
9193         CHECK(LDKParseError_InvalidSegWitProgramLength_meth != NULL);
9194         LDKParseError_InvalidPubKeyHashLength_class =
9195                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$InvalidPubKeyHashLength"));
9196         CHECK(LDKParseError_InvalidPubKeyHashLength_class != NULL);
9197         LDKParseError_InvalidPubKeyHashLength_meth = (*env)->GetMethodID(env, LDKParseError_InvalidPubKeyHashLength_class, "<init>", "()V");
9198         CHECK(LDKParseError_InvalidPubKeyHashLength_meth != NULL);
9199         LDKParseError_InvalidScriptHashLength_class =
9200                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$InvalidScriptHashLength"));
9201         CHECK(LDKParseError_InvalidScriptHashLength_class != NULL);
9202         LDKParseError_InvalidScriptHashLength_meth = (*env)->GetMethodID(env, LDKParseError_InvalidScriptHashLength_class, "<init>", "()V");
9203         CHECK(LDKParseError_InvalidScriptHashLength_meth != NULL);
9204         LDKParseError_InvalidRecoveryId_class =
9205                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$InvalidRecoveryId"));
9206         CHECK(LDKParseError_InvalidRecoveryId_class != NULL);
9207         LDKParseError_InvalidRecoveryId_meth = (*env)->GetMethodID(env, LDKParseError_InvalidRecoveryId_class, "<init>", "()V");
9208         CHECK(LDKParseError_InvalidRecoveryId_meth != NULL);
9209         LDKParseError_InvalidSliceLength_class =
9210                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$InvalidSliceLength"));
9211         CHECK(LDKParseError_InvalidSliceLength_class != NULL);
9212         LDKParseError_InvalidSliceLength_meth = (*env)->GetMethodID(env, LDKParseError_InvalidSliceLength_class, "<init>", "(Ljava/lang/String;)V");
9213         CHECK(LDKParseError_InvalidSliceLength_meth != NULL);
9214         LDKParseError_Skip_class =
9215                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseError$Skip"));
9216         CHECK(LDKParseError_Skip_class != NULL);
9217         LDKParseError_Skip_meth = (*env)->GetMethodID(env, LDKParseError_Skip_class, "<init>", "()V");
9218         CHECK(LDKParseError_Skip_meth != NULL);
9219 }
9220 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKParseError_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
9221         LDKParseError *obj = (LDKParseError*)untag_ptr(ptr);
9222         switch(obj->tag) {
9223                 case LDKParseError_Bech32Error: {
9224                         int64_t bech32_error_ref = tag_ptr(&obj->bech32_error, false);
9225                         return (*env)->NewObject(env, LDKParseError_Bech32Error_class, LDKParseError_Bech32Error_meth, bech32_error_ref);
9226                 }
9227                 case LDKParseError_ParseAmountError: {
9228                         /*obj->parse_amount_error*/
9229                         return (*env)->NewObject(env, LDKParseError_ParseAmountError_class, LDKParseError_ParseAmountError_meth, 0);
9230                 }
9231                 case LDKParseError_MalformedSignature: {
9232                         jclass malformed_signature_conv = LDKSecp256k1Error_to_java(env, obj->malformed_signature);
9233                         return (*env)->NewObject(env, LDKParseError_MalformedSignature_class, LDKParseError_MalformedSignature_meth, malformed_signature_conv);
9234                 }
9235                 case LDKParseError_BadPrefix: {
9236                         return (*env)->NewObject(env, LDKParseError_BadPrefix_class, LDKParseError_BadPrefix_meth);
9237                 }
9238                 case LDKParseError_UnknownCurrency: {
9239                         return (*env)->NewObject(env, LDKParseError_UnknownCurrency_class, LDKParseError_UnknownCurrency_meth);
9240                 }
9241                 case LDKParseError_UnknownSiPrefix: {
9242                         return (*env)->NewObject(env, LDKParseError_UnknownSiPrefix_class, LDKParseError_UnknownSiPrefix_meth);
9243                 }
9244                 case LDKParseError_MalformedHRP: {
9245                         return (*env)->NewObject(env, LDKParseError_MalformedHRP_class, LDKParseError_MalformedHRP_meth);
9246                 }
9247                 case LDKParseError_TooShortDataPart: {
9248                         return (*env)->NewObject(env, LDKParseError_TooShortDataPart_class, LDKParseError_TooShortDataPart_meth);
9249                 }
9250                 case LDKParseError_UnexpectedEndOfTaggedFields: {
9251                         return (*env)->NewObject(env, LDKParseError_UnexpectedEndOfTaggedFields_class, LDKParseError_UnexpectedEndOfTaggedFields_meth);
9252                 }
9253                 case LDKParseError_DescriptionDecodeError: {
9254                         /*obj->description_decode_error*/
9255                         return (*env)->NewObject(env, LDKParseError_DescriptionDecodeError_class, LDKParseError_DescriptionDecodeError_meth, 0);
9256                 }
9257                 case LDKParseError_PaddingError: {
9258                         return (*env)->NewObject(env, LDKParseError_PaddingError_class, LDKParseError_PaddingError_meth);
9259                 }
9260                 case LDKParseError_IntegerOverflowError: {
9261                         return (*env)->NewObject(env, LDKParseError_IntegerOverflowError_class, LDKParseError_IntegerOverflowError_meth);
9262                 }
9263                 case LDKParseError_InvalidSegWitProgramLength: {
9264                         return (*env)->NewObject(env, LDKParseError_InvalidSegWitProgramLength_class, LDKParseError_InvalidSegWitProgramLength_meth);
9265                 }
9266                 case LDKParseError_InvalidPubKeyHashLength: {
9267                         return (*env)->NewObject(env, LDKParseError_InvalidPubKeyHashLength_class, LDKParseError_InvalidPubKeyHashLength_meth);
9268                 }
9269                 case LDKParseError_InvalidScriptHashLength: {
9270                         return (*env)->NewObject(env, LDKParseError_InvalidScriptHashLength_class, LDKParseError_InvalidScriptHashLength_meth);
9271                 }
9272                 case LDKParseError_InvalidRecoveryId: {
9273                         return (*env)->NewObject(env, LDKParseError_InvalidRecoveryId_class, LDKParseError_InvalidRecoveryId_meth);
9274                 }
9275                 case LDKParseError_InvalidSliceLength: {
9276                         LDKStr invalid_slice_length_str = obj->invalid_slice_length;
9277                         jstring invalid_slice_length_conv = str_ref_to_java(env, invalid_slice_length_str.chars, invalid_slice_length_str.len);
9278                         return (*env)->NewObject(env, LDKParseError_InvalidSliceLength_class, LDKParseError_InvalidSliceLength_meth, invalid_slice_length_conv);
9279                 }
9280                 case LDKParseError_Skip: {
9281                         return (*env)->NewObject(env, LDKParseError_Skip_class, LDKParseError_Skip_meth);
9282                 }
9283                 default: abort();
9284         }
9285 }
9286 static inline enum LDKSiPrefix CResult_SiPrefixParseErrorZ_get_ok(LDKCResult_SiPrefixParseErrorZ *NONNULL_PTR owner){
9287 CHECK(owner->result_ok);
9288         return SiPrefix_clone(&*owner->contents.result);
9289 }
9290 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixParseErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9291         LDKCResult_SiPrefixParseErrorZ* owner_conv = (LDKCResult_SiPrefixParseErrorZ*)untag_ptr(owner);
9292         jclass ret_conv = LDKSiPrefix_to_java(env, CResult_SiPrefixParseErrorZ_get_ok(owner_conv));
9293         return ret_conv;
9294 }
9295
9296 static inline struct LDKParseError CResult_SiPrefixParseErrorZ_get_err(LDKCResult_SiPrefixParseErrorZ *NONNULL_PTR owner){
9297 CHECK(!owner->result_ok);
9298         return ParseError_clone(&*owner->contents.err);
9299 }
9300 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixParseErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9301         LDKCResult_SiPrefixParseErrorZ* owner_conv = (LDKCResult_SiPrefixParseErrorZ*)untag_ptr(owner);
9302         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
9303         *ret_copy = CResult_SiPrefixParseErrorZ_get_err(owner_conv);
9304         int64_t ret_ref = tag_ptr(ret_copy, true);
9305         return ret_ref;
9306 }
9307
9308 static jclass LDKParseOrSemanticError_ParseError_class = NULL;
9309 static jmethodID LDKParseOrSemanticError_ParseError_meth = NULL;
9310 static jclass LDKParseOrSemanticError_SemanticError_class = NULL;
9311 static jmethodID LDKParseOrSemanticError_SemanticError_meth = NULL;
9312 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKParseOrSemanticError_init (JNIEnv *env, jclass clz) {
9313         LDKParseOrSemanticError_ParseError_class =
9314                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseOrSemanticError$ParseError"));
9315         CHECK(LDKParseOrSemanticError_ParseError_class != NULL);
9316         LDKParseOrSemanticError_ParseError_meth = (*env)->GetMethodID(env, LDKParseOrSemanticError_ParseError_class, "<init>", "(J)V");
9317         CHECK(LDKParseOrSemanticError_ParseError_meth != NULL);
9318         LDKParseOrSemanticError_SemanticError_class =
9319                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKParseOrSemanticError$SemanticError"));
9320         CHECK(LDKParseOrSemanticError_SemanticError_class != NULL);
9321         LDKParseOrSemanticError_SemanticError_meth = (*env)->GetMethodID(env, LDKParseOrSemanticError_SemanticError_class, "<init>", "(Lorg/ldk/enums/SemanticError;)V");
9322         CHECK(LDKParseOrSemanticError_SemanticError_meth != NULL);
9323 }
9324 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKParseOrSemanticError_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
9325         LDKParseOrSemanticError *obj = (LDKParseOrSemanticError*)untag_ptr(ptr);
9326         switch(obj->tag) {
9327                 case LDKParseOrSemanticError_ParseError: {
9328                         int64_t parse_error_ref = tag_ptr(&obj->parse_error, false);
9329                         return (*env)->NewObject(env, LDKParseOrSemanticError_ParseError_class, LDKParseOrSemanticError_ParseError_meth, parse_error_ref);
9330                 }
9331                 case LDKParseOrSemanticError_SemanticError: {
9332                         jclass semantic_error_conv = LDKSemanticError_to_java(env, obj->semantic_error);
9333                         return (*env)->NewObject(env, LDKParseOrSemanticError_SemanticError_class, LDKParseOrSemanticError_SemanticError_meth, semantic_error_conv);
9334                 }
9335                 default: abort();
9336         }
9337 }
9338 static inline struct LDKInvoice CResult_InvoiceParseOrSemanticErrorZ_get_ok(LDKCResult_InvoiceParseOrSemanticErrorZ *NONNULL_PTR owner){
9339         LDKInvoice ret = *owner->contents.result;
9340         ret.is_owned = false;
9341         return ret;
9342 }
9343 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceParseOrSemanticErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9344         LDKCResult_InvoiceParseOrSemanticErrorZ* owner_conv = (LDKCResult_InvoiceParseOrSemanticErrorZ*)untag_ptr(owner);
9345         LDKInvoice ret_var = CResult_InvoiceParseOrSemanticErrorZ_get_ok(owner_conv);
9346         int64_t ret_ref = 0;
9347         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9348         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
9349         return ret_ref;
9350 }
9351
9352 static inline struct LDKParseOrSemanticError CResult_InvoiceParseOrSemanticErrorZ_get_err(LDKCResult_InvoiceParseOrSemanticErrorZ *NONNULL_PTR owner){
9353 CHECK(!owner->result_ok);
9354         return ParseOrSemanticError_clone(&*owner->contents.err);
9355 }
9356 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceParseOrSemanticErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9357         LDKCResult_InvoiceParseOrSemanticErrorZ* owner_conv = (LDKCResult_InvoiceParseOrSemanticErrorZ*)untag_ptr(owner);
9358         LDKParseOrSemanticError *ret_copy = MALLOC(sizeof(LDKParseOrSemanticError), "LDKParseOrSemanticError");
9359         *ret_copy = CResult_InvoiceParseOrSemanticErrorZ_get_err(owner_conv);
9360         int64_t ret_ref = tag_ptr(ret_copy, true);
9361         return ret_ref;
9362 }
9363
9364 static inline struct LDKSignedRawInvoice CResult_SignedRawInvoiceParseErrorZ_get_ok(LDKCResult_SignedRawInvoiceParseErrorZ *NONNULL_PTR owner){
9365         LDKSignedRawInvoice ret = *owner->contents.result;
9366         ret.is_owned = false;
9367         return ret;
9368 }
9369 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceParseErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9370         LDKCResult_SignedRawInvoiceParseErrorZ* owner_conv = (LDKCResult_SignedRawInvoiceParseErrorZ*)untag_ptr(owner);
9371         LDKSignedRawInvoice ret_var = CResult_SignedRawInvoiceParseErrorZ_get_ok(owner_conv);
9372         int64_t ret_ref = 0;
9373         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9374         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
9375         return ret_ref;
9376 }
9377
9378 static inline struct LDKParseError CResult_SignedRawInvoiceParseErrorZ_get_err(LDKCResult_SignedRawInvoiceParseErrorZ *NONNULL_PTR owner){
9379 CHECK(!owner->result_ok);
9380         return ParseError_clone(&*owner->contents.err);
9381 }
9382 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceParseErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9383         LDKCResult_SignedRawInvoiceParseErrorZ* owner_conv = (LDKCResult_SignedRawInvoiceParseErrorZ*)untag_ptr(owner);
9384         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
9385         *ret_copy = CResult_SignedRawInvoiceParseErrorZ_get_err(owner_conv);
9386         int64_t ret_ref = tag_ptr(ret_copy, true);
9387         return ret_ref;
9388 }
9389
9390 static inline struct LDKRawInvoice C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_a(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *NONNULL_PTR owner){
9391         LDKRawInvoice ret = owner->a;
9392         ret.is_owned = false;
9393         return ret;
9394 }
9395 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
9396         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* owner_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)untag_ptr(owner);
9397         LDKRawInvoice ret_var = C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_a(owner_conv);
9398         int64_t ret_ref = 0;
9399         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9400         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
9401         return ret_ref;
9402 }
9403
9404 static inline struct LDKThirtyTwoBytes C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_b(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *NONNULL_PTR owner){
9405         return ThirtyTwoBytes_clone(&owner->b);
9406 }
9407 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
9408         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* owner_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)untag_ptr(owner);
9409         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
9410         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_b(owner_conv).data);
9411         return ret_arr;
9412 }
9413
9414 static inline struct LDKInvoiceSignature C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_c(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *NONNULL_PTR owner){
9415         LDKInvoiceSignature ret = owner->c;
9416         ret.is_owned = false;
9417         return ret;
9418 }
9419 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1get_1c(JNIEnv *env, jclass clz, int64_t owner) {
9420         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* owner_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)untag_ptr(owner);
9421         LDKInvoiceSignature ret_var = C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_c(owner_conv);
9422         int64_t ret_ref = 0;
9423         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9424         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
9425         return ret_ref;
9426 }
9427
9428 static inline struct LDKPayeePubKey CResult_PayeePubKeyErrorZ_get_ok(LDKCResult_PayeePubKeyErrorZ *NONNULL_PTR owner){
9429         LDKPayeePubKey ret = *owner->contents.result;
9430         ret.is_owned = false;
9431         return ret;
9432 }
9433 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9434         LDKCResult_PayeePubKeyErrorZ* owner_conv = (LDKCResult_PayeePubKeyErrorZ*)untag_ptr(owner);
9435         LDKPayeePubKey ret_var = CResult_PayeePubKeyErrorZ_get_ok(owner_conv);
9436         int64_t ret_ref = 0;
9437         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9438         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
9439         return ret_ref;
9440 }
9441
9442 static inline enum LDKSecp256k1Error CResult_PayeePubKeyErrorZ_get_err(LDKCResult_PayeePubKeyErrorZ *NONNULL_PTR owner){
9443 CHECK(!owner->result_ok);
9444         return *owner->contents.err;
9445 }
9446 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9447         LDKCResult_PayeePubKeyErrorZ* owner_conv = (LDKCResult_PayeePubKeyErrorZ*)untag_ptr(owner);
9448         jclass ret_conv = LDKSecp256k1Error_to_java(env, CResult_PayeePubKeyErrorZ_get_err(owner_conv));
9449         return ret_conv;
9450 }
9451
9452 static inline LDKCVec_PrivateRouteZ CVec_PrivateRouteZ_clone(const LDKCVec_PrivateRouteZ *orig) {
9453         LDKCVec_PrivateRouteZ ret = { .data = MALLOC(sizeof(LDKPrivateRoute) * orig->datalen, "LDKCVec_PrivateRouteZ clone bytes"), .datalen = orig->datalen };
9454         for (size_t i = 0; i < ret.datalen; i++) {
9455                 ret.data[i] = PrivateRoute_clone(&orig->data[i]);
9456         }
9457         return ret;
9458 }
9459 static inline struct LDKPositiveTimestamp CResult_PositiveTimestampCreationErrorZ_get_ok(LDKCResult_PositiveTimestampCreationErrorZ *NONNULL_PTR owner){
9460         LDKPositiveTimestamp ret = *owner->contents.result;
9461         ret.is_owned = false;
9462         return ret;
9463 }
9464 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9465         LDKCResult_PositiveTimestampCreationErrorZ* owner_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)untag_ptr(owner);
9466         LDKPositiveTimestamp ret_var = CResult_PositiveTimestampCreationErrorZ_get_ok(owner_conv);
9467         int64_t ret_ref = 0;
9468         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9469         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
9470         return ret_ref;
9471 }
9472
9473 static inline enum LDKCreationError CResult_PositiveTimestampCreationErrorZ_get_err(LDKCResult_PositiveTimestampCreationErrorZ *NONNULL_PTR owner){
9474 CHECK(!owner->result_ok);
9475         return CreationError_clone(&*owner->contents.err);
9476 }
9477 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9478         LDKCResult_PositiveTimestampCreationErrorZ* owner_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)untag_ptr(owner);
9479         jclass ret_conv = LDKCreationError_to_java(env, CResult_PositiveTimestampCreationErrorZ_get_err(owner_conv));
9480         return ret_conv;
9481 }
9482
9483 static inline void CResult_NoneSemanticErrorZ_get_ok(LDKCResult_NoneSemanticErrorZ *NONNULL_PTR owner){
9484 CHECK(owner->result_ok);
9485         return *owner->contents.result;
9486 }
9487 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9488         LDKCResult_NoneSemanticErrorZ* owner_conv = (LDKCResult_NoneSemanticErrorZ*)untag_ptr(owner);
9489         CResult_NoneSemanticErrorZ_get_ok(owner_conv);
9490 }
9491
9492 static inline enum LDKSemanticError CResult_NoneSemanticErrorZ_get_err(LDKCResult_NoneSemanticErrorZ *NONNULL_PTR owner){
9493 CHECK(!owner->result_ok);
9494         return SemanticError_clone(&*owner->contents.err);
9495 }
9496 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9497         LDKCResult_NoneSemanticErrorZ* owner_conv = (LDKCResult_NoneSemanticErrorZ*)untag_ptr(owner);
9498         jclass ret_conv = LDKSemanticError_to_java(env, CResult_NoneSemanticErrorZ_get_err(owner_conv));
9499         return ret_conv;
9500 }
9501
9502 static inline struct LDKInvoice CResult_InvoiceSemanticErrorZ_get_ok(LDKCResult_InvoiceSemanticErrorZ *NONNULL_PTR owner){
9503         LDKInvoice ret = *owner->contents.result;
9504         ret.is_owned = false;
9505         return ret;
9506 }
9507 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9508         LDKCResult_InvoiceSemanticErrorZ* owner_conv = (LDKCResult_InvoiceSemanticErrorZ*)untag_ptr(owner);
9509         LDKInvoice ret_var = CResult_InvoiceSemanticErrorZ_get_ok(owner_conv);
9510         int64_t ret_ref = 0;
9511         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9512         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
9513         return ret_ref;
9514 }
9515
9516 static inline enum LDKSemanticError CResult_InvoiceSemanticErrorZ_get_err(LDKCResult_InvoiceSemanticErrorZ *NONNULL_PTR owner){
9517 CHECK(!owner->result_ok);
9518         return SemanticError_clone(&*owner->contents.err);
9519 }
9520 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9521         LDKCResult_InvoiceSemanticErrorZ* owner_conv = (LDKCResult_InvoiceSemanticErrorZ*)untag_ptr(owner);
9522         jclass ret_conv = LDKSemanticError_to_java(env, CResult_InvoiceSemanticErrorZ_get_err(owner_conv));
9523         return ret_conv;
9524 }
9525
9526 static inline struct LDKDescription CResult_DescriptionCreationErrorZ_get_ok(LDKCResult_DescriptionCreationErrorZ *NONNULL_PTR owner){
9527         LDKDescription ret = *owner->contents.result;
9528         ret.is_owned = false;
9529         return ret;
9530 }
9531 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9532         LDKCResult_DescriptionCreationErrorZ* owner_conv = (LDKCResult_DescriptionCreationErrorZ*)untag_ptr(owner);
9533         LDKDescription ret_var = CResult_DescriptionCreationErrorZ_get_ok(owner_conv);
9534         int64_t ret_ref = 0;
9535         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9536         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
9537         return ret_ref;
9538 }
9539
9540 static inline enum LDKCreationError CResult_DescriptionCreationErrorZ_get_err(LDKCResult_DescriptionCreationErrorZ *NONNULL_PTR owner){
9541 CHECK(!owner->result_ok);
9542         return CreationError_clone(&*owner->contents.err);
9543 }
9544 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9545         LDKCResult_DescriptionCreationErrorZ* owner_conv = (LDKCResult_DescriptionCreationErrorZ*)untag_ptr(owner);
9546         jclass ret_conv = LDKCreationError_to_java(env, CResult_DescriptionCreationErrorZ_get_err(owner_conv));
9547         return ret_conv;
9548 }
9549
9550 static inline struct LDKPrivateRoute CResult_PrivateRouteCreationErrorZ_get_ok(LDKCResult_PrivateRouteCreationErrorZ *NONNULL_PTR owner){
9551         LDKPrivateRoute ret = *owner->contents.result;
9552         ret.is_owned = false;
9553         return ret;
9554 }
9555 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9556         LDKCResult_PrivateRouteCreationErrorZ* owner_conv = (LDKCResult_PrivateRouteCreationErrorZ*)untag_ptr(owner);
9557         LDKPrivateRoute ret_var = CResult_PrivateRouteCreationErrorZ_get_ok(owner_conv);
9558         int64_t ret_ref = 0;
9559         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9560         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
9561         return ret_ref;
9562 }
9563
9564 static inline enum LDKCreationError CResult_PrivateRouteCreationErrorZ_get_err(LDKCResult_PrivateRouteCreationErrorZ *NONNULL_PTR owner){
9565 CHECK(!owner->result_ok);
9566         return CreationError_clone(&*owner->contents.err);
9567 }
9568 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9569         LDKCResult_PrivateRouteCreationErrorZ* owner_conv = (LDKCResult_PrivateRouteCreationErrorZ*)untag_ptr(owner);
9570         jclass ret_conv = LDKCreationError_to_java(env, CResult_PrivateRouteCreationErrorZ_get_err(owner_conv));
9571         return ret_conv;
9572 }
9573
9574 static jclass LDKGraphSyncError_DecodeError_class = NULL;
9575 static jmethodID LDKGraphSyncError_DecodeError_meth = NULL;
9576 static jclass LDKGraphSyncError_LightningError_class = NULL;
9577 static jmethodID LDKGraphSyncError_LightningError_meth = NULL;
9578 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKGraphSyncError_init (JNIEnv *env, jclass clz) {
9579         LDKGraphSyncError_DecodeError_class =
9580                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKGraphSyncError$DecodeError"));
9581         CHECK(LDKGraphSyncError_DecodeError_class != NULL);
9582         LDKGraphSyncError_DecodeError_meth = (*env)->GetMethodID(env, LDKGraphSyncError_DecodeError_class, "<init>", "(J)V");
9583         CHECK(LDKGraphSyncError_DecodeError_meth != NULL);
9584         LDKGraphSyncError_LightningError_class =
9585                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKGraphSyncError$LightningError"));
9586         CHECK(LDKGraphSyncError_LightningError_class != NULL);
9587         LDKGraphSyncError_LightningError_meth = (*env)->GetMethodID(env, LDKGraphSyncError_LightningError_class, "<init>", "(J)V");
9588         CHECK(LDKGraphSyncError_LightningError_meth != NULL);
9589 }
9590 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKGraphSyncError_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
9591         LDKGraphSyncError *obj = (LDKGraphSyncError*)untag_ptr(ptr);
9592         switch(obj->tag) {
9593                 case LDKGraphSyncError_DecodeError: {
9594                         int64_t decode_error_ref = tag_ptr(&obj->decode_error, false);
9595                         return (*env)->NewObject(env, LDKGraphSyncError_DecodeError_class, LDKGraphSyncError_DecodeError_meth, decode_error_ref);
9596                 }
9597                 case LDKGraphSyncError_LightningError: {
9598                         LDKLightningError lightning_error_var = obj->lightning_error;
9599                         int64_t lightning_error_ref = 0;
9600                         CHECK_INNER_FIELD_ACCESS_OR_NULL(lightning_error_var);
9601                         lightning_error_ref = tag_ptr(lightning_error_var.inner, false);
9602                         return (*env)->NewObject(env, LDKGraphSyncError_LightningError_class, LDKGraphSyncError_LightningError_meth, lightning_error_ref);
9603                 }
9604                 default: abort();
9605         }
9606 }
9607 static inline uint32_t CResult_u32GraphSyncErrorZ_get_ok(LDKCResult_u32GraphSyncErrorZ *NONNULL_PTR owner){
9608 CHECK(owner->result_ok);
9609         return *owner->contents.result;
9610 }
9611 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_CResult_1u32GraphSyncErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9612         LDKCResult_u32GraphSyncErrorZ* owner_conv = (LDKCResult_u32GraphSyncErrorZ*)untag_ptr(owner);
9613         int32_t ret_conv = CResult_u32GraphSyncErrorZ_get_ok(owner_conv);
9614         return ret_conv;
9615 }
9616
9617 static inline struct LDKGraphSyncError CResult_u32GraphSyncErrorZ_get_err(LDKCResult_u32GraphSyncErrorZ *NONNULL_PTR owner){
9618 CHECK(!owner->result_ok);
9619         return GraphSyncError_clone(&*owner->contents.err);
9620 }
9621 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1u32GraphSyncErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9622         LDKCResult_u32GraphSyncErrorZ* owner_conv = (LDKCResult_u32GraphSyncErrorZ*)untag_ptr(owner);
9623         LDKGraphSyncError *ret_copy = MALLOC(sizeof(LDKGraphSyncError), "LDKGraphSyncError");
9624         *ret_copy = CResult_u32GraphSyncErrorZ_get_err(owner_conv);
9625         int64_t ret_ref = tag_ptr(ret_copy, true);
9626         return ret_ref;
9627 }
9628
9629 static inline struct LDKNetAddress CResult_NetAddressDecodeErrorZ_get_ok(LDKCResult_NetAddressDecodeErrorZ *NONNULL_PTR owner){
9630 CHECK(owner->result_ok);
9631         return NetAddress_clone(&*owner->contents.result);
9632 }
9633 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9634         LDKCResult_NetAddressDecodeErrorZ* owner_conv = (LDKCResult_NetAddressDecodeErrorZ*)untag_ptr(owner);
9635         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
9636         *ret_copy = CResult_NetAddressDecodeErrorZ_get_ok(owner_conv);
9637         int64_t ret_ref = tag_ptr(ret_copy, true);
9638         return ret_ref;
9639 }
9640
9641 static inline struct LDKDecodeError CResult_NetAddressDecodeErrorZ_get_err(LDKCResult_NetAddressDecodeErrorZ *NONNULL_PTR owner){
9642 CHECK(!owner->result_ok);
9643         return DecodeError_clone(&*owner->contents.err);
9644 }
9645 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9646         LDKCResult_NetAddressDecodeErrorZ* owner_conv = (LDKCResult_NetAddressDecodeErrorZ*)untag_ptr(owner);
9647         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
9648         *ret_copy = CResult_NetAddressDecodeErrorZ_get_err(owner_conv);
9649         int64_t ret_ref = tag_ptr(ret_copy, true);
9650         return ret_ref;
9651 }
9652
9653 static inline LDKCVec_UpdateAddHTLCZ CVec_UpdateAddHTLCZ_clone(const LDKCVec_UpdateAddHTLCZ *orig) {
9654         LDKCVec_UpdateAddHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateAddHTLC) * orig->datalen, "LDKCVec_UpdateAddHTLCZ clone bytes"), .datalen = orig->datalen };
9655         for (size_t i = 0; i < ret.datalen; i++) {
9656                 ret.data[i] = UpdateAddHTLC_clone(&orig->data[i]);
9657         }
9658         return ret;
9659 }
9660 static inline LDKCVec_UpdateFulfillHTLCZ CVec_UpdateFulfillHTLCZ_clone(const LDKCVec_UpdateFulfillHTLCZ *orig) {
9661         LDKCVec_UpdateFulfillHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFulfillHTLC) * orig->datalen, "LDKCVec_UpdateFulfillHTLCZ clone bytes"), .datalen = orig->datalen };
9662         for (size_t i = 0; i < ret.datalen; i++) {
9663                 ret.data[i] = UpdateFulfillHTLC_clone(&orig->data[i]);
9664         }
9665         return ret;
9666 }
9667 static inline LDKCVec_UpdateFailHTLCZ CVec_UpdateFailHTLCZ_clone(const LDKCVec_UpdateFailHTLCZ *orig) {
9668         LDKCVec_UpdateFailHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFailHTLC) * orig->datalen, "LDKCVec_UpdateFailHTLCZ clone bytes"), .datalen = orig->datalen };
9669         for (size_t i = 0; i < ret.datalen; i++) {
9670                 ret.data[i] = UpdateFailHTLC_clone(&orig->data[i]);
9671         }
9672         return ret;
9673 }
9674 static inline LDKCVec_UpdateFailMalformedHTLCZ CVec_UpdateFailMalformedHTLCZ_clone(const LDKCVec_UpdateFailMalformedHTLCZ *orig) {
9675         LDKCVec_UpdateFailMalformedHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFailMalformedHTLC) * orig->datalen, "LDKCVec_UpdateFailMalformedHTLCZ clone bytes"), .datalen = orig->datalen };
9676         for (size_t i = 0; i < ret.datalen; i++) {
9677                 ret.data[i] = UpdateFailMalformedHTLC_clone(&orig->data[i]);
9678         }
9679         return ret;
9680 }
9681 static inline struct LDKAcceptChannel CResult_AcceptChannelDecodeErrorZ_get_ok(LDKCResult_AcceptChannelDecodeErrorZ *NONNULL_PTR owner){
9682         LDKAcceptChannel ret = *owner->contents.result;
9683         ret.is_owned = false;
9684         return ret;
9685 }
9686 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9687         LDKCResult_AcceptChannelDecodeErrorZ* owner_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)untag_ptr(owner);
9688         LDKAcceptChannel ret_var = CResult_AcceptChannelDecodeErrorZ_get_ok(owner_conv);
9689         int64_t ret_ref = 0;
9690         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9691         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
9692         return ret_ref;
9693 }
9694
9695 static inline struct LDKDecodeError CResult_AcceptChannelDecodeErrorZ_get_err(LDKCResult_AcceptChannelDecodeErrorZ *NONNULL_PTR owner){
9696 CHECK(!owner->result_ok);
9697         return DecodeError_clone(&*owner->contents.err);
9698 }
9699 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9700         LDKCResult_AcceptChannelDecodeErrorZ* owner_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)untag_ptr(owner);
9701         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
9702         *ret_copy = CResult_AcceptChannelDecodeErrorZ_get_err(owner_conv);
9703         int64_t ret_ref = tag_ptr(ret_copy, true);
9704         return ret_ref;
9705 }
9706
9707 static inline struct LDKAnnouncementSignatures CResult_AnnouncementSignaturesDecodeErrorZ_get_ok(LDKCResult_AnnouncementSignaturesDecodeErrorZ *NONNULL_PTR owner){
9708         LDKAnnouncementSignatures ret = *owner->contents.result;
9709         ret.is_owned = false;
9710         return ret;
9711 }
9712 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9713         LDKCResult_AnnouncementSignaturesDecodeErrorZ* owner_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)untag_ptr(owner);
9714         LDKAnnouncementSignatures ret_var = CResult_AnnouncementSignaturesDecodeErrorZ_get_ok(owner_conv);
9715         int64_t ret_ref = 0;
9716         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9717         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
9718         return ret_ref;
9719 }
9720
9721 static inline struct LDKDecodeError CResult_AnnouncementSignaturesDecodeErrorZ_get_err(LDKCResult_AnnouncementSignaturesDecodeErrorZ *NONNULL_PTR owner){
9722 CHECK(!owner->result_ok);
9723         return DecodeError_clone(&*owner->contents.err);
9724 }
9725 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9726         LDKCResult_AnnouncementSignaturesDecodeErrorZ* owner_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)untag_ptr(owner);
9727         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
9728         *ret_copy = CResult_AnnouncementSignaturesDecodeErrorZ_get_err(owner_conv);
9729         int64_t ret_ref = tag_ptr(ret_copy, true);
9730         return ret_ref;
9731 }
9732
9733 static inline struct LDKChannelReestablish CResult_ChannelReestablishDecodeErrorZ_get_ok(LDKCResult_ChannelReestablishDecodeErrorZ *NONNULL_PTR owner){
9734         LDKChannelReestablish ret = *owner->contents.result;
9735         ret.is_owned = false;
9736         return ret;
9737 }
9738 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9739         LDKCResult_ChannelReestablishDecodeErrorZ* owner_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)untag_ptr(owner);
9740         LDKChannelReestablish ret_var = CResult_ChannelReestablishDecodeErrorZ_get_ok(owner_conv);
9741         int64_t ret_ref = 0;
9742         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9743         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
9744         return ret_ref;
9745 }
9746
9747 static inline struct LDKDecodeError CResult_ChannelReestablishDecodeErrorZ_get_err(LDKCResult_ChannelReestablishDecodeErrorZ *NONNULL_PTR owner){
9748 CHECK(!owner->result_ok);
9749         return DecodeError_clone(&*owner->contents.err);
9750 }
9751 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9752         LDKCResult_ChannelReestablishDecodeErrorZ* owner_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)untag_ptr(owner);
9753         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
9754         *ret_copy = CResult_ChannelReestablishDecodeErrorZ_get_err(owner_conv);
9755         int64_t ret_ref = tag_ptr(ret_copy, true);
9756         return ret_ref;
9757 }
9758
9759 static inline struct LDKClosingSigned CResult_ClosingSignedDecodeErrorZ_get_ok(LDKCResult_ClosingSignedDecodeErrorZ *NONNULL_PTR owner){
9760         LDKClosingSigned ret = *owner->contents.result;
9761         ret.is_owned = false;
9762         return ret;
9763 }
9764 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9765         LDKCResult_ClosingSignedDecodeErrorZ* owner_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)untag_ptr(owner);
9766         LDKClosingSigned ret_var = CResult_ClosingSignedDecodeErrorZ_get_ok(owner_conv);
9767         int64_t ret_ref = 0;
9768         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9769         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
9770         return ret_ref;
9771 }
9772
9773 static inline struct LDKDecodeError CResult_ClosingSignedDecodeErrorZ_get_err(LDKCResult_ClosingSignedDecodeErrorZ *NONNULL_PTR owner){
9774 CHECK(!owner->result_ok);
9775         return DecodeError_clone(&*owner->contents.err);
9776 }
9777 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9778         LDKCResult_ClosingSignedDecodeErrorZ* owner_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)untag_ptr(owner);
9779         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
9780         *ret_copy = CResult_ClosingSignedDecodeErrorZ_get_err(owner_conv);
9781         int64_t ret_ref = tag_ptr(ret_copy, true);
9782         return ret_ref;
9783 }
9784
9785 static inline struct LDKClosingSignedFeeRange CResult_ClosingSignedFeeRangeDecodeErrorZ_get_ok(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ *NONNULL_PTR owner){
9786         LDKClosingSignedFeeRange ret = *owner->contents.result;
9787         ret.is_owned = false;
9788         return ret;
9789 }
9790 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9791         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* owner_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)untag_ptr(owner);
9792         LDKClosingSignedFeeRange ret_var = CResult_ClosingSignedFeeRangeDecodeErrorZ_get_ok(owner_conv);
9793         int64_t ret_ref = 0;
9794         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9795         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
9796         return ret_ref;
9797 }
9798
9799 static inline struct LDKDecodeError CResult_ClosingSignedFeeRangeDecodeErrorZ_get_err(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ *NONNULL_PTR owner){
9800 CHECK(!owner->result_ok);
9801         return DecodeError_clone(&*owner->contents.err);
9802 }
9803 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9804         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* owner_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)untag_ptr(owner);
9805         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
9806         *ret_copy = CResult_ClosingSignedFeeRangeDecodeErrorZ_get_err(owner_conv);
9807         int64_t ret_ref = tag_ptr(ret_copy, true);
9808         return ret_ref;
9809 }
9810
9811 static inline struct LDKCommitmentSigned CResult_CommitmentSignedDecodeErrorZ_get_ok(LDKCResult_CommitmentSignedDecodeErrorZ *NONNULL_PTR owner){
9812         LDKCommitmentSigned ret = *owner->contents.result;
9813         ret.is_owned = false;
9814         return ret;
9815 }
9816 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9817         LDKCResult_CommitmentSignedDecodeErrorZ* owner_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)untag_ptr(owner);
9818         LDKCommitmentSigned ret_var = CResult_CommitmentSignedDecodeErrorZ_get_ok(owner_conv);
9819         int64_t ret_ref = 0;
9820         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9821         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
9822         return ret_ref;
9823 }
9824
9825 static inline struct LDKDecodeError CResult_CommitmentSignedDecodeErrorZ_get_err(LDKCResult_CommitmentSignedDecodeErrorZ *NONNULL_PTR owner){
9826 CHECK(!owner->result_ok);
9827         return DecodeError_clone(&*owner->contents.err);
9828 }
9829 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9830         LDKCResult_CommitmentSignedDecodeErrorZ* owner_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)untag_ptr(owner);
9831         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
9832         *ret_copy = CResult_CommitmentSignedDecodeErrorZ_get_err(owner_conv);
9833         int64_t ret_ref = tag_ptr(ret_copy, true);
9834         return ret_ref;
9835 }
9836
9837 static inline struct LDKFundingCreated CResult_FundingCreatedDecodeErrorZ_get_ok(LDKCResult_FundingCreatedDecodeErrorZ *NONNULL_PTR owner){
9838         LDKFundingCreated ret = *owner->contents.result;
9839         ret.is_owned = false;
9840         return ret;
9841 }
9842 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9843         LDKCResult_FundingCreatedDecodeErrorZ* owner_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)untag_ptr(owner);
9844         LDKFundingCreated ret_var = CResult_FundingCreatedDecodeErrorZ_get_ok(owner_conv);
9845         int64_t ret_ref = 0;
9846         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9847         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
9848         return ret_ref;
9849 }
9850
9851 static inline struct LDKDecodeError CResult_FundingCreatedDecodeErrorZ_get_err(LDKCResult_FundingCreatedDecodeErrorZ *NONNULL_PTR owner){
9852 CHECK(!owner->result_ok);
9853         return DecodeError_clone(&*owner->contents.err);
9854 }
9855 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9856         LDKCResult_FundingCreatedDecodeErrorZ* owner_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)untag_ptr(owner);
9857         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
9858         *ret_copy = CResult_FundingCreatedDecodeErrorZ_get_err(owner_conv);
9859         int64_t ret_ref = tag_ptr(ret_copy, true);
9860         return ret_ref;
9861 }
9862
9863 static inline struct LDKFundingSigned CResult_FundingSignedDecodeErrorZ_get_ok(LDKCResult_FundingSignedDecodeErrorZ *NONNULL_PTR owner){
9864         LDKFundingSigned ret = *owner->contents.result;
9865         ret.is_owned = false;
9866         return ret;
9867 }
9868 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9869         LDKCResult_FundingSignedDecodeErrorZ* owner_conv = (LDKCResult_FundingSignedDecodeErrorZ*)untag_ptr(owner);
9870         LDKFundingSigned ret_var = CResult_FundingSignedDecodeErrorZ_get_ok(owner_conv);
9871         int64_t ret_ref = 0;
9872         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9873         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
9874         return ret_ref;
9875 }
9876
9877 static inline struct LDKDecodeError CResult_FundingSignedDecodeErrorZ_get_err(LDKCResult_FundingSignedDecodeErrorZ *NONNULL_PTR owner){
9878 CHECK(!owner->result_ok);
9879         return DecodeError_clone(&*owner->contents.err);
9880 }
9881 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9882         LDKCResult_FundingSignedDecodeErrorZ* owner_conv = (LDKCResult_FundingSignedDecodeErrorZ*)untag_ptr(owner);
9883         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
9884         *ret_copy = CResult_FundingSignedDecodeErrorZ_get_err(owner_conv);
9885         int64_t ret_ref = tag_ptr(ret_copy, true);
9886         return ret_ref;
9887 }
9888
9889 static inline struct LDKChannelReady CResult_ChannelReadyDecodeErrorZ_get_ok(LDKCResult_ChannelReadyDecodeErrorZ *NONNULL_PTR owner){
9890         LDKChannelReady ret = *owner->contents.result;
9891         ret.is_owned = false;
9892         return ret;
9893 }
9894 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReadyDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9895         LDKCResult_ChannelReadyDecodeErrorZ* owner_conv = (LDKCResult_ChannelReadyDecodeErrorZ*)untag_ptr(owner);
9896         LDKChannelReady ret_var = CResult_ChannelReadyDecodeErrorZ_get_ok(owner_conv);
9897         int64_t ret_ref = 0;
9898         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9899         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
9900         return ret_ref;
9901 }
9902
9903 static inline struct LDKDecodeError CResult_ChannelReadyDecodeErrorZ_get_err(LDKCResult_ChannelReadyDecodeErrorZ *NONNULL_PTR owner){
9904 CHECK(!owner->result_ok);
9905         return DecodeError_clone(&*owner->contents.err);
9906 }
9907 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReadyDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9908         LDKCResult_ChannelReadyDecodeErrorZ* owner_conv = (LDKCResult_ChannelReadyDecodeErrorZ*)untag_ptr(owner);
9909         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
9910         *ret_copy = CResult_ChannelReadyDecodeErrorZ_get_err(owner_conv);
9911         int64_t ret_ref = tag_ptr(ret_copy, true);
9912         return ret_ref;
9913 }
9914
9915 static inline struct LDKInit CResult_InitDecodeErrorZ_get_ok(LDKCResult_InitDecodeErrorZ *NONNULL_PTR owner){
9916         LDKInit ret = *owner->contents.result;
9917         ret.is_owned = false;
9918         return ret;
9919 }
9920 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9921         LDKCResult_InitDecodeErrorZ* owner_conv = (LDKCResult_InitDecodeErrorZ*)untag_ptr(owner);
9922         LDKInit ret_var = CResult_InitDecodeErrorZ_get_ok(owner_conv);
9923         int64_t ret_ref = 0;
9924         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9925         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
9926         return ret_ref;
9927 }
9928
9929 static inline struct LDKDecodeError CResult_InitDecodeErrorZ_get_err(LDKCResult_InitDecodeErrorZ *NONNULL_PTR owner){
9930 CHECK(!owner->result_ok);
9931         return DecodeError_clone(&*owner->contents.err);
9932 }
9933 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9934         LDKCResult_InitDecodeErrorZ* owner_conv = (LDKCResult_InitDecodeErrorZ*)untag_ptr(owner);
9935         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
9936         *ret_copy = CResult_InitDecodeErrorZ_get_err(owner_conv);
9937         int64_t ret_ref = tag_ptr(ret_copy, true);
9938         return ret_ref;
9939 }
9940
9941 static inline struct LDKOpenChannel CResult_OpenChannelDecodeErrorZ_get_ok(LDKCResult_OpenChannelDecodeErrorZ *NONNULL_PTR owner){
9942         LDKOpenChannel ret = *owner->contents.result;
9943         ret.is_owned = false;
9944         return ret;
9945 }
9946 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9947         LDKCResult_OpenChannelDecodeErrorZ* owner_conv = (LDKCResult_OpenChannelDecodeErrorZ*)untag_ptr(owner);
9948         LDKOpenChannel ret_var = CResult_OpenChannelDecodeErrorZ_get_ok(owner_conv);
9949         int64_t ret_ref = 0;
9950         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9951         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
9952         return ret_ref;
9953 }
9954
9955 static inline struct LDKDecodeError CResult_OpenChannelDecodeErrorZ_get_err(LDKCResult_OpenChannelDecodeErrorZ *NONNULL_PTR owner){
9956 CHECK(!owner->result_ok);
9957         return DecodeError_clone(&*owner->contents.err);
9958 }
9959 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9960         LDKCResult_OpenChannelDecodeErrorZ* owner_conv = (LDKCResult_OpenChannelDecodeErrorZ*)untag_ptr(owner);
9961         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
9962         *ret_copy = CResult_OpenChannelDecodeErrorZ_get_err(owner_conv);
9963         int64_t ret_ref = tag_ptr(ret_copy, true);
9964         return ret_ref;
9965 }
9966
9967 static inline struct LDKRevokeAndACK CResult_RevokeAndACKDecodeErrorZ_get_ok(LDKCResult_RevokeAndACKDecodeErrorZ *NONNULL_PTR owner){
9968         LDKRevokeAndACK ret = *owner->contents.result;
9969         ret.is_owned = false;
9970         return ret;
9971 }
9972 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9973         LDKCResult_RevokeAndACKDecodeErrorZ* owner_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)untag_ptr(owner);
9974         LDKRevokeAndACK ret_var = CResult_RevokeAndACKDecodeErrorZ_get_ok(owner_conv);
9975         int64_t ret_ref = 0;
9976         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
9977         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
9978         return ret_ref;
9979 }
9980
9981 static inline struct LDKDecodeError CResult_RevokeAndACKDecodeErrorZ_get_err(LDKCResult_RevokeAndACKDecodeErrorZ *NONNULL_PTR owner){
9982 CHECK(!owner->result_ok);
9983         return DecodeError_clone(&*owner->contents.err);
9984 }
9985 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
9986         LDKCResult_RevokeAndACKDecodeErrorZ* owner_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)untag_ptr(owner);
9987         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
9988         *ret_copy = CResult_RevokeAndACKDecodeErrorZ_get_err(owner_conv);
9989         int64_t ret_ref = tag_ptr(ret_copy, true);
9990         return ret_ref;
9991 }
9992
9993 static inline struct LDKShutdown CResult_ShutdownDecodeErrorZ_get_ok(LDKCResult_ShutdownDecodeErrorZ *NONNULL_PTR owner){
9994         LDKShutdown ret = *owner->contents.result;
9995         ret.is_owned = false;
9996         return ret;
9997 }
9998 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
9999         LDKCResult_ShutdownDecodeErrorZ* owner_conv = (LDKCResult_ShutdownDecodeErrorZ*)untag_ptr(owner);
10000         LDKShutdown ret_var = CResult_ShutdownDecodeErrorZ_get_ok(owner_conv);
10001         int64_t ret_ref = 0;
10002         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
10003         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
10004         return ret_ref;
10005 }
10006
10007 static inline struct LDKDecodeError CResult_ShutdownDecodeErrorZ_get_err(LDKCResult_ShutdownDecodeErrorZ *NONNULL_PTR owner){
10008 CHECK(!owner->result_ok);
10009         return DecodeError_clone(&*owner->contents.err);
10010 }
10011 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
10012         LDKCResult_ShutdownDecodeErrorZ* owner_conv = (LDKCResult_ShutdownDecodeErrorZ*)untag_ptr(owner);
10013         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
10014         *ret_copy = CResult_ShutdownDecodeErrorZ_get_err(owner_conv);
10015         int64_t ret_ref = tag_ptr(ret_copy, true);
10016         return ret_ref;
10017 }
10018
10019 static inline struct LDKUpdateFailHTLC CResult_UpdateFailHTLCDecodeErrorZ_get_ok(LDKCResult_UpdateFailHTLCDecodeErrorZ *NONNULL_PTR owner){
10020         LDKUpdateFailHTLC ret = *owner->contents.result;
10021         ret.is_owned = false;
10022         return ret;
10023 }
10024 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
10025         LDKCResult_UpdateFailHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)untag_ptr(owner);
10026         LDKUpdateFailHTLC ret_var = CResult_UpdateFailHTLCDecodeErrorZ_get_ok(owner_conv);
10027         int64_t ret_ref = 0;
10028         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
10029         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
10030         return ret_ref;
10031 }
10032
10033 static inline struct LDKDecodeError CResult_UpdateFailHTLCDecodeErrorZ_get_err(LDKCResult_UpdateFailHTLCDecodeErrorZ *NONNULL_PTR owner){
10034 CHECK(!owner->result_ok);
10035         return DecodeError_clone(&*owner->contents.err);
10036 }
10037 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
10038         LDKCResult_UpdateFailHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)untag_ptr(owner);
10039         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
10040         *ret_copy = CResult_UpdateFailHTLCDecodeErrorZ_get_err(owner_conv);
10041         int64_t ret_ref = tag_ptr(ret_copy, true);
10042         return ret_ref;
10043 }
10044
10045 static inline struct LDKUpdateFailMalformedHTLC CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_ok(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *NONNULL_PTR owner){
10046         LDKUpdateFailMalformedHTLC ret = *owner->contents.result;
10047         ret.is_owned = false;
10048         return ret;
10049 }
10050 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
10051         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)untag_ptr(owner);
10052         LDKUpdateFailMalformedHTLC ret_var = CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_ok(owner_conv);
10053         int64_t ret_ref = 0;
10054         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
10055         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
10056         return ret_ref;
10057 }
10058
10059 static inline struct LDKDecodeError CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_err(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *NONNULL_PTR owner){
10060 CHECK(!owner->result_ok);
10061         return DecodeError_clone(&*owner->contents.err);
10062 }
10063 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
10064         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)untag_ptr(owner);
10065         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
10066         *ret_copy = CResult_UpdateFailMalformedHTLCDecodeErrorZ_get_err(owner_conv);
10067         int64_t ret_ref = tag_ptr(ret_copy, true);
10068         return ret_ref;
10069 }
10070
10071 static inline struct LDKUpdateFee CResult_UpdateFeeDecodeErrorZ_get_ok(LDKCResult_UpdateFeeDecodeErrorZ *NONNULL_PTR owner){
10072         LDKUpdateFee ret = *owner->contents.result;
10073         ret.is_owned = false;
10074         return ret;
10075 }
10076 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
10077         LDKCResult_UpdateFeeDecodeErrorZ* owner_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)untag_ptr(owner);
10078         LDKUpdateFee ret_var = CResult_UpdateFeeDecodeErrorZ_get_ok(owner_conv);
10079         int64_t ret_ref = 0;
10080         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
10081         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
10082         return ret_ref;
10083 }
10084
10085 static inline struct LDKDecodeError CResult_UpdateFeeDecodeErrorZ_get_err(LDKCResult_UpdateFeeDecodeErrorZ *NONNULL_PTR owner){
10086 CHECK(!owner->result_ok);
10087         return DecodeError_clone(&*owner->contents.err);
10088 }
10089 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
10090         LDKCResult_UpdateFeeDecodeErrorZ* owner_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)untag_ptr(owner);
10091         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
10092         *ret_copy = CResult_UpdateFeeDecodeErrorZ_get_err(owner_conv);
10093         int64_t ret_ref = tag_ptr(ret_copy, true);
10094         return ret_ref;
10095 }
10096
10097 static inline struct LDKUpdateFulfillHTLC CResult_UpdateFulfillHTLCDecodeErrorZ_get_ok(LDKCResult_UpdateFulfillHTLCDecodeErrorZ *NONNULL_PTR owner){
10098         LDKUpdateFulfillHTLC ret = *owner->contents.result;
10099         ret.is_owned = false;
10100         return ret;
10101 }
10102 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
10103         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)untag_ptr(owner);
10104         LDKUpdateFulfillHTLC ret_var = CResult_UpdateFulfillHTLCDecodeErrorZ_get_ok(owner_conv);
10105         int64_t ret_ref = 0;
10106         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
10107         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
10108         return ret_ref;
10109 }
10110
10111 static inline struct LDKDecodeError CResult_UpdateFulfillHTLCDecodeErrorZ_get_err(LDKCResult_UpdateFulfillHTLCDecodeErrorZ *NONNULL_PTR owner){
10112 CHECK(!owner->result_ok);
10113         return DecodeError_clone(&*owner->contents.err);
10114 }
10115 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
10116         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)untag_ptr(owner);
10117         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
10118         *ret_copy = CResult_UpdateFulfillHTLCDecodeErrorZ_get_err(owner_conv);
10119         int64_t ret_ref = tag_ptr(ret_copy, true);
10120         return ret_ref;
10121 }
10122
10123 static inline struct LDKUpdateAddHTLC CResult_UpdateAddHTLCDecodeErrorZ_get_ok(LDKCResult_UpdateAddHTLCDecodeErrorZ *NONNULL_PTR owner){
10124         LDKUpdateAddHTLC ret = *owner->contents.result;
10125         ret.is_owned = false;
10126         return ret;
10127 }
10128 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
10129         LDKCResult_UpdateAddHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)untag_ptr(owner);
10130         LDKUpdateAddHTLC ret_var = CResult_UpdateAddHTLCDecodeErrorZ_get_ok(owner_conv);
10131         int64_t ret_ref = 0;
10132         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
10133         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
10134         return ret_ref;
10135 }
10136
10137 static inline struct LDKDecodeError CResult_UpdateAddHTLCDecodeErrorZ_get_err(LDKCResult_UpdateAddHTLCDecodeErrorZ *NONNULL_PTR owner){
10138 CHECK(!owner->result_ok);
10139         return DecodeError_clone(&*owner->contents.err);
10140 }
10141 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
10142         LDKCResult_UpdateAddHTLCDecodeErrorZ* owner_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)untag_ptr(owner);
10143         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
10144         *ret_copy = CResult_UpdateAddHTLCDecodeErrorZ_get_err(owner_conv);
10145         int64_t ret_ref = tag_ptr(ret_copy, true);
10146         return ret_ref;
10147 }
10148
10149 static inline struct LDKOnionMessage CResult_OnionMessageDecodeErrorZ_get_ok(LDKCResult_OnionMessageDecodeErrorZ *NONNULL_PTR owner){
10150         LDKOnionMessage ret = *owner->contents.result;
10151         ret.is_owned = false;
10152         return ret;
10153 }
10154 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OnionMessageDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
10155         LDKCResult_OnionMessageDecodeErrorZ* owner_conv = (LDKCResult_OnionMessageDecodeErrorZ*)untag_ptr(owner);
10156         LDKOnionMessage ret_var = CResult_OnionMessageDecodeErrorZ_get_ok(owner_conv);
10157         int64_t ret_ref = 0;
10158         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
10159         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
10160         return ret_ref;
10161 }
10162
10163 static inline struct LDKDecodeError CResult_OnionMessageDecodeErrorZ_get_err(LDKCResult_OnionMessageDecodeErrorZ *NONNULL_PTR owner){
10164 CHECK(!owner->result_ok);
10165         return DecodeError_clone(&*owner->contents.err);
10166 }
10167 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OnionMessageDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
10168         LDKCResult_OnionMessageDecodeErrorZ* owner_conv = (LDKCResult_OnionMessageDecodeErrorZ*)untag_ptr(owner);
10169         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
10170         *ret_copy = CResult_OnionMessageDecodeErrorZ_get_err(owner_conv);
10171         int64_t ret_ref = tag_ptr(ret_copy, true);
10172         return ret_ref;
10173 }
10174
10175 static inline struct LDKPing CResult_PingDecodeErrorZ_get_ok(LDKCResult_PingDecodeErrorZ *NONNULL_PTR owner){
10176         LDKPing ret = *owner->contents.result;
10177         ret.is_owned = false;
10178         return ret;
10179 }
10180 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
10181         LDKCResult_PingDecodeErrorZ* owner_conv = (LDKCResult_PingDecodeErrorZ*)untag_ptr(owner);
10182         LDKPing ret_var = CResult_PingDecodeErrorZ_get_ok(owner_conv);
10183         int64_t ret_ref = 0;
10184         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
10185         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
10186         return ret_ref;
10187 }
10188
10189 static inline struct LDKDecodeError CResult_PingDecodeErrorZ_get_err(LDKCResult_PingDecodeErrorZ *NONNULL_PTR owner){
10190 CHECK(!owner->result_ok);
10191         return DecodeError_clone(&*owner->contents.err);
10192 }
10193 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
10194         LDKCResult_PingDecodeErrorZ* owner_conv = (LDKCResult_PingDecodeErrorZ*)untag_ptr(owner);
10195         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
10196         *ret_copy = CResult_PingDecodeErrorZ_get_err(owner_conv);
10197         int64_t ret_ref = tag_ptr(ret_copy, true);
10198         return ret_ref;
10199 }
10200
10201 static inline struct LDKPong CResult_PongDecodeErrorZ_get_ok(LDKCResult_PongDecodeErrorZ *NONNULL_PTR owner){
10202         LDKPong ret = *owner->contents.result;
10203         ret.is_owned = false;
10204         return ret;
10205 }
10206 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
10207         LDKCResult_PongDecodeErrorZ* owner_conv = (LDKCResult_PongDecodeErrorZ*)untag_ptr(owner);
10208         LDKPong ret_var = CResult_PongDecodeErrorZ_get_ok(owner_conv);
10209         int64_t ret_ref = 0;
10210         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
10211         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
10212         return ret_ref;
10213 }
10214
10215 static inline struct LDKDecodeError CResult_PongDecodeErrorZ_get_err(LDKCResult_PongDecodeErrorZ *NONNULL_PTR owner){
10216 CHECK(!owner->result_ok);
10217         return DecodeError_clone(&*owner->contents.err);
10218 }
10219 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
10220         LDKCResult_PongDecodeErrorZ* owner_conv = (LDKCResult_PongDecodeErrorZ*)untag_ptr(owner);
10221         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
10222         *ret_copy = CResult_PongDecodeErrorZ_get_err(owner_conv);
10223         int64_t ret_ref = tag_ptr(ret_copy, true);
10224         return ret_ref;
10225 }
10226
10227 static inline struct LDKUnsignedChannelAnnouncement CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_ok(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *NONNULL_PTR owner){
10228         LDKUnsignedChannelAnnouncement ret = *owner->contents.result;
10229         ret.is_owned = false;
10230         return ret;
10231 }
10232 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
10233         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)untag_ptr(owner);
10234         LDKUnsignedChannelAnnouncement ret_var = CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_ok(owner_conv);
10235         int64_t ret_ref = 0;
10236         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
10237         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
10238         return ret_ref;
10239 }
10240
10241 static inline struct LDKDecodeError CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_err(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *NONNULL_PTR owner){
10242 CHECK(!owner->result_ok);
10243         return DecodeError_clone(&*owner->contents.err);
10244 }
10245 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
10246         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)untag_ptr(owner);
10247         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
10248         *ret_copy = CResult_UnsignedChannelAnnouncementDecodeErrorZ_get_err(owner_conv);
10249         int64_t ret_ref = tag_ptr(ret_copy, true);
10250         return ret_ref;
10251 }
10252
10253 static inline struct LDKChannelAnnouncement CResult_ChannelAnnouncementDecodeErrorZ_get_ok(LDKCResult_ChannelAnnouncementDecodeErrorZ *NONNULL_PTR owner){
10254         LDKChannelAnnouncement ret = *owner->contents.result;
10255         ret.is_owned = false;
10256         return ret;
10257 }
10258 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
10259         LDKCResult_ChannelAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)untag_ptr(owner);
10260         LDKChannelAnnouncement ret_var = CResult_ChannelAnnouncementDecodeErrorZ_get_ok(owner_conv);
10261         int64_t ret_ref = 0;
10262         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
10263         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
10264         return ret_ref;
10265 }
10266
10267 static inline struct LDKDecodeError CResult_ChannelAnnouncementDecodeErrorZ_get_err(LDKCResult_ChannelAnnouncementDecodeErrorZ *NONNULL_PTR owner){
10268 CHECK(!owner->result_ok);
10269         return DecodeError_clone(&*owner->contents.err);
10270 }
10271 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
10272         LDKCResult_ChannelAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)untag_ptr(owner);
10273         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
10274         *ret_copy = CResult_ChannelAnnouncementDecodeErrorZ_get_err(owner_conv);
10275         int64_t ret_ref = tag_ptr(ret_copy, true);
10276         return ret_ref;
10277 }
10278
10279 static inline struct LDKUnsignedChannelUpdate CResult_UnsignedChannelUpdateDecodeErrorZ_get_ok(LDKCResult_UnsignedChannelUpdateDecodeErrorZ *NONNULL_PTR owner){
10280         LDKUnsignedChannelUpdate ret = *owner->contents.result;
10281         ret.is_owned = false;
10282         return ret;
10283 }
10284 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
10285         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* owner_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)untag_ptr(owner);
10286         LDKUnsignedChannelUpdate ret_var = CResult_UnsignedChannelUpdateDecodeErrorZ_get_ok(owner_conv);
10287         int64_t ret_ref = 0;
10288         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
10289         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
10290         return ret_ref;
10291 }
10292
10293 static inline struct LDKDecodeError CResult_UnsignedChannelUpdateDecodeErrorZ_get_err(LDKCResult_UnsignedChannelUpdateDecodeErrorZ *NONNULL_PTR owner){
10294 CHECK(!owner->result_ok);
10295         return DecodeError_clone(&*owner->contents.err);
10296 }
10297 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
10298         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* owner_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)untag_ptr(owner);
10299         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
10300         *ret_copy = CResult_UnsignedChannelUpdateDecodeErrorZ_get_err(owner_conv);
10301         int64_t ret_ref = tag_ptr(ret_copy, true);
10302         return ret_ref;
10303 }
10304
10305 static inline struct LDKChannelUpdate CResult_ChannelUpdateDecodeErrorZ_get_ok(LDKCResult_ChannelUpdateDecodeErrorZ *NONNULL_PTR owner){
10306         LDKChannelUpdate ret = *owner->contents.result;
10307         ret.is_owned = false;
10308         return ret;
10309 }
10310 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
10311         LDKCResult_ChannelUpdateDecodeErrorZ* owner_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)untag_ptr(owner);
10312         LDKChannelUpdate ret_var = CResult_ChannelUpdateDecodeErrorZ_get_ok(owner_conv);
10313         int64_t ret_ref = 0;
10314         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
10315         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
10316         return ret_ref;
10317 }
10318
10319 static inline struct LDKDecodeError CResult_ChannelUpdateDecodeErrorZ_get_err(LDKCResult_ChannelUpdateDecodeErrorZ *NONNULL_PTR owner){
10320 CHECK(!owner->result_ok);
10321         return DecodeError_clone(&*owner->contents.err);
10322 }
10323 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
10324         LDKCResult_ChannelUpdateDecodeErrorZ* owner_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)untag_ptr(owner);
10325         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
10326         *ret_copy = CResult_ChannelUpdateDecodeErrorZ_get_err(owner_conv);
10327         int64_t ret_ref = tag_ptr(ret_copy, true);
10328         return ret_ref;
10329 }
10330
10331 static inline struct LDKErrorMessage CResult_ErrorMessageDecodeErrorZ_get_ok(LDKCResult_ErrorMessageDecodeErrorZ *NONNULL_PTR owner){
10332         LDKErrorMessage ret = *owner->contents.result;
10333         ret.is_owned = false;
10334         return ret;
10335 }
10336 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
10337         LDKCResult_ErrorMessageDecodeErrorZ* owner_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)untag_ptr(owner);
10338         LDKErrorMessage ret_var = CResult_ErrorMessageDecodeErrorZ_get_ok(owner_conv);
10339         int64_t ret_ref = 0;
10340         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
10341         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
10342         return ret_ref;
10343 }
10344
10345 static inline struct LDKDecodeError CResult_ErrorMessageDecodeErrorZ_get_err(LDKCResult_ErrorMessageDecodeErrorZ *NONNULL_PTR owner){
10346 CHECK(!owner->result_ok);
10347         return DecodeError_clone(&*owner->contents.err);
10348 }
10349 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
10350         LDKCResult_ErrorMessageDecodeErrorZ* owner_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)untag_ptr(owner);
10351         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
10352         *ret_copy = CResult_ErrorMessageDecodeErrorZ_get_err(owner_conv);
10353         int64_t ret_ref = tag_ptr(ret_copy, true);
10354         return ret_ref;
10355 }
10356
10357 static inline struct LDKWarningMessage CResult_WarningMessageDecodeErrorZ_get_ok(LDKCResult_WarningMessageDecodeErrorZ *NONNULL_PTR owner){
10358         LDKWarningMessage ret = *owner->contents.result;
10359         ret.is_owned = false;
10360         return ret;
10361 }
10362 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1WarningMessageDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
10363         LDKCResult_WarningMessageDecodeErrorZ* owner_conv = (LDKCResult_WarningMessageDecodeErrorZ*)untag_ptr(owner);
10364         LDKWarningMessage ret_var = CResult_WarningMessageDecodeErrorZ_get_ok(owner_conv);
10365         int64_t ret_ref = 0;
10366         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
10367         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
10368         return ret_ref;
10369 }
10370
10371 static inline struct LDKDecodeError CResult_WarningMessageDecodeErrorZ_get_err(LDKCResult_WarningMessageDecodeErrorZ *NONNULL_PTR owner){
10372 CHECK(!owner->result_ok);
10373         return DecodeError_clone(&*owner->contents.err);
10374 }
10375 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1WarningMessageDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
10376         LDKCResult_WarningMessageDecodeErrorZ* owner_conv = (LDKCResult_WarningMessageDecodeErrorZ*)untag_ptr(owner);
10377         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
10378         *ret_copy = CResult_WarningMessageDecodeErrorZ_get_err(owner_conv);
10379         int64_t ret_ref = tag_ptr(ret_copy, true);
10380         return ret_ref;
10381 }
10382
10383 static inline struct LDKUnsignedNodeAnnouncement CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_ok(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *NONNULL_PTR owner){
10384         LDKUnsignedNodeAnnouncement ret = *owner->contents.result;
10385         ret.is_owned = false;
10386         return ret;
10387 }
10388 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
10389         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)untag_ptr(owner);
10390         LDKUnsignedNodeAnnouncement ret_var = CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_ok(owner_conv);
10391         int64_t ret_ref = 0;
10392         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
10393         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
10394         return ret_ref;
10395 }
10396
10397 static inline struct LDKDecodeError CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_err(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *NONNULL_PTR owner){
10398 CHECK(!owner->result_ok);
10399         return DecodeError_clone(&*owner->contents.err);
10400 }
10401 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
10402         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)untag_ptr(owner);
10403         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
10404         *ret_copy = CResult_UnsignedNodeAnnouncementDecodeErrorZ_get_err(owner_conv);
10405         int64_t ret_ref = tag_ptr(ret_copy, true);
10406         return ret_ref;
10407 }
10408
10409 static inline struct LDKNodeAnnouncement CResult_NodeAnnouncementDecodeErrorZ_get_ok(LDKCResult_NodeAnnouncementDecodeErrorZ *NONNULL_PTR owner){
10410         LDKNodeAnnouncement ret = *owner->contents.result;
10411         ret.is_owned = false;
10412         return ret;
10413 }
10414 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
10415         LDKCResult_NodeAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)untag_ptr(owner);
10416         LDKNodeAnnouncement ret_var = CResult_NodeAnnouncementDecodeErrorZ_get_ok(owner_conv);
10417         int64_t ret_ref = 0;
10418         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
10419         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
10420         return ret_ref;
10421 }
10422
10423 static inline struct LDKDecodeError CResult_NodeAnnouncementDecodeErrorZ_get_err(LDKCResult_NodeAnnouncementDecodeErrorZ *NONNULL_PTR owner){
10424 CHECK(!owner->result_ok);
10425         return DecodeError_clone(&*owner->contents.err);
10426 }
10427 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
10428         LDKCResult_NodeAnnouncementDecodeErrorZ* owner_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)untag_ptr(owner);
10429         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
10430         *ret_copy = CResult_NodeAnnouncementDecodeErrorZ_get_err(owner_conv);
10431         int64_t ret_ref = tag_ptr(ret_copy, true);
10432         return ret_ref;
10433 }
10434
10435 static inline struct LDKQueryShortChannelIds CResult_QueryShortChannelIdsDecodeErrorZ_get_ok(LDKCResult_QueryShortChannelIdsDecodeErrorZ *NONNULL_PTR owner){
10436         LDKQueryShortChannelIds ret = *owner->contents.result;
10437         ret.is_owned = false;
10438         return ret;
10439 }
10440 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
10441         LDKCResult_QueryShortChannelIdsDecodeErrorZ* owner_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)untag_ptr(owner);
10442         LDKQueryShortChannelIds ret_var = CResult_QueryShortChannelIdsDecodeErrorZ_get_ok(owner_conv);
10443         int64_t ret_ref = 0;
10444         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
10445         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
10446         return ret_ref;
10447 }
10448
10449 static inline struct LDKDecodeError CResult_QueryShortChannelIdsDecodeErrorZ_get_err(LDKCResult_QueryShortChannelIdsDecodeErrorZ *NONNULL_PTR owner){
10450 CHECK(!owner->result_ok);
10451         return DecodeError_clone(&*owner->contents.err);
10452 }
10453 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
10454         LDKCResult_QueryShortChannelIdsDecodeErrorZ* owner_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)untag_ptr(owner);
10455         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
10456         *ret_copy = CResult_QueryShortChannelIdsDecodeErrorZ_get_err(owner_conv);
10457         int64_t ret_ref = tag_ptr(ret_copy, true);
10458         return ret_ref;
10459 }
10460
10461 static inline struct LDKReplyShortChannelIdsEnd CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_ok(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *NONNULL_PTR owner){
10462         LDKReplyShortChannelIdsEnd ret = *owner->contents.result;
10463         ret.is_owned = false;
10464         return ret;
10465 }
10466 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
10467         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* owner_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)untag_ptr(owner);
10468         LDKReplyShortChannelIdsEnd ret_var = CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_ok(owner_conv);
10469         int64_t ret_ref = 0;
10470         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
10471         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
10472         return ret_ref;
10473 }
10474
10475 static inline struct LDKDecodeError CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_err(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *NONNULL_PTR owner){
10476 CHECK(!owner->result_ok);
10477         return DecodeError_clone(&*owner->contents.err);
10478 }
10479 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
10480         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* owner_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)untag_ptr(owner);
10481         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
10482         *ret_copy = CResult_ReplyShortChannelIdsEndDecodeErrorZ_get_err(owner_conv);
10483         int64_t ret_ref = tag_ptr(ret_copy, true);
10484         return ret_ref;
10485 }
10486
10487 static inline struct LDKQueryChannelRange CResult_QueryChannelRangeDecodeErrorZ_get_ok(LDKCResult_QueryChannelRangeDecodeErrorZ *NONNULL_PTR owner){
10488         LDKQueryChannelRange ret = *owner->contents.result;
10489         ret.is_owned = false;
10490         return ret;
10491 }
10492 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
10493         LDKCResult_QueryChannelRangeDecodeErrorZ* owner_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)untag_ptr(owner);
10494         LDKQueryChannelRange ret_var = CResult_QueryChannelRangeDecodeErrorZ_get_ok(owner_conv);
10495         int64_t ret_ref = 0;
10496         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
10497         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
10498         return ret_ref;
10499 }
10500
10501 static inline struct LDKDecodeError CResult_QueryChannelRangeDecodeErrorZ_get_err(LDKCResult_QueryChannelRangeDecodeErrorZ *NONNULL_PTR owner){
10502 CHECK(!owner->result_ok);
10503         return DecodeError_clone(&*owner->contents.err);
10504 }
10505 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
10506         LDKCResult_QueryChannelRangeDecodeErrorZ* owner_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)untag_ptr(owner);
10507         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
10508         *ret_copy = CResult_QueryChannelRangeDecodeErrorZ_get_err(owner_conv);
10509         int64_t ret_ref = tag_ptr(ret_copy, true);
10510         return ret_ref;
10511 }
10512
10513 static inline struct LDKReplyChannelRange CResult_ReplyChannelRangeDecodeErrorZ_get_ok(LDKCResult_ReplyChannelRangeDecodeErrorZ *NONNULL_PTR owner){
10514         LDKReplyChannelRange ret = *owner->contents.result;
10515         ret.is_owned = false;
10516         return ret;
10517 }
10518 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
10519         LDKCResult_ReplyChannelRangeDecodeErrorZ* owner_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)untag_ptr(owner);
10520         LDKReplyChannelRange ret_var = CResult_ReplyChannelRangeDecodeErrorZ_get_ok(owner_conv);
10521         int64_t ret_ref = 0;
10522         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
10523         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
10524         return ret_ref;
10525 }
10526
10527 static inline struct LDKDecodeError CResult_ReplyChannelRangeDecodeErrorZ_get_err(LDKCResult_ReplyChannelRangeDecodeErrorZ *NONNULL_PTR owner){
10528 CHECK(!owner->result_ok);
10529         return DecodeError_clone(&*owner->contents.err);
10530 }
10531 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
10532         LDKCResult_ReplyChannelRangeDecodeErrorZ* owner_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)untag_ptr(owner);
10533         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
10534         *ret_copy = CResult_ReplyChannelRangeDecodeErrorZ_get_err(owner_conv);
10535         int64_t ret_ref = tag_ptr(ret_copy, true);
10536         return ret_ref;
10537 }
10538
10539 static inline struct LDKGossipTimestampFilter CResult_GossipTimestampFilterDecodeErrorZ_get_ok(LDKCResult_GossipTimestampFilterDecodeErrorZ *NONNULL_PTR owner){
10540         LDKGossipTimestampFilter ret = *owner->contents.result;
10541         ret.is_owned = false;
10542         return ret;
10543 }
10544 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
10545         LDKCResult_GossipTimestampFilterDecodeErrorZ* owner_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)untag_ptr(owner);
10546         LDKGossipTimestampFilter ret_var = CResult_GossipTimestampFilterDecodeErrorZ_get_ok(owner_conv);
10547         int64_t ret_ref = 0;
10548         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
10549         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
10550         return ret_ref;
10551 }
10552
10553 static inline struct LDKDecodeError CResult_GossipTimestampFilterDecodeErrorZ_get_err(LDKCResult_GossipTimestampFilterDecodeErrorZ *NONNULL_PTR owner){
10554 CHECK(!owner->result_ok);
10555         return DecodeError_clone(&*owner->contents.err);
10556 }
10557 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
10558         LDKCResult_GossipTimestampFilterDecodeErrorZ* owner_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)untag_ptr(owner);
10559         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
10560         *ret_copy = CResult_GossipTimestampFilterDecodeErrorZ_get_err(owner_conv);
10561         int64_t ret_ref = tag_ptr(ret_copy, true);
10562         return ret_ref;
10563 }
10564
10565 static inline LDKCVec_PhantomRouteHintsZ CVec_PhantomRouteHintsZ_clone(const LDKCVec_PhantomRouteHintsZ *orig) {
10566         LDKCVec_PhantomRouteHintsZ ret = { .data = MALLOC(sizeof(LDKPhantomRouteHints) * orig->datalen, "LDKCVec_PhantomRouteHintsZ clone bytes"), .datalen = orig->datalen };
10567         for (size_t i = 0; i < ret.datalen; i++) {
10568                 ret.data[i] = PhantomRouteHints_clone(&orig->data[i]);
10569         }
10570         return ret;
10571 }
10572 static jclass LDKSignOrCreationError_SignError_class = NULL;
10573 static jmethodID LDKSignOrCreationError_SignError_meth = NULL;
10574 static jclass LDKSignOrCreationError_CreationError_class = NULL;
10575 static jmethodID LDKSignOrCreationError_CreationError_meth = NULL;
10576 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKSignOrCreationError_init (JNIEnv *env, jclass clz) {
10577         LDKSignOrCreationError_SignError_class =
10578                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKSignOrCreationError$SignError"));
10579         CHECK(LDKSignOrCreationError_SignError_class != NULL);
10580         LDKSignOrCreationError_SignError_meth = (*env)->GetMethodID(env, LDKSignOrCreationError_SignError_class, "<init>", "()V");
10581         CHECK(LDKSignOrCreationError_SignError_meth != NULL);
10582         LDKSignOrCreationError_CreationError_class =
10583                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKSignOrCreationError$CreationError"));
10584         CHECK(LDKSignOrCreationError_CreationError_class != NULL);
10585         LDKSignOrCreationError_CreationError_meth = (*env)->GetMethodID(env, LDKSignOrCreationError_CreationError_class, "<init>", "(Lorg/ldk/enums/CreationError;)V");
10586         CHECK(LDKSignOrCreationError_CreationError_meth != NULL);
10587 }
10588 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKSignOrCreationError_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
10589         LDKSignOrCreationError *obj = (LDKSignOrCreationError*)untag_ptr(ptr);
10590         switch(obj->tag) {
10591                 case LDKSignOrCreationError_SignError: {
10592                         return (*env)->NewObject(env, LDKSignOrCreationError_SignError_class, LDKSignOrCreationError_SignError_meth);
10593                 }
10594                 case LDKSignOrCreationError_CreationError: {
10595                         jclass creation_error_conv = LDKCreationError_to_java(env, obj->creation_error);
10596                         return (*env)->NewObject(env, LDKSignOrCreationError_CreationError_class, LDKSignOrCreationError_CreationError_meth, creation_error_conv);
10597                 }
10598                 default: abort();
10599         }
10600 }
10601 static inline struct LDKInvoice CResult_InvoiceSignOrCreationErrorZ_get_ok(LDKCResult_InvoiceSignOrCreationErrorZ *NONNULL_PTR owner){
10602         LDKInvoice ret = *owner->contents.result;
10603         ret.is_owned = false;
10604         return ret;
10605 }
10606 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
10607         LDKCResult_InvoiceSignOrCreationErrorZ* owner_conv = (LDKCResult_InvoiceSignOrCreationErrorZ*)untag_ptr(owner);
10608         LDKInvoice ret_var = CResult_InvoiceSignOrCreationErrorZ_get_ok(owner_conv);
10609         int64_t ret_ref = 0;
10610         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
10611         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
10612         return ret_ref;
10613 }
10614
10615 static inline struct LDKSignOrCreationError CResult_InvoiceSignOrCreationErrorZ_get_err(LDKCResult_InvoiceSignOrCreationErrorZ *NONNULL_PTR owner){
10616 CHECK(!owner->result_ok);
10617         return SignOrCreationError_clone(&*owner->contents.err);
10618 }
10619 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
10620         LDKCResult_InvoiceSignOrCreationErrorZ* owner_conv = (LDKCResult_InvoiceSignOrCreationErrorZ*)untag_ptr(owner);
10621         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
10622         *ret_copy = CResult_InvoiceSignOrCreationErrorZ_get_err(owner_conv);
10623         int64_t ret_ref = tag_ptr(ret_copy, true);
10624         return ret_ref;
10625 }
10626
10627 typedef struct LDKFilter_JCalls {
10628         atomic_size_t refcnt;
10629         JavaVM *vm;
10630         jweak o;
10631         jmethodID register_tx_meth;
10632         jmethodID register_output_meth;
10633 } LDKFilter_JCalls;
10634 static void LDKFilter_JCalls_free(void* this_arg) {
10635         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
10636         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
10637                 JNIEnv *env;
10638                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10639                 if (get_jenv_res == JNI_EDETACHED) {
10640                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10641                 } else {
10642                         DO_ASSERT(get_jenv_res == JNI_OK);
10643                 }
10644                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
10645                 if (get_jenv_res == JNI_EDETACHED) {
10646                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10647                 }
10648                 FREE(j_calls);
10649         }
10650 }
10651 void register_tx_LDKFilter_jcall(const void* this_arg, const uint8_t (* txid)[32], LDKu8slice script_pubkey) {
10652         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
10653         JNIEnv *env;
10654         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10655         if (get_jenv_res == JNI_EDETACHED) {
10656                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10657         } else {
10658                 DO_ASSERT(get_jenv_res == JNI_OK);
10659         }
10660         int8_tArray txid_arr = (*env)->NewByteArray(env, 32);
10661         (*env)->SetByteArrayRegion(env, txid_arr, 0, 32, *txid);
10662         LDKu8slice script_pubkey_var = script_pubkey;
10663         int8_tArray script_pubkey_arr = (*env)->NewByteArray(env, script_pubkey_var.datalen);
10664         (*env)->SetByteArrayRegion(env, script_pubkey_arr, 0, script_pubkey_var.datalen, script_pubkey_var.data);
10665         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10666         CHECK(obj != NULL);
10667         (*env)->CallVoidMethod(env, obj, j_calls->register_tx_meth, txid_arr, script_pubkey_arr);
10668         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10669                 (*env)->ExceptionDescribe(env);
10670                 (*env)->FatalError(env, "A call to register_tx in LDKFilter from rust threw an exception.");
10671         }
10672         if (get_jenv_res == JNI_EDETACHED) {
10673                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10674         }
10675 }
10676 void register_output_LDKFilter_jcall(const void* this_arg, LDKWatchedOutput output) {
10677         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
10678         JNIEnv *env;
10679         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10680         if (get_jenv_res == JNI_EDETACHED) {
10681                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10682         } else {
10683                 DO_ASSERT(get_jenv_res == JNI_OK);
10684         }
10685         LDKWatchedOutput output_var = output;
10686         int64_t output_ref = 0;
10687         CHECK_INNER_FIELD_ACCESS_OR_NULL(output_var);
10688         output_ref = tag_ptr(output_var.inner, output_var.is_owned);
10689         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10690         CHECK(obj != NULL);
10691         (*env)->CallVoidMethod(env, obj, j_calls->register_output_meth, output_ref);
10692         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10693                 (*env)->ExceptionDescribe(env);
10694                 (*env)->FatalError(env, "A call to register_output in LDKFilter from rust threw an exception.");
10695         }
10696         if (get_jenv_res == JNI_EDETACHED) {
10697                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10698         }
10699 }
10700 static void LDKFilter_JCalls_cloned(LDKFilter* new_obj) {
10701         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) new_obj->this_arg;
10702         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
10703 }
10704 static inline LDKFilter LDKFilter_init (JNIEnv *env, jclass clz, jobject o) {
10705         jclass c = (*env)->GetObjectClass(env, o);
10706         CHECK(c != NULL);
10707         LDKFilter_JCalls *calls = MALLOC(sizeof(LDKFilter_JCalls), "LDKFilter_JCalls");
10708         atomic_init(&calls->refcnt, 1);
10709         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
10710         calls->o = (*env)->NewWeakGlobalRef(env, o);
10711         calls->register_tx_meth = (*env)->GetMethodID(env, c, "register_tx", "([B[B)V");
10712         CHECK(calls->register_tx_meth != NULL);
10713         calls->register_output_meth = (*env)->GetMethodID(env, c, "register_output", "(J)V");
10714         CHECK(calls->register_output_meth != NULL);
10715
10716         LDKFilter ret = {
10717                 .this_arg = (void*) calls,
10718                 .register_tx = register_tx_LDKFilter_jcall,
10719                 .register_output = register_output_LDKFilter_jcall,
10720                 .free = LDKFilter_JCalls_free,
10721         };
10722         return ret;
10723 }
10724 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKFilter_1new(JNIEnv *env, jclass clz, jobject o) {
10725         LDKFilter *res_ptr = MALLOC(sizeof(LDKFilter), "LDKFilter");
10726         *res_ptr = LDKFilter_init(env, clz, o);
10727         return tag_ptr(res_ptr, true);
10728 }
10729 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) {
10730         void* this_arg_ptr = untag_ptr(this_arg);
10731         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
10732         LDKFilter* this_arg_conv = (LDKFilter*)this_arg_ptr;
10733         unsigned char txid_arr[32];
10734         CHECK((*env)->GetArrayLength(env, txid) == 32);
10735         (*env)->GetByteArrayRegion(env, txid, 0, 32, txid_arr);
10736         unsigned char (*txid_ref)[32] = &txid_arr;
10737         LDKu8slice script_pubkey_ref;
10738         script_pubkey_ref.datalen = (*env)->GetArrayLength(env, script_pubkey);
10739         script_pubkey_ref.data = (*env)->GetByteArrayElements (env, script_pubkey, NULL);
10740         (this_arg_conv->register_tx)(this_arg_conv->this_arg, txid_ref, script_pubkey_ref);
10741         (*env)->ReleaseByteArrayElements(env, script_pubkey, (int8_t*)script_pubkey_ref.data, 0);
10742 }
10743
10744 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Filter_1register_1output(JNIEnv *env, jclass clz, int64_t this_arg, int64_t output) {
10745         void* this_arg_ptr = untag_ptr(this_arg);
10746         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
10747         LDKFilter* this_arg_conv = (LDKFilter*)this_arg_ptr;
10748         LDKWatchedOutput output_conv;
10749         output_conv.inner = untag_ptr(output);
10750         output_conv.is_owned = ptr_is_owned(output);
10751         CHECK_INNER_FIELD_ACCESS_OR_NULL(output_conv);
10752         output_conv = WatchedOutput_clone(&output_conv);
10753         (this_arg_conv->register_output)(this_arg_conv->this_arg, output_conv);
10754 }
10755
10756 static jclass LDKCOption_FilterZ_Some_class = NULL;
10757 static jmethodID LDKCOption_FilterZ_Some_meth = NULL;
10758 static jclass LDKCOption_FilterZ_None_class = NULL;
10759 static jmethodID LDKCOption_FilterZ_None_meth = NULL;
10760 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1FilterZ_init (JNIEnv *env, jclass clz) {
10761         LDKCOption_FilterZ_Some_class =
10762                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_FilterZ$Some"));
10763         CHECK(LDKCOption_FilterZ_Some_class != NULL);
10764         LDKCOption_FilterZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_FilterZ_Some_class, "<init>", "(J)V");
10765         CHECK(LDKCOption_FilterZ_Some_meth != NULL);
10766         LDKCOption_FilterZ_None_class =
10767                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKCOption_FilterZ$None"));
10768         CHECK(LDKCOption_FilterZ_None_class != NULL);
10769         LDKCOption_FilterZ_None_meth = (*env)->GetMethodID(env, LDKCOption_FilterZ_None_class, "<init>", "()V");
10770         CHECK(LDKCOption_FilterZ_None_meth != NULL);
10771 }
10772 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1FilterZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
10773         LDKCOption_FilterZ *obj = (LDKCOption_FilterZ*)untag_ptr(ptr);
10774         switch(obj->tag) {
10775                 case LDKCOption_FilterZ_Some: {
10776                         LDKFilter* some_ret = MALLOC(sizeof(LDKFilter), "LDKFilter");
10777                         *some_ret = obj->some;
10778                         // WARNING: We likely need to clone here, but no clone is available, so we just do it for Java instances
10779                         if ((*some_ret).free == LDKFilter_JCalls_free) {
10780                                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
10781                                 LDKFilter_JCalls_cloned(&(*some_ret));
10782                         }
10783                         return (*env)->NewObject(env, LDKCOption_FilterZ_Some_class, LDKCOption_FilterZ_Some_meth, tag_ptr(some_ret, true));
10784                 }
10785                 case LDKCOption_FilterZ_None: {
10786                         return (*env)->NewObject(env, LDKCOption_FilterZ_None_class, LDKCOption_FilterZ_None_meth);
10787                 }
10788                 default: abort();
10789         }
10790 }
10791 static inline struct LDKLockedChannelMonitor CResult_LockedChannelMonitorNoneZ_get_ok(LDKCResult_LockedChannelMonitorNoneZ *NONNULL_PTR owner){
10792         LDKLockedChannelMonitor ret = *owner->contents.result;
10793         ret.is_owned = false;
10794         return ret;
10795 }
10796 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1LockedChannelMonitorNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t owner) {
10797         LDKCResult_LockedChannelMonitorNoneZ* owner_conv = (LDKCResult_LockedChannelMonitorNoneZ*)untag_ptr(owner);
10798         LDKLockedChannelMonitor ret_var = CResult_LockedChannelMonitorNoneZ_get_ok(owner_conv);
10799         int64_t ret_ref = 0;
10800         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
10801         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
10802         return ret_ref;
10803 }
10804
10805 static inline void CResult_LockedChannelMonitorNoneZ_get_err(LDKCResult_LockedChannelMonitorNoneZ *NONNULL_PTR owner){
10806 CHECK(!owner->result_ok);
10807         return *owner->contents.err;
10808 }
10809 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1LockedChannelMonitorNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t owner) {
10810         LDKCResult_LockedChannelMonitorNoneZ* owner_conv = (LDKCResult_LockedChannelMonitorNoneZ*)untag_ptr(owner);
10811         CResult_LockedChannelMonitorNoneZ_get_err(owner_conv);
10812 }
10813
10814 static inline LDKCVec_OutPointZ CVec_OutPointZ_clone(const LDKCVec_OutPointZ *orig) {
10815         LDKCVec_OutPointZ ret = { .data = MALLOC(sizeof(LDKOutPoint) * orig->datalen, "LDKCVec_OutPointZ clone bytes"), .datalen = orig->datalen };
10816         for (size_t i = 0; i < ret.datalen; i++) {
10817                 ret.data[i] = OutPoint_clone(&orig->data[i]);
10818         }
10819         return ret;
10820 }
10821 static inline LDKCVec_MonitorUpdateIdZ CVec_MonitorUpdateIdZ_clone(const LDKCVec_MonitorUpdateIdZ *orig) {
10822         LDKCVec_MonitorUpdateIdZ ret = { .data = MALLOC(sizeof(LDKMonitorUpdateId) * orig->datalen, "LDKCVec_MonitorUpdateIdZ clone bytes"), .datalen = orig->datalen };
10823         for (size_t i = 0; i < ret.datalen; i++) {
10824                 ret.data[i] = MonitorUpdateId_clone(&orig->data[i]);
10825         }
10826         return ret;
10827 }
10828 static inline struct LDKOutPoint C2Tuple_OutPointCVec_MonitorUpdateIdZZ_get_a(LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ *NONNULL_PTR owner){
10829         LDKOutPoint ret = owner->a;
10830         ret.is_owned = false;
10831         return ret;
10832 }
10833 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointCVec_1MonitorUpdateIdZZ_1get_1a(JNIEnv *env, jclass clz, int64_t owner) {
10834         LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ* owner_conv = (LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ*)untag_ptr(owner);
10835         LDKOutPoint ret_var = C2Tuple_OutPointCVec_MonitorUpdateIdZZ_get_a(owner_conv);
10836         int64_t ret_ref = 0;
10837         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
10838         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
10839         return ret_ref;
10840 }
10841
10842 static inline struct LDKCVec_MonitorUpdateIdZ C2Tuple_OutPointCVec_MonitorUpdateIdZZ_get_b(LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ *NONNULL_PTR owner){
10843         return CVec_MonitorUpdateIdZ_clone(&owner->b);
10844 }
10845 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointCVec_1MonitorUpdateIdZZ_1get_1b(JNIEnv *env, jclass clz, int64_t owner) {
10846         LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ* owner_conv = (LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ*)untag_ptr(owner);
10847         LDKCVec_MonitorUpdateIdZ ret_var = C2Tuple_OutPointCVec_MonitorUpdateIdZZ_get_b(owner_conv);
10848         int64_tArray ret_arr = NULL;
10849         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
10850         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
10851         for (size_t r = 0; r < ret_var.datalen; r++) {
10852                 LDKMonitorUpdateId ret_conv_17_var = ret_var.data[r];
10853                 int64_t ret_conv_17_ref = 0;
10854                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_17_var);
10855                 ret_conv_17_ref = tag_ptr(ret_conv_17_var.inner, ret_conv_17_var.is_owned);
10856                 ret_arr_ptr[r] = ret_conv_17_ref;
10857         }
10858         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
10859         FREE(ret_var.data);
10860         return ret_arr;
10861 }
10862
10863 static inline LDKCVec_C2Tuple_OutPointCVec_MonitorUpdateIdZZZ CVec_C2Tuple_OutPointCVec_MonitorUpdateIdZZZ_clone(const LDKCVec_C2Tuple_OutPointCVec_MonitorUpdateIdZZZ *orig) {
10864         LDKCVec_C2Tuple_OutPointCVec_MonitorUpdateIdZZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ) * orig->datalen, "LDKCVec_C2Tuple_OutPointCVec_MonitorUpdateIdZZZ clone bytes"), .datalen = orig->datalen };
10865         for (size_t i = 0; i < ret.datalen; i++) {
10866                 ret.data[i] = C2Tuple_OutPointCVec_MonitorUpdateIdZZ_clone(&orig->data[i]);
10867         }
10868         return ret;
10869 }
10870 typedef struct LDKMessageSendEventsProvider_JCalls {
10871         atomic_size_t refcnt;
10872         JavaVM *vm;
10873         jweak o;
10874         jmethodID get_and_clear_pending_msg_events_meth;
10875 } LDKMessageSendEventsProvider_JCalls;
10876 static void LDKMessageSendEventsProvider_JCalls_free(void* this_arg) {
10877         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg;
10878         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
10879                 JNIEnv *env;
10880                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10881                 if (get_jenv_res == JNI_EDETACHED) {
10882                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10883                 } else {
10884                         DO_ASSERT(get_jenv_res == JNI_OK);
10885                 }
10886                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
10887                 if (get_jenv_res == JNI_EDETACHED) {
10888                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10889                 }
10890                 FREE(j_calls);
10891         }
10892 }
10893 LDKCVec_MessageSendEventZ get_and_clear_pending_msg_events_LDKMessageSendEventsProvider_jcall(const void* this_arg) {
10894         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg;
10895         JNIEnv *env;
10896         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10897         if (get_jenv_res == JNI_EDETACHED) {
10898                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10899         } else {
10900                 DO_ASSERT(get_jenv_res == JNI_OK);
10901         }
10902         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10903         CHECK(obj != NULL);
10904         int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_and_clear_pending_msg_events_meth);
10905         if (UNLIKELY((*env)->ExceptionCheck(env))) {
10906                 (*env)->ExceptionDescribe(env);
10907                 (*env)->FatalError(env, "A call to get_and_clear_pending_msg_events in LDKMessageSendEventsProvider from rust threw an exception.");
10908         }
10909         LDKCVec_MessageSendEventZ ret_constr;
10910         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
10911         if (ret_constr.datalen > 0)
10912                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKMessageSendEvent), "LDKCVec_MessageSendEventZ Elements");
10913         else
10914                 ret_constr.data = NULL;
10915         int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
10916         for (size_t s = 0; s < ret_constr.datalen; s++) {
10917                 int64_t ret_conv_18 = ret_vals[s];
10918                 void* ret_conv_18_ptr = untag_ptr(ret_conv_18);
10919                 CHECK_ACCESS(ret_conv_18_ptr);
10920                 LDKMessageSendEvent ret_conv_18_conv = *(LDKMessageSendEvent*)(ret_conv_18_ptr);
10921                 FREE(untag_ptr(ret_conv_18));
10922                 ret_constr.data[s] = ret_conv_18_conv;
10923         }
10924         (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
10925         if (get_jenv_res == JNI_EDETACHED) {
10926                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10927         }
10928         return ret_constr;
10929 }
10930 static void LDKMessageSendEventsProvider_JCalls_cloned(LDKMessageSendEventsProvider* new_obj) {
10931         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) new_obj->this_arg;
10932         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
10933 }
10934 static inline LDKMessageSendEventsProvider LDKMessageSendEventsProvider_init (JNIEnv *env, jclass clz, jobject o) {
10935         jclass c = (*env)->GetObjectClass(env, o);
10936         CHECK(c != NULL);
10937         LDKMessageSendEventsProvider_JCalls *calls = MALLOC(sizeof(LDKMessageSendEventsProvider_JCalls), "LDKMessageSendEventsProvider_JCalls");
10938         atomic_init(&calls->refcnt, 1);
10939         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
10940         calls->o = (*env)->NewWeakGlobalRef(env, o);
10941         calls->get_and_clear_pending_msg_events_meth = (*env)->GetMethodID(env, c, "get_and_clear_pending_msg_events", "()[J");
10942         CHECK(calls->get_and_clear_pending_msg_events_meth != NULL);
10943
10944         LDKMessageSendEventsProvider ret = {
10945                 .this_arg = (void*) calls,
10946                 .get_and_clear_pending_msg_events = get_and_clear_pending_msg_events_LDKMessageSendEventsProvider_jcall,
10947                 .free = LDKMessageSendEventsProvider_JCalls_free,
10948         };
10949         return ret;
10950 }
10951 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKMessageSendEventsProvider_1new(JNIEnv *env, jclass clz, jobject o) {
10952         LDKMessageSendEventsProvider *res_ptr = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
10953         *res_ptr = LDKMessageSendEventsProvider_init(env, clz, o);
10954         return tag_ptr(res_ptr, true);
10955 }
10956 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_MessageSendEventsProvider_1get_1and_1clear_1pending_1msg_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
10957         void* this_arg_ptr = untag_ptr(this_arg);
10958         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
10959         LDKMessageSendEventsProvider* this_arg_conv = (LDKMessageSendEventsProvider*)this_arg_ptr;
10960         LDKCVec_MessageSendEventZ ret_var = (this_arg_conv->get_and_clear_pending_msg_events)(this_arg_conv->this_arg);
10961         int64_tArray ret_arr = NULL;
10962         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
10963         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
10964         for (size_t s = 0; s < ret_var.datalen; s++) {
10965                 LDKMessageSendEvent *ret_conv_18_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
10966                 *ret_conv_18_copy = ret_var.data[s];
10967                 int64_t ret_conv_18_ref = tag_ptr(ret_conv_18_copy, true);
10968                 ret_arr_ptr[s] = ret_conv_18_ref;
10969         }
10970         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
10971         FREE(ret_var.data);
10972         return ret_arr;
10973 }
10974
10975 typedef struct LDKOnionMessageProvider_JCalls {
10976         atomic_size_t refcnt;
10977         JavaVM *vm;
10978         jweak o;
10979         jmethodID next_onion_message_for_peer_meth;
10980 } LDKOnionMessageProvider_JCalls;
10981 static void LDKOnionMessageProvider_JCalls_free(void* this_arg) {
10982         LDKOnionMessageProvider_JCalls *j_calls = (LDKOnionMessageProvider_JCalls*) this_arg;
10983         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
10984                 JNIEnv *env;
10985                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10986                 if (get_jenv_res == JNI_EDETACHED) {
10987                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10988                 } else {
10989                         DO_ASSERT(get_jenv_res == JNI_OK);
10990                 }
10991                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
10992                 if (get_jenv_res == JNI_EDETACHED) {
10993                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10994                 }
10995                 FREE(j_calls);
10996         }
10997 }
10998 LDKOnionMessage next_onion_message_for_peer_LDKOnionMessageProvider_jcall(const void* this_arg, LDKPublicKey peer_node_id) {
10999         LDKOnionMessageProvider_JCalls *j_calls = (LDKOnionMessageProvider_JCalls*) this_arg;
11000         JNIEnv *env;
11001         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11002         if (get_jenv_res == JNI_EDETACHED) {
11003                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11004         } else {
11005                 DO_ASSERT(get_jenv_res == JNI_OK);
11006         }
11007         int8_tArray peer_node_id_arr = (*env)->NewByteArray(env, 33);
11008         (*env)->SetByteArrayRegion(env, peer_node_id_arr, 0, 33, peer_node_id.compressed_form);
11009         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11010         CHECK(obj != NULL);
11011         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->next_onion_message_for_peer_meth, peer_node_id_arr);
11012         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11013                 (*env)->ExceptionDescribe(env);
11014                 (*env)->FatalError(env, "A call to next_onion_message_for_peer in LDKOnionMessageProvider from rust threw an exception.");
11015         }
11016         LDKOnionMessage ret_conv;
11017         ret_conv.inner = untag_ptr(ret);
11018         ret_conv.is_owned = ptr_is_owned(ret);
11019         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv);
11020         if (get_jenv_res == JNI_EDETACHED) {
11021                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11022         }
11023         return ret_conv;
11024 }
11025 static void LDKOnionMessageProvider_JCalls_cloned(LDKOnionMessageProvider* new_obj) {
11026         LDKOnionMessageProvider_JCalls *j_calls = (LDKOnionMessageProvider_JCalls*) new_obj->this_arg;
11027         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
11028 }
11029 static inline LDKOnionMessageProvider LDKOnionMessageProvider_init (JNIEnv *env, jclass clz, jobject o) {
11030         jclass c = (*env)->GetObjectClass(env, o);
11031         CHECK(c != NULL);
11032         LDKOnionMessageProvider_JCalls *calls = MALLOC(sizeof(LDKOnionMessageProvider_JCalls), "LDKOnionMessageProvider_JCalls");
11033         atomic_init(&calls->refcnt, 1);
11034         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
11035         calls->o = (*env)->NewWeakGlobalRef(env, o);
11036         calls->next_onion_message_for_peer_meth = (*env)->GetMethodID(env, c, "next_onion_message_for_peer", "([B)J");
11037         CHECK(calls->next_onion_message_for_peer_meth != NULL);
11038
11039         LDKOnionMessageProvider ret = {
11040                 .this_arg = (void*) calls,
11041                 .next_onion_message_for_peer = next_onion_message_for_peer_LDKOnionMessageProvider_jcall,
11042                 .free = LDKOnionMessageProvider_JCalls_free,
11043         };
11044         return ret;
11045 }
11046 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKOnionMessageProvider_1new(JNIEnv *env, jclass clz, jobject o) {
11047         LDKOnionMessageProvider *res_ptr = MALLOC(sizeof(LDKOnionMessageProvider), "LDKOnionMessageProvider");
11048         *res_ptr = LDKOnionMessageProvider_init(env, clz, o);
11049         return tag_ptr(res_ptr, true);
11050 }
11051 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) {
11052         void* this_arg_ptr = untag_ptr(this_arg);
11053         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
11054         LDKOnionMessageProvider* this_arg_conv = (LDKOnionMessageProvider*)this_arg_ptr;
11055         LDKPublicKey peer_node_id_ref;
11056         CHECK((*env)->GetArrayLength(env, peer_node_id) == 33);
11057         (*env)->GetByteArrayRegion(env, peer_node_id, 0, 33, peer_node_id_ref.compressed_form);
11058         LDKOnionMessage ret_var = (this_arg_conv->next_onion_message_for_peer)(this_arg_conv->this_arg, peer_node_id_ref);
11059         int64_t ret_ref = 0;
11060         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
11061         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
11062         return ret_ref;
11063 }
11064
11065 typedef struct LDKEventHandler_JCalls {
11066         atomic_size_t refcnt;
11067         JavaVM *vm;
11068         jweak o;
11069         jmethodID handle_event_meth;
11070 } LDKEventHandler_JCalls;
11071 static void LDKEventHandler_JCalls_free(void* this_arg) {
11072         LDKEventHandler_JCalls *j_calls = (LDKEventHandler_JCalls*) this_arg;
11073         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
11074                 JNIEnv *env;
11075                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11076                 if (get_jenv_res == JNI_EDETACHED) {
11077                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11078                 } else {
11079                         DO_ASSERT(get_jenv_res == JNI_OK);
11080                 }
11081                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
11082                 if (get_jenv_res == JNI_EDETACHED) {
11083                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11084                 }
11085                 FREE(j_calls);
11086         }
11087 }
11088 void handle_event_LDKEventHandler_jcall(const void* this_arg, LDKEvent event) {
11089         LDKEventHandler_JCalls *j_calls = (LDKEventHandler_JCalls*) this_arg;
11090         JNIEnv *env;
11091         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11092         if (get_jenv_res == JNI_EDETACHED) {
11093                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11094         } else {
11095                 DO_ASSERT(get_jenv_res == JNI_OK);
11096         }
11097         LDKEvent *event_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
11098         *event_copy = event;
11099         int64_t event_ref = tag_ptr(event_copy, true);
11100         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11101         CHECK(obj != NULL);
11102         (*env)->CallVoidMethod(env, obj, j_calls->handle_event_meth, event_ref);
11103         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11104                 (*env)->ExceptionDescribe(env);
11105                 (*env)->FatalError(env, "A call to handle_event in LDKEventHandler from rust threw an exception.");
11106         }
11107         if (get_jenv_res == JNI_EDETACHED) {
11108                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11109         }
11110 }
11111 static void LDKEventHandler_JCalls_cloned(LDKEventHandler* new_obj) {
11112         LDKEventHandler_JCalls *j_calls = (LDKEventHandler_JCalls*) new_obj->this_arg;
11113         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
11114 }
11115 static inline LDKEventHandler LDKEventHandler_init (JNIEnv *env, jclass clz, jobject o) {
11116         jclass c = (*env)->GetObjectClass(env, o);
11117         CHECK(c != NULL);
11118         LDKEventHandler_JCalls *calls = MALLOC(sizeof(LDKEventHandler_JCalls), "LDKEventHandler_JCalls");
11119         atomic_init(&calls->refcnt, 1);
11120         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
11121         calls->o = (*env)->NewWeakGlobalRef(env, o);
11122         calls->handle_event_meth = (*env)->GetMethodID(env, c, "handle_event", "(J)V");
11123         CHECK(calls->handle_event_meth != NULL);
11124
11125         LDKEventHandler ret = {
11126                 .this_arg = (void*) calls,
11127                 .handle_event = handle_event_LDKEventHandler_jcall,
11128                 .free = LDKEventHandler_JCalls_free,
11129         };
11130         return ret;
11131 }
11132 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKEventHandler_1new(JNIEnv *env, jclass clz, jobject o) {
11133         LDKEventHandler *res_ptr = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
11134         *res_ptr = LDKEventHandler_init(env, clz, o);
11135         return tag_ptr(res_ptr, true);
11136 }
11137 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_EventHandler_1handle_1event(JNIEnv *env, jclass clz, int64_t this_arg, int64_t event) {
11138         void* this_arg_ptr = untag_ptr(this_arg);
11139         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
11140         LDKEventHandler* this_arg_conv = (LDKEventHandler*)this_arg_ptr;
11141         void* event_ptr = untag_ptr(event);
11142         CHECK_ACCESS(event_ptr);
11143         LDKEvent event_conv = *(LDKEvent*)(event_ptr);
11144         event_conv = Event_clone((LDKEvent*)untag_ptr(event));
11145         (this_arg_conv->handle_event)(this_arg_conv->this_arg, event_conv);
11146 }
11147
11148 typedef struct LDKEventsProvider_JCalls {
11149         atomic_size_t refcnt;
11150         JavaVM *vm;
11151         jweak o;
11152         jmethodID process_pending_events_meth;
11153 } LDKEventsProvider_JCalls;
11154 static void LDKEventsProvider_JCalls_free(void* this_arg) {
11155         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) this_arg;
11156         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
11157                 JNIEnv *env;
11158                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11159                 if (get_jenv_res == JNI_EDETACHED) {
11160                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11161                 } else {
11162                         DO_ASSERT(get_jenv_res == JNI_OK);
11163                 }
11164                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
11165                 if (get_jenv_res == JNI_EDETACHED) {
11166                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11167                 }
11168                 FREE(j_calls);
11169         }
11170 }
11171 void process_pending_events_LDKEventsProvider_jcall(const void* this_arg, LDKEventHandler handler) {
11172         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) this_arg;
11173         JNIEnv *env;
11174         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11175         if (get_jenv_res == JNI_EDETACHED) {
11176                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11177         } else {
11178                 DO_ASSERT(get_jenv_res == JNI_OK);
11179         }
11180         LDKEventHandler* handler_ret = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
11181         *handler_ret = handler;
11182         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11183         CHECK(obj != NULL);
11184         (*env)->CallVoidMethod(env, obj, j_calls->process_pending_events_meth, tag_ptr(handler_ret, true));
11185         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11186                 (*env)->ExceptionDescribe(env);
11187                 (*env)->FatalError(env, "A call to process_pending_events in LDKEventsProvider from rust threw an exception.");
11188         }
11189         if (get_jenv_res == JNI_EDETACHED) {
11190                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11191         }
11192 }
11193 static void LDKEventsProvider_JCalls_cloned(LDKEventsProvider* new_obj) {
11194         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) new_obj->this_arg;
11195         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
11196 }
11197 static inline LDKEventsProvider LDKEventsProvider_init (JNIEnv *env, jclass clz, jobject o) {
11198         jclass c = (*env)->GetObjectClass(env, o);
11199         CHECK(c != NULL);
11200         LDKEventsProvider_JCalls *calls = MALLOC(sizeof(LDKEventsProvider_JCalls), "LDKEventsProvider_JCalls");
11201         atomic_init(&calls->refcnt, 1);
11202         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
11203         calls->o = (*env)->NewWeakGlobalRef(env, o);
11204         calls->process_pending_events_meth = (*env)->GetMethodID(env, c, "process_pending_events", "(J)V");
11205         CHECK(calls->process_pending_events_meth != NULL);
11206
11207         LDKEventsProvider ret = {
11208                 .this_arg = (void*) calls,
11209                 .process_pending_events = process_pending_events_LDKEventsProvider_jcall,
11210                 .free = LDKEventsProvider_JCalls_free,
11211         };
11212         return ret;
11213 }
11214 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKEventsProvider_1new(JNIEnv *env, jclass clz, jobject o) {
11215         LDKEventsProvider *res_ptr = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
11216         *res_ptr = LDKEventsProvider_init(env, clz, o);
11217         return tag_ptr(res_ptr, true);
11218 }
11219 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_EventsProvider_1process_1pending_1events(JNIEnv *env, jclass clz, int64_t this_arg, int64_t handler) {
11220         void* this_arg_ptr = untag_ptr(this_arg);
11221         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
11222         LDKEventsProvider* this_arg_conv = (LDKEventsProvider*)this_arg_ptr;
11223         void* handler_ptr = untag_ptr(handler);
11224         CHECK_ACCESS(handler_ptr);
11225         LDKEventHandler handler_conv = *(LDKEventHandler*)(handler_ptr);
11226         if (handler_conv.free == LDKEventHandler_JCalls_free) {
11227                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
11228                 LDKEventHandler_JCalls_cloned(&handler_conv);
11229         }
11230         (this_arg_conv->process_pending_events)(this_arg_conv->this_arg, handler_conv);
11231 }
11232
11233 typedef struct LDKPersister_JCalls {
11234         atomic_size_t refcnt;
11235         JavaVM *vm;
11236         jweak o;
11237         jmethodID persist_manager_meth;
11238         jmethodID persist_graph_meth;
11239         jmethodID persist_scorer_meth;
11240 } LDKPersister_JCalls;
11241 static void LDKPersister_JCalls_free(void* this_arg) {
11242         LDKPersister_JCalls *j_calls = (LDKPersister_JCalls*) this_arg;
11243         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
11244                 JNIEnv *env;
11245                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11246                 if (get_jenv_res == JNI_EDETACHED) {
11247                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11248                 } else {
11249                         DO_ASSERT(get_jenv_res == JNI_OK);
11250                 }
11251                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
11252                 if (get_jenv_res == JNI_EDETACHED) {
11253                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11254                 }
11255                 FREE(j_calls);
11256         }
11257 }
11258 LDKCResult_NoneErrorZ persist_manager_LDKPersister_jcall(const void* this_arg, const LDKChannelManager * channel_manager) {
11259         LDKPersister_JCalls *j_calls = (LDKPersister_JCalls*) this_arg;
11260         JNIEnv *env;
11261         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11262         if (get_jenv_res == JNI_EDETACHED) {
11263                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11264         } else {
11265                 DO_ASSERT(get_jenv_res == JNI_OK);
11266         }
11267         LDKChannelManager channel_manager_var = *channel_manager;
11268         int64_t channel_manager_ref = 0;
11269         // WARNING: we may need a move here but no clone is available for LDKChannelManager
11270         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_manager_var);
11271         channel_manager_ref = tag_ptr(channel_manager_var.inner, channel_manager_var.is_owned);
11272         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11273         CHECK(obj != NULL);
11274         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->persist_manager_meth, channel_manager_ref);
11275         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11276                 (*env)->ExceptionDescribe(env);
11277                 (*env)->FatalError(env, "A call to persist_manager in LDKPersister from rust threw an exception.");
11278         }
11279         void* ret_ptr = untag_ptr(ret);
11280         CHECK_ACCESS(ret_ptr);
11281         LDKCResult_NoneErrorZ ret_conv = *(LDKCResult_NoneErrorZ*)(ret_ptr);
11282         FREE(untag_ptr(ret));
11283         if (get_jenv_res == JNI_EDETACHED) {
11284                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11285         }
11286         return ret_conv;
11287 }
11288 LDKCResult_NoneErrorZ persist_graph_LDKPersister_jcall(const void* this_arg, const LDKNetworkGraph * network_graph) {
11289         LDKPersister_JCalls *j_calls = (LDKPersister_JCalls*) this_arg;
11290         JNIEnv *env;
11291         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11292         if (get_jenv_res == JNI_EDETACHED) {
11293                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11294         } else {
11295                 DO_ASSERT(get_jenv_res == JNI_OK);
11296         }
11297         LDKNetworkGraph network_graph_var = *network_graph;
11298         int64_t network_graph_ref = 0;
11299         // WARNING: we may need a move here but no clone is available for LDKNetworkGraph
11300         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_var);
11301         network_graph_ref = tag_ptr(network_graph_var.inner, network_graph_var.is_owned);
11302         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11303         CHECK(obj != NULL);
11304         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->persist_graph_meth, network_graph_ref);
11305         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11306                 (*env)->ExceptionDescribe(env);
11307                 (*env)->FatalError(env, "A call to persist_graph in LDKPersister from rust threw an exception.");
11308         }
11309         void* ret_ptr = untag_ptr(ret);
11310         CHECK_ACCESS(ret_ptr);
11311         LDKCResult_NoneErrorZ ret_conv = *(LDKCResult_NoneErrorZ*)(ret_ptr);
11312         FREE(untag_ptr(ret));
11313         if (get_jenv_res == JNI_EDETACHED) {
11314                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11315         }
11316         return ret_conv;
11317 }
11318 LDKCResult_NoneErrorZ persist_scorer_LDKPersister_jcall(const void* this_arg, const LDKWriteableScore * scorer) {
11319         LDKPersister_JCalls *j_calls = (LDKPersister_JCalls*) this_arg;
11320         JNIEnv *env;
11321         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11322         if (get_jenv_res == JNI_EDETACHED) {
11323                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11324         } else {
11325                 DO_ASSERT(get_jenv_res == JNI_OK);
11326         }
11327         // WARNING: This object doesn't live past this scope, needs clone!
11328         int64_t ret_scorer = tag_ptr(scorer, false);
11329         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11330         CHECK(obj != NULL);
11331         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->persist_scorer_meth, ret_scorer);
11332         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11333                 (*env)->ExceptionDescribe(env);
11334                 (*env)->FatalError(env, "A call to persist_scorer in LDKPersister from rust threw an exception.");
11335         }
11336         void* ret_ptr = untag_ptr(ret);
11337         CHECK_ACCESS(ret_ptr);
11338         LDKCResult_NoneErrorZ ret_conv = *(LDKCResult_NoneErrorZ*)(ret_ptr);
11339         FREE(untag_ptr(ret));
11340         if (get_jenv_res == JNI_EDETACHED) {
11341                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11342         }
11343         return ret_conv;
11344 }
11345 static void LDKPersister_JCalls_cloned(LDKPersister* new_obj) {
11346         LDKPersister_JCalls *j_calls = (LDKPersister_JCalls*) new_obj->this_arg;
11347         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
11348 }
11349 static inline LDKPersister LDKPersister_init (JNIEnv *env, jclass clz, jobject o) {
11350         jclass c = (*env)->GetObjectClass(env, o);
11351         CHECK(c != NULL);
11352         LDKPersister_JCalls *calls = MALLOC(sizeof(LDKPersister_JCalls), "LDKPersister_JCalls");
11353         atomic_init(&calls->refcnt, 1);
11354         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
11355         calls->o = (*env)->NewWeakGlobalRef(env, o);
11356         calls->persist_manager_meth = (*env)->GetMethodID(env, c, "persist_manager", "(J)J");
11357         CHECK(calls->persist_manager_meth != NULL);
11358         calls->persist_graph_meth = (*env)->GetMethodID(env, c, "persist_graph", "(J)J");
11359         CHECK(calls->persist_graph_meth != NULL);
11360         calls->persist_scorer_meth = (*env)->GetMethodID(env, c, "persist_scorer", "(J)J");
11361         CHECK(calls->persist_scorer_meth != NULL);
11362
11363         LDKPersister ret = {
11364                 .this_arg = (void*) calls,
11365                 .persist_manager = persist_manager_LDKPersister_jcall,
11366                 .persist_graph = persist_graph_LDKPersister_jcall,
11367                 .persist_scorer = persist_scorer_LDKPersister_jcall,
11368                 .free = LDKPersister_JCalls_free,
11369         };
11370         return ret;
11371 }
11372 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKPersister_1new(JNIEnv *env, jclass clz, jobject o) {
11373         LDKPersister *res_ptr = MALLOC(sizeof(LDKPersister), "LDKPersister");
11374         *res_ptr = LDKPersister_init(env, clz, o);
11375         return tag_ptr(res_ptr, true);
11376 }
11377 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Persister_1persist_1manager(JNIEnv *env, jclass clz, int64_t this_arg, int64_t channel_manager) {
11378         void* this_arg_ptr = untag_ptr(this_arg);
11379         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
11380         LDKPersister* this_arg_conv = (LDKPersister*)this_arg_ptr;
11381         LDKChannelManager channel_manager_conv;
11382         channel_manager_conv.inner = untag_ptr(channel_manager);
11383         channel_manager_conv.is_owned = ptr_is_owned(channel_manager);
11384         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_manager_conv);
11385         channel_manager_conv.is_owned = false;
11386         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
11387         *ret_conv = (this_arg_conv->persist_manager)(this_arg_conv->this_arg, &channel_manager_conv);
11388         return tag_ptr(ret_conv, true);
11389 }
11390
11391 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Persister_1persist_1graph(JNIEnv *env, jclass clz, int64_t this_arg, int64_t network_graph) {
11392         void* this_arg_ptr = untag_ptr(this_arg);
11393         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
11394         LDKPersister* this_arg_conv = (LDKPersister*)this_arg_ptr;
11395         LDKNetworkGraph network_graph_conv;
11396         network_graph_conv.inner = untag_ptr(network_graph);
11397         network_graph_conv.is_owned = ptr_is_owned(network_graph);
11398         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
11399         network_graph_conv.is_owned = false;
11400         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
11401         *ret_conv = (this_arg_conv->persist_graph)(this_arg_conv->this_arg, &network_graph_conv);
11402         return tag_ptr(ret_conv, true);
11403 }
11404
11405 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Persister_1persist_1scorer(JNIEnv *env, jclass clz, int64_t this_arg, int64_t scorer) {
11406         void* this_arg_ptr = untag_ptr(this_arg);
11407         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
11408         LDKPersister* this_arg_conv = (LDKPersister*)this_arg_ptr;
11409         void* scorer_ptr = untag_ptr(scorer);
11410         if (ptr_is_owned(scorer)) { CHECK_ACCESS(scorer_ptr); }
11411         LDKWriteableScore* scorer_conv = (LDKWriteableScore*)scorer_ptr;
11412         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
11413         *ret_conv = (this_arg_conv->persist_scorer)(this_arg_conv->this_arg, scorer_conv);
11414         return tag_ptr(ret_conv, true);
11415 }
11416
11417 typedef struct LDKFutureCallback_JCalls {
11418         atomic_size_t refcnt;
11419         JavaVM *vm;
11420         jweak o;
11421         jmethodID call_meth;
11422 } LDKFutureCallback_JCalls;
11423 static void LDKFutureCallback_JCalls_free(void* this_arg) {
11424         LDKFutureCallback_JCalls *j_calls = (LDKFutureCallback_JCalls*) this_arg;
11425         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
11426                 JNIEnv *env;
11427                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11428                 if (get_jenv_res == JNI_EDETACHED) {
11429                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11430                 } else {
11431                         DO_ASSERT(get_jenv_res == JNI_OK);
11432                 }
11433                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
11434                 if (get_jenv_res == JNI_EDETACHED) {
11435                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11436                 }
11437                 FREE(j_calls);
11438         }
11439 }
11440 void call_LDKFutureCallback_jcall(const void* this_arg) {
11441         LDKFutureCallback_JCalls *j_calls = (LDKFutureCallback_JCalls*) this_arg;
11442         JNIEnv *env;
11443         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11444         if (get_jenv_res == JNI_EDETACHED) {
11445                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11446         } else {
11447                 DO_ASSERT(get_jenv_res == JNI_OK);
11448         }
11449         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11450         CHECK(obj != NULL);
11451         (*env)->CallVoidMethod(env, obj, j_calls->call_meth);
11452         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11453                 (*env)->ExceptionDescribe(env);
11454                 (*env)->FatalError(env, "A call to call in LDKFutureCallback from rust threw an exception.");
11455         }
11456         if (get_jenv_res == JNI_EDETACHED) {
11457                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11458         }
11459 }
11460 static void LDKFutureCallback_JCalls_cloned(LDKFutureCallback* new_obj) {
11461         LDKFutureCallback_JCalls *j_calls = (LDKFutureCallback_JCalls*) new_obj->this_arg;
11462         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
11463 }
11464 static inline LDKFutureCallback LDKFutureCallback_init (JNIEnv *env, jclass clz, jobject o) {
11465         jclass c = (*env)->GetObjectClass(env, o);
11466         CHECK(c != NULL);
11467         LDKFutureCallback_JCalls *calls = MALLOC(sizeof(LDKFutureCallback_JCalls), "LDKFutureCallback_JCalls");
11468         atomic_init(&calls->refcnt, 1);
11469         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
11470         calls->o = (*env)->NewWeakGlobalRef(env, o);
11471         calls->call_meth = (*env)->GetMethodID(env, c, "call", "()V");
11472         CHECK(calls->call_meth != NULL);
11473
11474         LDKFutureCallback ret = {
11475                 .this_arg = (void*) calls,
11476                 .call = call_LDKFutureCallback_jcall,
11477                 .free = LDKFutureCallback_JCalls_free,
11478         };
11479         return ret;
11480 }
11481 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKFutureCallback_1new(JNIEnv *env, jclass clz, jobject o) {
11482         LDKFutureCallback *res_ptr = MALLOC(sizeof(LDKFutureCallback), "LDKFutureCallback");
11483         *res_ptr = LDKFutureCallback_init(env, clz, o);
11484         return tag_ptr(res_ptr, true);
11485 }
11486 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FutureCallback_1call(JNIEnv *env, jclass clz, int64_t this_arg) {
11487         void* this_arg_ptr = untag_ptr(this_arg);
11488         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
11489         LDKFutureCallback* this_arg_conv = (LDKFutureCallback*)this_arg_ptr;
11490         (this_arg_conv->call)(this_arg_conv->this_arg);
11491 }
11492
11493 typedef struct LDKListen_JCalls {
11494         atomic_size_t refcnt;
11495         JavaVM *vm;
11496         jweak o;
11497         jmethodID filtered_block_connected_meth;
11498         jmethodID block_connected_meth;
11499         jmethodID block_disconnected_meth;
11500 } LDKListen_JCalls;
11501 static void LDKListen_JCalls_free(void* this_arg) {
11502         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
11503         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
11504                 JNIEnv *env;
11505                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11506                 if (get_jenv_res == JNI_EDETACHED) {
11507                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11508                 } else {
11509                         DO_ASSERT(get_jenv_res == JNI_OK);
11510                 }
11511                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
11512                 if (get_jenv_res == JNI_EDETACHED) {
11513                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11514                 }
11515                 FREE(j_calls);
11516         }
11517 }
11518 void filtered_block_connected_LDKListen_jcall(const void* this_arg, const uint8_t (* header)[80], LDKCVec_C2Tuple_usizeTransactionZZ txdata, uint32_t height) {
11519         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
11520         JNIEnv *env;
11521         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11522         if (get_jenv_res == JNI_EDETACHED) {
11523                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11524         } else {
11525                 DO_ASSERT(get_jenv_res == JNI_OK);
11526         }
11527         int8_tArray header_arr = (*env)->NewByteArray(env, 80);
11528         (*env)->SetByteArrayRegion(env, header_arr, 0, 80, *header);
11529         LDKCVec_C2Tuple_usizeTransactionZZ txdata_var = txdata;
11530         int64_tArray txdata_arr = NULL;
11531         txdata_arr = (*env)->NewLongArray(env, txdata_var.datalen);
11532         int64_t *txdata_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, txdata_arr, NULL);
11533         for (size_t c = 0; c < txdata_var.datalen; c++) {
11534                 LDKC2Tuple_usizeTransactionZ* txdata_conv_28_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
11535                 *txdata_conv_28_conv = txdata_var.data[c];
11536                 txdata_arr_ptr[c] = tag_ptr(txdata_conv_28_conv, true);
11537         }
11538         (*env)->ReleasePrimitiveArrayCritical(env, txdata_arr, txdata_arr_ptr, 0);
11539         FREE(txdata_var.data);
11540         int32_t height_conv = height;
11541         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11542         CHECK(obj != NULL);
11543         (*env)->CallVoidMethod(env, obj, j_calls->filtered_block_connected_meth, header_arr, txdata_arr, height_conv);
11544         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11545                 (*env)->ExceptionDescribe(env);
11546                 (*env)->FatalError(env, "A call to filtered_block_connected in LDKListen from rust threw an exception.");
11547         }
11548         if (get_jenv_res == JNI_EDETACHED) {
11549                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11550         }
11551 }
11552 void block_connected_LDKListen_jcall(const void* this_arg, LDKu8slice block, uint32_t height) {
11553         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
11554         JNIEnv *env;
11555         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11556         if (get_jenv_res == JNI_EDETACHED) {
11557                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11558         } else {
11559                 DO_ASSERT(get_jenv_res == JNI_OK);
11560         }
11561         LDKu8slice block_var = block;
11562         int8_tArray block_arr = (*env)->NewByteArray(env, block_var.datalen);
11563         (*env)->SetByteArrayRegion(env, block_arr, 0, block_var.datalen, block_var.data);
11564         int32_t height_conv = height;
11565         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11566         CHECK(obj != NULL);
11567         (*env)->CallVoidMethod(env, obj, j_calls->block_connected_meth, block_arr, height_conv);
11568         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11569                 (*env)->ExceptionDescribe(env);
11570                 (*env)->FatalError(env, "A call to block_connected in LDKListen from rust threw an exception.");
11571         }
11572         if (get_jenv_res == JNI_EDETACHED) {
11573                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11574         }
11575 }
11576 void block_disconnected_LDKListen_jcall(const void* this_arg, const uint8_t (* header)[80], uint32_t height) {
11577         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
11578         JNIEnv *env;
11579         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11580         if (get_jenv_res == JNI_EDETACHED) {
11581                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11582         } else {
11583                 DO_ASSERT(get_jenv_res == JNI_OK);
11584         }
11585         int8_tArray header_arr = (*env)->NewByteArray(env, 80);
11586         (*env)->SetByteArrayRegion(env, header_arr, 0, 80, *header);
11587         int32_t height_conv = height;
11588         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11589         CHECK(obj != NULL);
11590         (*env)->CallVoidMethod(env, obj, j_calls->block_disconnected_meth, header_arr, height_conv);
11591         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11592                 (*env)->ExceptionDescribe(env);
11593                 (*env)->FatalError(env, "A call to block_disconnected in LDKListen from rust threw an exception.");
11594         }
11595         if (get_jenv_res == JNI_EDETACHED) {
11596                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11597         }
11598 }
11599 static void LDKListen_JCalls_cloned(LDKListen* new_obj) {
11600         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) new_obj->this_arg;
11601         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
11602 }
11603 static inline LDKListen LDKListen_init (JNIEnv *env, jclass clz, jobject o) {
11604         jclass c = (*env)->GetObjectClass(env, o);
11605         CHECK(c != NULL);
11606         LDKListen_JCalls *calls = MALLOC(sizeof(LDKListen_JCalls), "LDKListen_JCalls");
11607         atomic_init(&calls->refcnt, 1);
11608         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
11609         calls->o = (*env)->NewWeakGlobalRef(env, o);
11610         calls->filtered_block_connected_meth = (*env)->GetMethodID(env, c, "filtered_block_connected", "([B[JI)V");
11611         CHECK(calls->filtered_block_connected_meth != NULL);
11612         calls->block_connected_meth = (*env)->GetMethodID(env, c, "block_connected", "([BI)V");
11613         CHECK(calls->block_connected_meth != NULL);
11614         calls->block_disconnected_meth = (*env)->GetMethodID(env, c, "block_disconnected", "([BI)V");
11615         CHECK(calls->block_disconnected_meth != NULL);
11616
11617         LDKListen ret = {
11618                 .this_arg = (void*) calls,
11619                 .filtered_block_connected = filtered_block_connected_LDKListen_jcall,
11620                 .block_connected = block_connected_LDKListen_jcall,
11621                 .block_disconnected = block_disconnected_LDKListen_jcall,
11622                 .free = LDKListen_JCalls_free,
11623         };
11624         return ret;
11625 }
11626 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKListen_1new(JNIEnv *env, jclass clz, jobject o) {
11627         LDKListen *res_ptr = MALLOC(sizeof(LDKListen), "LDKListen");
11628         *res_ptr = LDKListen_init(env, clz, o);
11629         return tag_ptr(res_ptr, true);
11630 }
11631 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) {
11632         void* this_arg_ptr = untag_ptr(this_arg);
11633         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
11634         LDKListen* this_arg_conv = (LDKListen*)this_arg_ptr;
11635         unsigned char header_arr[80];
11636         CHECK((*env)->GetArrayLength(env, header) == 80);
11637         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
11638         unsigned char (*header_ref)[80] = &header_arr;
11639         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
11640         txdata_constr.datalen = (*env)->GetArrayLength(env, txdata);
11641         if (txdata_constr.datalen > 0)
11642                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
11643         else
11644                 txdata_constr.data = NULL;
11645         int64_t* txdata_vals = (*env)->GetLongArrayElements (env, txdata, NULL);
11646         for (size_t c = 0; c < txdata_constr.datalen; c++) {
11647                 int64_t txdata_conv_28 = txdata_vals[c];
11648                 void* txdata_conv_28_ptr = untag_ptr(txdata_conv_28);
11649                 CHECK_ACCESS(txdata_conv_28_ptr);
11650                 LDKC2Tuple_usizeTransactionZ txdata_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(txdata_conv_28_ptr);
11651                 txdata_conv_28_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)untag_ptr(txdata_conv_28));
11652                 txdata_constr.data[c] = txdata_conv_28_conv;
11653         }
11654         (*env)->ReleaseLongArrayElements(env, txdata, txdata_vals, 0);
11655         (this_arg_conv->filtered_block_connected)(this_arg_conv->this_arg, header_ref, txdata_constr, height);
11656 }
11657
11658 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) {
11659         void* this_arg_ptr = untag_ptr(this_arg);
11660         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
11661         LDKListen* this_arg_conv = (LDKListen*)this_arg_ptr;
11662         LDKu8slice block_ref;
11663         block_ref.datalen = (*env)->GetArrayLength(env, block);
11664         block_ref.data = (*env)->GetByteArrayElements (env, block, NULL);
11665         (this_arg_conv->block_connected)(this_arg_conv->this_arg, block_ref, height);
11666         (*env)->ReleaseByteArrayElements(env, block, (int8_t*)block_ref.data, 0);
11667 }
11668
11669 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) {
11670         void* this_arg_ptr = untag_ptr(this_arg);
11671         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
11672         LDKListen* this_arg_conv = (LDKListen*)this_arg_ptr;
11673         unsigned char header_arr[80];
11674         CHECK((*env)->GetArrayLength(env, header) == 80);
11675         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
11676         unsigned char (*header_ref)[80] = &header_arr;
11677         (this_arg_conv->block_disconnected)(this_arg_conv->this_arg, header_ref, height);
11678 }
11679
11680 typedef struct LDKConfirm_JCalls {
11681         atomic_size_t refcnt;
11682         JavaVM *vm;
11683         jweak o;
11684         jmethodID transactions_confirmed_meth;
11685         jmethodID transaction_unconfirmed_meth;
11686         jmethodID best_block_updated_meth;
11687         jmethodID get_relevant_txids_meth;
11688 } LDKConfirm_JCalls;
11689 static void LDKConfirm_JCalls_free(void* this_arg) {
11690         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
11691         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
11692                 JNIEnv *env;
11693                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11694                 if (get_jenv_res == JNI_EDETACHED) {
11695                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11696                 } else {
11697                         DO_ASSERT(get_jenv_res == JNI_OK);
11698                 }
11699                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
11700                 if (get_jenv_res == JNI_EDETACHED) {
11701                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11702                 }
11703                 FREE(j_calls);
11704         }
11705 }
11706 void transactions_confirmed_LDKConfirm_jcall(const void* this_arg, const uint8_t (* header)[80], LDKCVec_C2Tuple_usizeTransactionZZ txdata, uint32_t height) {
11707         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
11708         JNIEnv *env;
11709         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11710         if (get_jenv_res == JNI_EDETACHED) {
11711                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11712         } else {
11713                 DO_ASSERT(get_jenv_res == JNI_OK);
11714         }
11715         int8_tArray header_arr = (*env)->NewByteArray(env, 80);
11716         (*env)->SetByteArrayRegion(env, header_arr, 0, 80, *header);
11717         LDKCVec_C2Tuple_usizeTransactionZZ txdata_var = txdata;
11718         int64_tArray txdata_arr = NULL;
11719         txdata_arr = (*env)->NewLongArray(env, txdata_var.datalen);
11720         int64_t *txdata_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, txdata_arr, NULL);
11721         for (size_t c = 0; c < txdata_var.datalen; c++) {
11722                 LDKC2Tuple_usizeTransactionZ* txdata_conv_28_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
11723                 *txdata_conv_28_conv = txdata_var.data[c];
11724                 txdata_arr_ptr[c] = tag_ptr(txdata_conv_28_conv, true);
11725         }
11726         (*env)->ReleasePrimitiveArrayCritical(env, txdata_arr, txdata_arr_ptr, 0);
11727         FREE(txdata_var.data);
11728         int32_t height_conv = height;
11729         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11730         CHECK(obj != NULL);
11731         (*env)->CallVoidMethod(env, obj, j_calls->transactions_confirmed_meth, header_arr, txdata_arr, height_conv);
11732         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11733                 (*env)->ExceptionDescribe(env);
11734                 (*env)->FatalError(env, "A call to transactions_confirmed in LDKConfirm from rust threw an exception.");
11735         }
11736         if (get_jenv_res == JNI_EDETACHED) {
11737                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11738         }
11739 }
11740 void transaction_unconfirmed_LDKConfirm_jcall(const void* this_arg, const uint8_t (* txid)[32]) {
11741         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
11742         JNIEnv *env;
11743         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11744         if (get_jenv_res == JNI_EDETACHED) {
11745                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11746         } else {
11747                 DO_ASSERT(get_jenv_res == JNI_OK);
11748         }
11749         int8_tArray txid_arr = (*env)->NewByteArray(env, 32);
11750         (*env)->SetByteArrayRegion(env, txid_arr, 0, 32, *txid);
11751         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11752         CHECK(obj != NULL);
11753         (*env)->CallVoidMethod(env, obj, j_calls->transaction_unconfirmed_meth, txid_arr);
11754         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11755                 (*env)->ExceptionDescribe(env);
11756                 (*env)->FatalError(env, "A call to transaction_unconfirmed in LDKConfirm from rust threw an exception.");
11757         }
11758         if (get_jenv_res == JNI_EDETACHED) {
11759                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11760         }
11761 }
11762 void best_block_updated_LDKConfirm_jcall(const void* this_arg, const uint8_t (* header)[80], uint32_t height) {
11763         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
11764         JNIEnv *env;
11765         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11766         if (get_jenv_res == JNI_EDETACHED) {
11767                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11768         } else {
11769                 DO_ASSERT(get_jenv_res == JNI_OK);
11770         }
11771         int8_tArray header_arr = (*env)->NewByteArray(env, 80);
11772         (*env)->SetByteArrayRegion(env, header_arr, 0, 80, *header);
11773         int32_t height_conv = height;
11774         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11775         CHECK(obj != NULL);
11776         (*env)->CallVoidMethod(env, obj, j_calls->best_block_updated_meth, header_arr, height_conv);
11777         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11778                 (*env)->ExceptionDescribe(env);
11779                 (*env)->FatalError(env, "A call to best_block_updated in LDKConfirm from rust threw an exception.");
11780         }
11781         if (get_jenv_res == JNI_EDETACHED) {
11782                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11783         }
11784 }
11785 LDKCVec_C2Tuple_TxidBlockHashZZ get_relevant_txids_LDKConfirm_jcall(const void* this_arg) {
11786         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
11787         JNIEnv *env;
11788         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11789         if (get_jenv_res == JNI_EDETACHED) {
11790                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11791         } else {
11792                 DO_ASSERT(get_jenv_res == JNI_OK);
11793         }
11794         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11795         CHECK(obj != NULL);
11796         int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_relevant_txids_meth);
11797         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11798                 (*env)->ExceptionDescribe(env);
11799                 (*env)->FatalError(env, "A call to get_relevant_txids in LDKConfirm from rust threw an exception.");
11800         }
11801         LDKCVec_C2Tuple_TxidBlockHashZZ ret_constr;
11802         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
11803         if (ret_constr.datalen > 0)
11804                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKC2Tuple_TxidBlockHashZ), "LDKCVec_C2Tuple_TxidBlockHashZZ Elements");
11805         else
11806                 ret_constr.data = NULL;
11807         int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
11808         for (size_t z = 0; z < ret_constr.datalen; z++) {
11809                 int64_t ret_conv_25 = ret_vals[z];
11810                 void* ret_conv_25_ptr = untag_ptr(ret_conv_25);
11811                 CHECK_ACCESS(ret_conv_25_ptr);
11812                 LDKC2Tuple_TxidBlockHashZ ret_conv_25_conv = *(LDKC2Tuple_TxidBlockHashZ*)(ret_conv_25_ptr);
11813                 FREE(untag_ptr(ret_conv_25));
11814                 ret_constr.data[z] = ret_conv_25_conv;
11815         }
11816         (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
11817         if (get_jenv_res == JNI_EDETACHED) {
11818                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11819         }
11820         return ret_constr;
11821 }
11822 static void LDKConfirm_JCalls_cloned(LDKConfirm* new_obj) {
11823         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) new_obj->this_arg;
11824         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
11825 }
11826 static inline LDKConfirm LDKConfirm_init (JNIEnv *env, jclass clz, jobject o) {
11827         jclass c = (*env)->GetObjectClass(env, o);
11828         CHECK(c != NULL);
11829         LDKConfirm_JCalls *calls = MALLOC(sizeof(LDKConfirm_JCalls), "LDKConfirm_JCalls");
11830         atomic_init(&calls->refcnt, 1);
11831         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
11832         calls->o = (*env)->NewWeakGlobalRef(env, o);
11833         calls->transactions_confirmed_meth = (*env)->GetMethodID(env, c, "transactions_confirmed", "([B[JI)V");
11834         CHECK(calls->transactions_confirmed_meth != NULL);
11835         calls->transaction_unconfirmed_meth = (*env)->GetMethodID(env, c, "transaction_unconfirmed", "([B)V");
11836         CHECK(calls->transaction_unconfirmed_meth != NULL);
11837         calls->best_block_updated_meth = (*env)->GetMethodID(env, c, "best_block_updated", "([BI)V");
11838         CHECK(calls->best_block_updated_meth != NULL);
11839         calls->get_relevant_txids_meth = (*env)->GetMethodID(env, c, "get_relevant_txids", "()[J");
11840         CHECK(calls->get_relevant_txids_meth != NULL);
11841
11842         LDKConfirm ret = {
11843                 .this_arg = (void*) calls,
11844                 .transactions_confirmed = transactions_confirmed_LDKConfirm_jcall,
11845                 .transaction_unconfirmed = transaction_unconfirmed_LDKConfirm_jcall,
11846                 .best_block_updated = best_block_updated_LDKConfirm_jcall,
11847                 .get_relevant_txids = get_relevant_txids_LDKConfirm_jcall,
11848                 .free = LDKConfirm_JCalls_free,
11849         };
11850         return ret;
11851 }
11852 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKConfirm_1new(JNIEnv *env, jclass clz, jobject o) {
11853         LDKConfirm *res_ptr = MALLOC(sizeof(LDKConfirm), "LDKConfirm");
11854         *res_ptr = LDKConfirm_init(env, clz, o);
11855         return tag_ptr(res_ptr, true);
11856 }
11857 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) {
11858         void* this_arg_ptr = untag_ptr(this_arg);
11859         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
11860         LDKConfirm* this_arg_conv = (LDKConfirm*)this_arg_ptr;
11861         unsigned char header_arr[80];
11862         CHECK((*env)->GetArrayLength(env, header) == 80);
11863         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
11864         unsigned char (*header_ref)[80] = &header_arr;
11865         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
11866         txdata_constr.datalen = (*env)->GetArrayLength(env, txdata);
11867         if (txdata_constr.datalen > 0)
11868                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
11869         else
11870                 txdata_constr.data = NULL;
11871         int64_t* txdata_vals = (*env)->GetLongArrayElements (env, txdata, NULL);
11872         for (size_t c = 0; c < txdata_constr.datalen; c++) {
11873                 int64_t txdata_conv_28 = txdata_vals[c];
11874                 void* txdata_conv_28_ptr = untag_ptr(txdata_conv_28);
11875                 CHECK_ACCESS(txdata_conv_28_ptr);
11876                 LDKC2Tuple_usizeTransactionZ txdata_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(txdata_conv_28_ptr);
11877                 txdata_conv_28_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)untag_ptr(txdata_conv_28));
11878                 txdata_constr.data[c] = txdata_conv_28_conv;
11879         }
11880         (*env)->ReleaseLongArrayElements(env, txdata, txdata_vals, 0);
11881         (this_arg_conv->transactions_confirmed)(this_arg_conv->this_arg, header_ref, txdata_constr, height);
11882 }
11883
11884 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Confirm_1transaction_1unconfirmed(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray txid) {
11885         void* this_arg_ptr = untag_ptr(this_arg);
11886         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
11887         LDKConfirm* this_arg_conv = (LDKConfirm*)this_arg_ptr;
11888         unsigned char txid_arr[32];
11889         CHECK((*env)->GetArrayLength(env, txid) == 32);
11890         (*env)->GetByteArrayRegion(env, txid, 0, 32, txid_arr);
11891         unsigned char (*txid_ref)[32] = &txid_arr;
11892         (this_arg_conv->transaction_unconfirmed)(this_arg_conv->this_arg, txid_ref);
11893 }
11894
11895 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) {
11896         void* this_arg_ptr = untag_ptr(this_arg);
11897         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
11898         LDKConfirm* this_arg_conv = (LDKConfirm*)this_arg_ptr;
11899         unsigned char header_arr[80];
11900         CHECK((*env)->GetArrayLength(env, header) == 80);
11901         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
11902         unsigned char (*header_ref)[80] = &header_arr;
11903         (this_arg_conv->best_block_updated)(this_arg_conv->this_arg, header_ref, height);
11904 }
11905
11906 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_Confirm_1get_1relevant_1txids(JNIEnv *env, jclass clz, int64_t this_arg) {
11907         void* this_arg_ptr = untag_ptr(this_arg);
11908         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
11909         LDKConfirm* this_arg_conv = (LDKConfirm*)this_arg_ptr;
11910         LDKCVec_C2Tuple_TxidBlockHashZZ ret_var = (this_arg_conv->get_relevant_txids)(this_arg_conv->this_arg);
11911         int64_tArray ret_arr = NULL;
11912         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
11913         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
11914         for (size_t z = 0; z < ret_var.datalen; z++) {
11915                 LDKC2Tuple_TxidBlockHashZ* ret_conv_25_conv = MALLOC(sizeof(LDKC2Tuple_TxidBlockHashZ), "LDKC2Tuple_TxidBlockHashZ");
11916                 *ret_conv_25_conv = ret_var.data[z];
11917                 ret_arr_ptr[z] = tag_ptr(ret_conv_25_conv, true);
11918         }
11919         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
11920         FREE(ret_var.data);
11921         return ret_arr;
11922 }
11923
11924 typedef struct LDKPersist_JCalls {
11925         atomic_size_t refcnt;
11926         JavaVM *vm;
11927         jweak o;
11928         jmethodID persist_new_channel_meth;
11929         jmethodID update_persisted_channel_meth;
11930 } LDKPersist_JCalls;
11931 static void LDKPersist_JCalls_free(void* this_arg) {
11932         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
11933         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
11934                 JNIEnv *env;
11935                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11936                 if (get_jenv_res == JNI_EDETACHED) {
11937                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11938                 } else {
11939                         DO_ASSERT(get_jenv_res == JNI_OK);
11940                 }
11941                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
11942                 if (get_jenv_res == JNI_EDETACHED) {
11943                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11944                 }
11945                 FREE(j_calls);
11946         }
11947 }
11948 LDKChannelMonitorUpdateStatus persist_new_channel_LDKPersist_jcall(const void* this_arg, LDKOutPoint channel_id, const LDKChannelMonitor * data, LDKMonitorUpdateId update_id) {
11949         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
11950         JNIEnv *env;
11951         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11952         if (get_jenv_res == JNI_EDETACHED) {
11953                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11954         } else {
11955                 DO_ASSERT(get_jenv_res == JNI_OK);
11956         }
11957         LDKOutPoint channel_id_var = channel_id;
11958         int64_t channel_id_ref = 0;
11959         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_id_var);
11960         channel_id_ref = tag_ptr(channel_id_var.inner, channel_id_var.is_owned);
11961         LDKChannelMonitor data_var = *data;
11962         int64_t data_ref = 0;
11963         data_var = ChannelMonitor_clone(&data_var);
11964         CHECK_INNER_FIELD_ACCESS_OR_NULL(data_var);
11965         data_ref = tag_ptr(data_var.inner, data_var.is_owned);
11966         LDKMonitorUpdateId update_id_var = update_id;
11967         int64_t update_id_ref = 0;
11968         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_id_var);
11969         update_id_ref = tag_ptr(update_id_var.inner, update_id_var.is_owned);
11970         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
11971         CHECK(obj != NULL);
11972         jclass ret = (*env)->CallObjectMethod(env, obj, j_calls->persist_new_channel_meth, channel_id_ref, data_ref, update_id_ref);
11973         if (UNLIKELY((*env)->ExceptionCheck(env))) {
11974                 (*env)->ExceptionDescribe(env);
11975                 (*env)->FatalError(env, "A call to persist_new_channel in LDKPersist from rust threw an exception.");
11976         }
11977         LDKChannelMonitorUpdateStatus ret_conv = LDKChannelMonitorUpdateStatus_from_java(env, ret);
11978         if (get_jenv_res == JNI_EDETACHED) {
11979                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
11980         }
11981         return ret_conv;
11982 }
11983 LDKChannelMonitorUpdateStatus update_persisted_channel_LDKPersist_jcall(const void* this_arg, LDKOutPoint channel_id, const LDKChannelMonitorUpdate * update, const LDKChannelMonitor * data, LDKMonitorUpdateId update_id) {
11984         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
11985         JNIEnv *env;
11986         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
11987         if (get_jenv_res == JNI_EDETACHED) {
11988                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
11989         } else {
11990                 DO_ASSERT(get_jenv_res == JNI_OK);
11991         }
11992         LDKOutPoint channel_id_var = channel_id;
11993         int64_t channel_id_ref = 0;
11994         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_id_var);
11995         channel_id_ref = tag_ptr(channel_id_var.inner, channel_id_var.is_owned);
11996         LDKChannelMonitorUpdate update_var = *update;
11997         int64_t update_ref = 0;
11998         update_var = ChannelMonitorUpdate_clone(&update_var);
11999         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_var);
12000         update_ref = tag_ptr(update_var.inner, update_var.is_owned);
12001         LDKChannelMonitor data_var = *data;
12002         int64_t data_ref = 0;
12003         data_var = ChannelMonitor_clone(&data_var);
12004         CHECK_INNER_FIELD_ACCESS_OR_NULL(data_var);
12005         data_ref = tag_ptr(data_var.inner, data_var.is_owned);
12006         LDKMonitorUpdateId update_id_var = update_id;
12007         int64_t update_id_ref = 0;
12008         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_id_var);
12009         update_id_ref = tag_ptr(update_id_var.inner, update_id_var.is_owned);
12010         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12011         CHECK(obj != NULL);
12012         jclass ret = (*env)->CallObjectMethod(env, obj, j_calls->update_persisted_channel_meth, channel_id_ref, update_ref, data_ref, update_id_ref);
12013         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12014                 (*env)->ExceptionDescribe(env);
12015                 (*env)->FatalError(env, "A call to update_persisted_channel in LDKPersist from rust threw an exception.");
12016         }
12017         LDKChannelMonitorUpdateStatus ret_conv = LDKChannelMonitorUpdateStatus_from_java(env, ret);
12018         if (get_jenv_res == JNI_EDETACHED) {
12019                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12020         }
12021         return ret_conv;
12022 }
12023 static void LDKPersist_JCalls_cloned(LDKPersist* new_obj) {
12024         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) new_obj->this_arg;
12025         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
12026 }
12027 static inline LDKPersist LDKPersist_init (JNIEnv *env, jclass clz, jobject o) {
12028         jclass c = (*env)->GetObjectClass(env, o);
12029         CHECK(c != NULL);
12030         LDKPersist_JCalls *calls = MALLOC(sizeof(LDKPersist_JCalls), "LDKPersist_JCalls");
12031         atomic_init(&calls->refcnt, 1);
12032         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
12033         calls->o = (*env)->NewWeakGlobalRef(env, o);
12034         calls->persist_new_channel_meth = (*env)->GetMethodID(env, c, "persist_new_channel", "(JJJ)Lorg/ldk/enums/ChannelMonitorUpdateStatus;");
12035         CHECK(calls->persist_new_channel_meth != NULL);
12036         calls->update_persisted_channel_meth = (*env)->GetMethodID(env, c, "update_persisted_channel", "(JJJJ)Lorg/ldk/enums/ChannelMonitorUpdateStatus;");
12037         CHECK(calls->update_persisted_channel_meth != NULL);
12038
12039         LDKPersist ret = {
12040                 .this_arg = (void*) calls,
12041                 .persist_new_channel = persist_new_channel_LDKPersist_jcall,
12042                 .update_persisted_channel = update_persisted_channel_LDKPersist_jcall,
12043                 .free = LDKPersist_JCalls_free,
12044         };
12045         return ret;
12046 }
12047 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKPersist_1new(JNIEnv *env, jclass clz, jobject o) {
12048         LDKPersist *res_ptr = MALLOC(sizeof(LDKPersist), "LDKPersist");
12049         *res_ptr = LDKPersist_init(env, clz, o);
12050         return tag_ptr(res_ptr, true);
12051 }
12052 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) {
12053         void* this_arg_ptr = untag_ptr(this_arg);
12054         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
12055         LDKPersist* this_arg_conv = (LDKPersist*)this_arg_ptr;
12056         LDKOutPoint channel_id_conv;
12057         channel_id_conv.inner = untag_ptr(channel_id);
12058         channel_id_conv.is_owned = ptr_is_owned(channel_id);
12059         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_id_conv);
12060         channel_id_conv = OutPoint_clone(&channel_id_conv);
12061         LDKChannelMonitor data_conv;
12062         data_conv.inner = untag_ptr(data);
12063         data_conv.is_owned = ptr_is_owned(data);
12064         CHECK_INNER_FIELD_ACCESS_OR_NULL(data_conv);
12065         data_conv.is_owned = false;
12066         LDKMonitorUpdateId update_id_conv;
12067         update_id_conv.inner = untag_ptr(update_id);
12068         update_id_conv.is_owned = ptr_is_owned(update_id);
12069         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_id_conv);
12070         update_id_conv = MonitorUpdateId_clone(&update_id_conv);
12071         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));
12072         return ret_conv;
12073 }
12074
12075 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) {
12076         void* this_arg_ptr = untag_ptr(this_arg);
12077         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
12078         LDKPersist* this_arg_conv = (LDKPersist*)this_arg_ptr;
12079         LDKOutPoint channel_id_conv;
12080         channel_id_conv.inner = untag_ptr(channel_id);
12081         channel_id_conv.is_owned = ptr_is_owned(channel_id);
12082         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_id_conv);
12083         channel_id_conv = OutPoint_clone(&channel_id_conv);
12084         LDKChannelMonitorUpdate update_conv;
12085         update_conv.inner = untag_ptr(update);
12086         update_conv.is_owned = ptr_is_owned(update);
12087         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_conv);
12088         update_conv.is_owned = false;
12089         LDKChannelMonitor data_conv;
12090         data_conv.inner = untag_ptr(data);
12091         data_conv.is_owned = ptr_is_owned(data);
12092         CHECK_INNER_FIELD_ACCESS_OR_NULL(data_conv);
12093         data_conv.is_owned = false;
12094         LDKMonitorUpdateId update_id_conv;
12095         update_id_conv.inner = untag_ptr(update_id);
12096         update_id_conv.is_owned = ptr_is_owned(update_id);
12097         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_id_conv);
12098         update_id_conv = MonitorUpdateId_clone(&update_id_conv);
12099         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));
12100         return ret_conv;
12101 }
12102
12103 typedef struct LDKChannelMessageHandler_JCalls {
12104         atomic_size_t refcnt;
12105         JavaVM *vm;
12106         jweak o;
12107         LDKMessageSendEventsProvider_JCalls* MessageSendEventsProvider;
12108         jmethodID handle_open_channel_meth;
12109         jmethodID handle_accept_channel_meth;
12110         jmethodID handle_funding_created_meth;
12111         jmethodID handle_funding_signed_meth;
12112         jmethodID handle_channel_ready_meth;
12113         jmethodID handle_shutdown_meth;
12114         jmethodID handle_closing_signed_meth;
12115         jmethodID handle_update_add_htlc_meth;
12116         jmethodID handle_update_fulfill_htlc_meth;
12117         jmethodID handle_update_fail_htlc_meth;
12118         jmethodID handle_update_fail_malformed_htlc_meth;
12119         jmethodID handle_commitment_signed_meth;
12120         jmethodID handle_revoke_and_ack_meth;
12121         jmethodID handle_update_fee_meth;
12122         jmethodID handle_announcement_signatures_meth;
12123         jmethodID peer_disconnected_meth;
12124         jmethodID peer_connected_meth;
12125         jmethodID handle_channel_reestablish_meth;
12126         jmethodID handle_channel_update_meth;
12127         jmethodID handle_error_meth;
12128         jmethodID provided_node_features_meth;
12129         jmethodID provided_init_features_meth;
12130 } LDKChannelMessageHandler_JCalls;
12131 static void LDKChannelMessageHandler_JCalls_free(void* this_arg) {
12132         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
12133         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
12134                 JNIEnv *env;
12135                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12136                 if (get_jenv_res == JNI_EDETACHED) {
12137                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12138                 } else {
12139                         DO_ASSERT(get_jenv_res == JNI_OK);
12140                 }
12141                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
12142                 if (get_jenv_res == JNI_EDETACHED) {
12143                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12144                 }
12145                 FREE(j_calls);
12146         }
12147 }
12148 void handle_open_channel_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKInitFeatures their_features, const LDKOpenChannel * msg) {
12149         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
12150         JNIEnv *env;
12151         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12152         if (get_jenv_res == JNI_EDETACHED) {
12153                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12154         } else {
12155                 DO_ASSERT(get_jenv_res == JNI_OK);
12156         }
12157         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
12158         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
12159         LDKInitFeatures their_features_var = their_features;
12160         int64_t their_features_ref = 0;
12161         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_var);
12162         their_features_ref = tag_ptr(their_features_var.inner, their_features_var.is_owned);
12163         LDKOpenChannel msg_var = *msg;
12164         int64_t msg_ref = 0;
12165         msg_var = OpenChannel_clone(&msg_var);
12166         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
12167         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
12168         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12169         CHECK(obj != NULL);
12170         (*env)->CallVoidMethod(env, obj, j_calls->handle_open_channel_meth, their_node_id_arr, their_features_ref, msg_ref);
12171         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12172                 (*env)->ExceptionDescribe(env);
12173                 (*env)->FatalError(env, "A call to handle_open_channel in LDKChannelMessageHandler from rust threw an exception.");
12174         }
12175         if (get_jenv_res == JNI_EDETACHED) {
12176                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12177         }
12178 }
12179 void handle_accept_channel_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKInitFeatures their_features, const LDKAcceptChannel * msg) {
12180         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
12181         JNIEnv *env;
12182         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12183         if (get_jenv_res == JNI_EDETACHED) {
12184                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12185         } else {
12186                 DO_ASSERT(get_jenv_res == JNI_OK);
12187         }
12188         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
12189         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
12190         LDKInitFeatures their_features_var = their_features;
12191         int64_t their_features_ref = 0;
12192         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_var);
12193         their_features_ref = tag_ptr(their_features_var.inner, their_features_var.is_owned);
12194         LDKAcceptChannel msg_var = *msg;
12195         int64_t msg_ref = 0;
12196         msg_var = AcceptChannel_clone(&msg_var);
12197         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
12198         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
12199         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12200         CHECK(obj != NULL);
12201         (*env)->CallVoidMethod(env, obj, j_calls->handle_accept_channel_meth, their_node_id_arr, their_features_ref, msg_ref);
12202         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12203                 (*env)->ExceptionDescribe(env);
12204                 (*env)->FatalError(env, "A call to handle_accept_channel in LDKChannelMessageHandler from rust threw an exception.");
12205         }
12206         if (get_jenv_res == JNI_EDETACHED) {
12207                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12208         }
12209 }
12210 void handle_funding_created_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingCreated * msg) {
12211         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
12212         JNIEnv *env;
12213         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12214         if (get_jenv_res == JNI_EDETACHED) {
12215                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12216         } else {
12217                 DO_ASSERT(get_jenv_res == JNI_OK);
12218         }
12219         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
12220         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
12221         LDKFundingCreated msg_var = *msg;
12222         int64_t msg_ref = 0;
12223         msg_var = FundingCreated_clone(&msg_var);
12224         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
12225         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
12226         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12227         CHECK(obj != NULL);
12228         (*env)->CallVoidMethod(env, obj, j_calls->handle_funding_created_meth, their_node_id_arr, msg_ref);
12229         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12230                 (*env)->ExceptionDescribe(env);
12231                 (*env)->FatalError(env, "A call to handle_funding_created in LDKChannelMessageHandler from rust threw an exception.");
12232         }
12233         if (get_jenv_res == JNI_EDETACHED) {
12234                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12235         }
12236 }
12237 void handle_funding_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingSigned * msg) {
12238         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
12239         JNIEnv *env;
12240         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12241         if (get_jenv_res == JNI_EDETACHED) {
12242                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12243         } else {
12244                 DO_ASSERT(get_jenv_res == JNI_OK);
12245         }
12246         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
12247         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
12248         LDKFundingSigned msg_var = *msg;
12249         int64_t msg_ref = 0;
12250         msg_var = FundingSigned_clone(&msg_var);
12251         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
12252         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
12253         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12254         CHECK(obj != NULL);
12255         (*env)->CallVoidMethod(env, obj, j_calls->handle_funding_signed_meth, their_node_id_arr, msg_ref);
12256         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12257                 (*env)->ExceptionDescribe(env);
12258                 (*env)->FatalError(env, "A call to handle_funding_signed in LDKChannelMessageHandler from rust threw an exception.");
12259         }
12260         if (get_jenv_res == JNI_EDETACHED) {
12261                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12262         }
12263 }
12264 void handle_channel_ready_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKChannelReady * msg) {
12265         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
12266         JNIEnv *env;
12267         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12268         if (get_jenv_res == JNI_EDETACHED) {
12269                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12270         } else {
12271                 DO_ASSERT(get_jenv_res == JNI_OK);
12272         }
12273         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
12274         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
12275         LDKChannelReady msg_var = *msg;
12276         int64_t msg_ref = 0;
12277         msg_var = ChannelReady_clone(&msg_var);
12278         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
12279         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
12280         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12281         CHECK(obj != NULL);
12282         (*env)->CallVoidMethod(env, obj, j_calls->handle_channel_ready_meth, their_node_id_arr, msg_ref);
12283         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12284                 (*env)->ExceptionDescribe(env);
12285                 (*env)->FatalError(env, "A call to handle_channel_ready in LDKChannelMessageHandler from rust threw an exception.");
12286         }
12287         if (get_jenv_res == JNI_EDETACHED) {
12288                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12289         }
12290 }
12291 void handle_shutdown_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInitFeatures * their_features, const LDKShutdown * msg) {
12292         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
12293         JNIEnv *env;
12294         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12295         if (get_jenv_res == JNI_EDETACHED) {
12296                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12297         } else {
12298                 DO_ASSERT(get_jenv_res == JNI_OK);
12299         }
12300         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
12301         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
12302         LDKInitFeatures their_features_var = *their_features;
12303         int64_t their_features_ref = 0;
12304         their_features_var = InitFeatures_clone(&their_features_var);
12305         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_var);
12306         their_features_ref = tag_ptr(their_features_var.inner, their_features_var.is_owned);
12307         LDKShutdown msg_var = *msg;
12308         int64_t msg_ref = 0;
12309         msg_var = Shutdown_clone(&msg_var);
12310         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
12311         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
12312         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12313         CHECK(obj != NULL);
12314         (*env)->CallVoidMethod(env, obj, j_calls->handle_shutdown_meth, their_node_id_arr, their_features_ref, msg_ref);
12315         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12316                 (*env)->ExceptionDescribe(env);
12317                 (*env)->FatalError(env, "A call to handle_shutdown in LDKChannelMessageHandler from rust threw an exception.");
12318         }
12319         if (get_jenv_res == JNI_EDETACHED) {
12320                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12321         }
12322 }
12323 void handle_closing_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKClosingSigned * msg) {
12324         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
12325         JNIEnv *env;
12326         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12327         if (get_jenv_res == JNI_EDETACHED) {
12328                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12329         } else {
12330                 DO_ASSERT(get_jenv_res == JNI_OK);
12331         }
12332         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
12333         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
12334         LDKClosingSigned msg_var = *msg;
12335         int64_t msg_ref = 0;
12336         msg_var = ClosingSigned_clone(&msg_var);
12337         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
12338         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
12339         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12340         CHECK(obj != NULL);
12341         (*env)->CallVoidMethod(env, obj, j_calls->handle_closing_signed_meth, their_node_id_arr, msg_ref);
12342         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12343                 (*env)->ExceptionDescribe(env);
12344                 (*env)->FatalError(env, "A call to handle_closing_signed in LDKChannelMessageHandler from rust threw an exception.");
12345         }
12346         if (get_jenv_res == JNI_EDETACHED) {
12347                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12348         }
12349 }
12350 void handle_update_add_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateAddHTLC * msg) {
12351         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
12352         JNIEnv *env;
12353         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12354         if (get_jenv_res == JNI_EDETACHED) {
12355                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12356         } else {
12357                 DO_ASSERT(get_jenv_res == JNI_OK);
12358         }
12359         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
12360         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
12361         LDKUpdateAddHTLC msg_var = *msg;
12362         int64_t msg_ref = 0;
12363         msg_var = UpdateAddHTLC_clone(&msg_var);
12364         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
12365         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
12366         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12367         CHECK(obj != NULL);
12368         (*env)->CallVoidMethod(env, obj, j_calls->handle_update_add_htlc_meth, their_node_id_arr, msg_ref);
12369         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12370                 (*env)->ExceptionDescribe(env);
12371                 (*env)->FatalError(env, "A call to handle_update_add_htlc in LDKChannelMessageHandler from rust threw an exception.");
12372         }
12373         if (get_jenv_res == JNI_EDETACHED) {
12374                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12375         }
12376 }
12377 void handle_update_fulfill_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFulfillHTLC * msg) {
12378         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
12379         JNIEnv *env;
12380         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12381         if (get_jenv_res == JNI_EDETACHED) {
12382                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12383         } else {
12384                 DO_ASSERT(get_jenv_res == JNI_OK);
12385         }
12386         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
12387         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
12388         LDKUpdateFulfillHTLC msg_var = *msg;
12389         int64_t msg_ref = 0;
12390         msg_var = UpdateFulfillHTLC_clone(&msg_var);
12391         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
12392         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
12393         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12394         CHECK(obj != NULL);
12395         (*env)->CallVoidMethod(env, obj, j_calls->handle_update_fulfill_htlc_meth, their_node_id_arr, msg_ref);
12396         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12397                 (*env)->ExceptionDescribe(env);
12398                 (*env)->FatalError(env, "A call to handle_update_fulfill_htlc in LDKChannelMessageHandler from rust threw an exception.");
12399         }
12400         if (get_jenv_res == JNI_EDETACHED) {
12401                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12402         }
12403 }
12404 void handle_update_fail_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFailHTLC * msg) {
12405         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
12406         JNIEnv *env;
12407         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12408         if (get_jenv_res == JNI_EDETACHED) {
12409                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12410         } else {
12411                 DO_ASSERT(get_jenv_res == JNI_OK);
12412         }
12413         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
12414         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
12415         LDKUpdateFailHTLC msg_var = *msg;
12416         int64_t msg_ref = 0;
12417         msg_var = UpdateFailHTLC_clone(&msg_var);
12418         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
12419         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
12420         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12421         CHECK(obj != NULL);
12422         (*env)->CallVoidMethod(env, obj, j_calls->handle_update_fail_htlc_meth, their_node_id_arr, msg_ref);
12423         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12424                 (*env)->ExceptionDescribe(env);
12425                 (*env)->FatalError(env, "A call to handle_update_fail_htlc in LDKChannelMessageHandler from rust threw an exception.");
12426         }
12427         if (get_jenv_res == JNI_EDETACHED) {
12428                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12429         }
12430 }
12431 void handle_update_fail_malformed_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFailMalformedHTLC * msg) {
12432         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
12433         JNIEnv *env;
12434         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12435         if (get_jenv_res == JNI_EDETACHED) {
12436                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12437         } else {
12438                 DO_ASSERT(get_jenv_res == JNI_OK);
12439         }
12440         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
12441         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
12442         LDKUpdateFailMalformedHTLC msg_var = *msg;
12443         int64_t msg_ref = 0;
12444         msg_var = UpdateFailMalformedHTLC_clone(&msg_var);
12445         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
12446         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
12447         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12448         CHECK(obj != NULL);
12449         (*env)->CallVoidMethod(env, obj, j_calls->handle_update_fail_malformed_htlc_meth, their_node_id_arr, msg_ref);
12450         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12451                 (*env)->ExceptionDescribe(env);
12452                 (*env)->FatalError(env, "A call to handle_update_fail_malformed_htlc in LDKChannelMessageHandler from rust threw an exception.");
12453         }
12454         if (get_jenv_res == JNI_EDETACHED) {
12455                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12456         }
12457 }
12458 void handle_commitment_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKCommitmentSigned * msg) {
12459         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
12460         JNIEnv *env;
12461         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12462         if (get_jenv_res == JNI_EDETACHED) {
12463                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12464         } else {
12465                 DO_ASSERT(get_jenv_res == JNI_OK);
12466         }
12467         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
12468         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
12469         LDKCommitmentSigned msg_var = *msg;
12470         int64_t msg_ref = 0;
12471         msg_var = CommitmentSigned_clone(&msg_var);
12472         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
12473         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
12474         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12475         CHECK(obj != NULL);
12476         (*env)->CallVoidMethod(env, obj, j_calls->handle_commitment_signed_meth, their_node_id_arr, msg_ref);
12477         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12478                 (*env)->ExceptionDescribe(env);
12479                 (*env)->FatalError(env, "A call to handle_commitment_signed in LDKChannelMessageHandler from rust threw an exception.");
12480         }
12481         if (get_jenv_res == JNI_EDETACHED) {
12482                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12483         }
12484 }
12485 void handle_revoke_and_ack_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKRevokeAndACK * msg) {
12486         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
12487         JNIEnv *env;
12488         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12489         if (get_jenv_res == JNI_EDETACHED) {
12490                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12491         } else {
12492                 DO_ASSERT(get_jenv_res == JNI_OK);
12493         }
12494         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
12495         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
12496         LDKRevokeAndACK msg_var = *msg;
12497         int64_t msg_ref = 0;
12498         msg_var = RevokeAndACK_clone(&msg_var);
12499         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
12500         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
12501         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12502         CHECK(obj != NULL);
12503         (*env)->CallVoidMethod(env, obj, j_calls->handle_revoke_and_ack_meth, their_node_id_arr, msg_ref);
12504         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12505                 (*env)->ExceptionDescribe(env);
12506                 (*env)->FatalError(env, "A call to handle_revoke_and_ack in LDKChannelMessageHandler from rust threw an exception.");
12507         }
12508         if (get_jenv_res == JNI_EDETACHED) {
12509                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12510         }
12511 }
12512 void handle_update_fee_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFee * msg) {
12513         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
12514         JNIEnv *env;
12515         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12516         if (get_jenv_res == JNI_EDETACHED) {
12517                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12518         } else {
12519                 DO_ASSERT(get_jenv_res == JNI_OK);
12520         }
12521         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
12522         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
12523         LDKUpdateFee msg_var = *msg;
12524         int64_t msg_ref = 0;
12525         msg_var = UpdateFee_clone(&msg_var);
12526         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
12527         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
12528         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12529         CHECK(obj != NULL);
12530         (*env)->CallVoidMethod(env, obj, j_calls->handle_update_fee_meth, their_node_id_arr, msg_ref);
12531         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12532                 (*env)->ExceptionDescribe(env);
12533                 (*env)->FatalError(env, "A call to handle_update_fee in LDKChannelMessageHandler from rust threw an exception.");
12534         }
12535         if (get_jenv_res == JNI_EDETACHED) {
12536                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12537         }
12538 }
12539 void handle_announcement_signatures_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKAnnouncementSignatures * msg) {
12540         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
12541         JNIEnv *env;
12542         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12543         if (get_jenv_res == JNI_EDETACHED) {
12544                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12545         } else {
12546                 DO_ASSERT(get_jenv_res == JNI_OK);
12547         }
12548         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
12549         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
12550         LDKAnnouncementSignatures msg_var = *msg;
12551         int64_t msg_ref = 0;
12552         msg_var = AnnouncementSignatures_clone(&msg_var);
12553         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
12554         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
12555         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12556         CHECK(obj != NULL);
12557         (*env)->CallVoidMethod(env, obj, j_calls->handle_announcement_signatures_meth, their_node_id_arr, msg_ref);
12558         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12559                 (*env)->ExceptionDescribe(env);
12560                 (*env)->FatalError(env, "A call to handle_announcement_signatures in LDKChannelMessageHandler from rust threw an exception.");
12561         }
12562         if (get_jenv_res == JNI_EDETACHED) {
12563                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12564         }
12565 }
12566 void peer_disconnected_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, bool no_connection_possible) {
12567         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
12568         JNIEnv *env;
12569         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12570         if (get_jenv_res == JNI_EDETACHED) {
12571                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12572         } else {
12573                 DO_ASSERT(get_jenv_res == JNI_OK);
12574         }
12575         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
12576         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
12577         jboolean no_connection_possible_conv = no_connection_possible;
12578         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12579         CHECK(obj != NULL);
12580         (*env)->CallVoidMethod(env, obj, j_calls->peer_disconnected_meth, their_node_id_arr, no_connection_possible_conv);
12581         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12582                 (*env)->ExceptionDescribe(env);
12583                 (*env)->FatalError(env, "A call to peer_disconnected in LDKChannelMessageHandler from rust threw an exception.");
12584         }
12585         if (get_jenv_res == JNI_EDETACHED) {
12586                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12587         }
12588 }
12589 LDKCResult_NoneNoneZ peer_connected_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInit * msg) {
12590         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
12591         JNIEnv *env;
12592         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12593         if (get_jenv_res == JNI_EDETACHED) {
12594                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12595         } else {
12596                 DO_ASSERT(get_jenv_res == JNI_OK);
12597         }
12598         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
12599         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
12600         LDKInit msg_var = *msg;
12601         int64_t msg_ref = 0;
12602         msg_var = Init_clone(&msg_var);
12603         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
12604         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
12605         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12606         CHECK(obj != NULL);
12607         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->peer_connected_meth, their_node_id_arr, msg_ref);
12608         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12609                 (*env)->ExceptionDescribe(env);
12610                 (*env)->FatalError(env, "A call to peer_connected in LDKChannelMessageHandler from rust threw an exception.");
12611         }
12612         void* ret_ptr = untag_ptr(ret);
12613         CHECK_ACCESS(ret_ptr);
12614         LDKCResult_NoneNoneZ ret_conv = *(LDKCResult_NoneNoneZ*)(ret_ptr);
12615         FREE(untag_ptr(ret));
12616         if (get_jenv_res == JNI_EDETACHED) {
12617                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12618         }
12619         return ret_conv;
12620 }
12621 void handle_channel_reestablish_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKChannelReestablish * msg) {
12622         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
12623         JNIEnv *env;
12624         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12625         if (get_jenv_res == JNI_EDETACHED) {
12626                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12627         } else {
12628                 DO_ASSERT(get_jenv_res == JNI_OK);
12629         }
12630         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
12631         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
12632         LDKChannelReestablish msg_var = *msg;
12633         int64_t msg_ref = 0;
12634         msg_var = ChannelReestablish_clone(&msg_var);
12635         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
12636         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
12637         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12638         CHECK(obj != NULL);
12639         (*env)->CallVoidMethod(env, obj, j_calls->handle_channel_reestablish_meth, their_node_id_arr, msg_ref);
12640         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12641                 (*env)->ExceptionDescribe(env);
12642                 (*env)->FatalError(env, "A call to handle_channel_reestablish in LDKChannelMessageHandler from rust threw an exception.");
12643         }
12644         if (get_jenv_res == JNI_EDETACHED) {
12645                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12646         }
12647 }
12648 void handle_channel_update_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKChannelUpdate * msg) {
12649         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
12650         JNIEnv *env;
12651         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12652         if (get_jenv_res == JNI_EDETACHED) {
12653                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12654         } else {
12655                 DO_ASSERT(get_jenv_res == JNI_OK);
12656         }
12657         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
12658         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
12659         LDKChannelUpdate msg_var = *msg;
12660         int64_t msg_ref = 0;
12661         msg_var = ChannelUpdate_clone(&msg_var);
12662         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
12663         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
12664         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12665         CHECK(obj != NULL);
12666         (*env)->CallVoidMethod(env, obj, j_calls->handle_channel_update_meth, their_node_id_arr, msg_ref);
12667         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12668                 (*env)->ExceptionDescribe(env);
12669                 (*env)->FatalError(env, "A call to handle_channel_update in LDKChannelMessageHandler from rust threw an exception.");
12670         }
12671         if (get_jenv_res == JNI_EDETACHED) {
12672                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12673         }
12674 }
12675 void handle_error_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKErrorMessage * msg) {
12676         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
12677         JNIEnv *env;
12678         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12679         if (get_jenv_res == JNI_EDETACHED) {
12680                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12681         } else {
12682                 DO_ASSERT(get_jenv_res == JNI_OK);
12683         }
12684         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
12685         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
12686         LDKErrorMessage msg_var = *msg;
12687         int64_t msg_ref = 0;
12688         msg_var = ErrorMessage_clone(&msg_var);
12689         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
12690         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
12691         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12692         CHECK(obj != NULL);
12693         (*env)->CallVoidMethod(env, obj, j_calls->handle_error_meth, their_node_id_arr, msg_ref);
12694         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12695                 (*env)->ExceptionDescribe(env);
12696                 (*env)->FatalError(env, "A call to handle_error in LDKChannelMessageHandler from rust threw an exception.");
12697         }
12698         if (get_jenv_res == JNI_EDETACHED) {
12699                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12700         }
12701 }
12702 LDKNodeFeatures provided_node_features_LDKChannelMessageHandler_jcall(const void* this_arg) {
12703         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
12704         JNIEnv *env;
12705         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12706         if (get_jenv_res == JNI_EDETACHED) {
12707                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12708         } else {
12709                 DO_ASSERT(get_jenv_res == JNI_OK);
12710         }
12711         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12712         CHECK(obj != NULL);
12713         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->provided_node_features_meth);
12714         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12715                 (*env)->ExceptionDescribe(env);
12716                 (*env)->FatalError(env, "A call to provided_node_features in LDKChannelMessageHandler from rust threw an exception.");
12717         }
12718         LDKNodeFeatures ret_conv;
12719         ret_conv.inner = untag_ptr(ret);
12720         ret_conv.is_owned = ptr_is_owned(ret);
12721         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv);
12722         if (get_jenv_res == JNI_EDETACHED) {
12723                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12724         }
12725         return ret_conv;
12726 }
12727 LDKInitFeatures provided_init_features_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id) {
12728         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
12729         JNIEnv *env;
12730         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
12731         if (get_jenv_res == JNI_EDETACHED) {
12732                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
12733         } else {
12734                 DO_ASSERT(get_jenv_res == JNI_OK);
12735         }
12736         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
12737         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
12738         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
12739         CHECK(obj != NULL);
12740         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->provided_init_features_meth, their_node_id_arr);
12741         if (UNLIKELY((*env)->ExceptionCheck(env))) {
12742                 (*env)->ExceptionDescribe(env);
12743                 (*env)->FatalError(env, "A call to provided_init_features in LDKChannelMessageHandler from rust threw an exception.");
12744         }
12745         LDKInitFeatures ret_conv;
12746         ret_conv.inner = untag_ptr(ret);
12747         ret_conv.is_owned = ptr_is_owned(ret);
12748         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv);
12749         if (get_jenv_res == JNI_EDETACHED) {
12750                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
12751         }
12752         return ret_conv;
12753 }
12754 static void LDKChannelMessageHandler_JCalls_cloned(LDKChannelMessageHandler* new_obj) {
12755         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) new_obj->this_arg;
12756         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
12757         atomic_fetch_add_explicit(&j_calls->MessageSendEventsProvider->refcnt, 1, memory_order_release);
12758 }
12759 static inline LDKChannelMessageHandler LDKChannelMessageHandler_init (JNIEnv *env, jclass clz, jobject o, jobject MessageSendEventsProvider) {
12760         jclass c = (*env)->GetObjectClass(env, o);
12761         CHECK(c != NULL);
12762         LDKChannelMessageHandler_JCalls *calls = MALLOC(sizeof(LDKChannelMessageHandler_JCalls), "LDKChannelMessageHandler_JCalls");
12763         atomic_init(&calls->refcnt, 1);
12764         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
12765         calls->o = (*env)->NewWeakGlobalRef(env, o);
12766         calls->handle_open_channel_meth = (*env)->GetMethodID(env, c, "handle_open_channel", "([BJJ)V");
12767         CHECK(calls->handle_open_channel_meth != NULL);
12768         calls->handle_accept_channel_meth = (*env)->GetMethodID(env, c, "handle_accept_channel", "([BJJ)V");
12769         CHECK(calls->handle_accept_channel_meth != NULL);
12770         calls->handle_funding_created_meth = (*env)->GetMethodID(env, c, "handle_funding_created", "([BJ)V");
12771         CHECK(calls->handle_funding_created_meth != NULL);
12772         calls->handle_funding_signed_meth = (*env)->GetMethodID(env, c, "handle_funding_signed", "([BJ)V");
12773         CHECK(calls->handle_funding_signed_meth != NULL);
12774         calls->handle_channel_ready_meth = (*env)->GetMethodID(env, c, "handle_channel_ready", "([BJ)V");
12775         CHECK(calls->handle_channel_ready_meth != NULL);
12776         calls->handle_shutdown_meth = (*env)->GetMethodID(env, c, "handle_shutdown", "([BJJ)V");
12777         CHECK(calls->handle_shutdown_meth != NULL);
12778         calls->handle_closing_signed_meth = (*env)->GetMethodID(env, c, "handle_closing_signed", "([BJ)V");
12779         CHECK(calls->handle_closing_signed_meth != NULL);
12780         calls->handle_update_add_htlc_meth = (*env)->GetMethodID(env, c, "handle_update_add_htlc", "([BJ)V");
12781         CHECK(calls->handle_update_add_htlc_meth != NULL);
12782         calls->handle_update_fulfill_htlc_meth = (*env)->GetMethodID(env, c, "handle_update_fulfill_htlc", "([BJ)V");
12783         CHECK(calls->handle_update_fulfill_htlc_meth != NULL);
12784         calls->handle_update_fail_htlc_meth = (*env)->GetMethodID(env, c, "handle_update_fail_htlc", "([BJ)V");
12785         CHECK(calls->handle_update_fail_htlc_meth != NULL);
12786         calls->handle_update_fail_malformed_htlc_meth = (*env)->GetMethodID(env, c, "handle_update_fail_malformed_htlc", "([BJ)V");
12787         CHECK(calls->handle_update_fail_malformed_htlc_meth != NULL);
12788         calls->handle_commitment_signed_meth = (*env)->GetMethodID(env, c, "handle_commitment_signed", "([BJ)V");
12789         CHECK(calls->handle_commitment_signed_meth != NULL);
12790         calls->handle_revoke_and_ack_meth = (*env)->GetMethodID(env, c, "handle_revoke_and_ack", "([BJ)V");
12791         CHECK(calls->handle_revoke_and_ack_meth != NULL);
12792         calls->handle_update_fee_meth = (*env)->GetMethodID(env, c, "handle_update_fee", "([BJ)V");
12793         CHECK(calls->handle_update_fee_meth != NULL);
12794         calls->handle_announcement_signatures_meth = (*env)->GetMethodID(env, c, "handle_announcement_signatures", "([BJ)V");
12795         CHECK(calls->handle_announcement_signatures_meth != NULL);
12796         calls->peer_disconnected_meth = (*env)->GetMethodID(env, c, "peer_disconnected", "([BZ)V");
12797         CHECK(calls->peer_disconnected_meth != NULL);
12798         calls->peer_connected_meth = (*env)->GetMethodID(env, c, "peer_connected", "([BJ)J");
12799         CHECK(calls->peer_connected_meth != NULL);
12800         calls->handle_channel_reestablish_meth = (*env)->GetMethodID(env, c, "handle_channel_reestablish", "([BJ)V");
12801         CHECK(calls->handle_channel_reestablish_meth != NULL);
12802         calls->handle_channel_update_meth = (*env)->GetMethodID(env, c, "handle_channel_update", "([BJ)V");
12803         CHECK(calls->handle_channel_update_meth != NULL);
12804         calls->handle_error_meth = (*env)->GetMethodID(env, c, "handle_error", "([BJ)V");
12805         CHECK(calls->handle_error_meth != NULL);
12806         calls->provided_node_features_meth = (*env)->GetMethodID(env, c, "provided_node_features", "()J");
12807         CHECK(calls->provided_node_features_meth != NULL);
12808         calls->provided_init_features_meth = (*env)->GetMethodID(env, c, "provided_init_features", "([B)J");
12809         CHECK(calls->provided_init_features_meth != NULL);
12810
12811         LDKChannelMessageHandler ret = {
12812                 .this_arg = (void*) calls,
12813                 .handle_open_channel = handle_open_channel_LDKChannelMessageHandler_jcall,
12814                 .handle_accept_channel = handle_accept_channel_LDKChannelMessageHandler_jcall,
12815                 .handle_funding_created = handle_funding_created_LDKChannelMessageHandler_jcall,
12816                 .handle_funding_signed = handle_funding_signed_LDKChannelMessageHandler_jcall,
12817                 .handle_channel_ready = handle_channel_ready_LDKChannelMessageHandler_jcall,
12818                 .handle_shutdown = handle_shutdown_LDKChannelMessageHandler_jcall,
12819                 .handle_closing_signed = handle_closing_signed_LDKChannelMessageHandler_jcall,
12820                 .handle_update_add_htlc = handle_update_add_htlc_LDKChannelMessageHandler_jcall,
12821                 .handle_update_fulfill_htlc = handle_update_fulfill_htlc_LDKChannelMessageHandler_jcall,
12822                 .handle_update_fail_htlc = handle_update_fail_htlc_LDKChannelMessageHandler_jcall,
12823                 .handle_update_fail_malformed_htlc = handle_update_fail_malformed_htlc_LDKChannelMessageHandler_jcall,
12824                 .handle_commitment_signed = handle_commitment_signed_LDKChannelMessageHandler_jcall,
12825                 .handle_revoke_and_ack = handle_revoke_and_ack_LDKChannelMessageHandler_jcall,
12826                 .handle_update_fee = handle_update_fee_LDKChannelMessageHandler_jcall,
12827                 .handle_announcement_signatures = handle_announcement_signatures_LDKChannelMessageHandler_jcall,
12828                 .peer_disconnected = peer_disconnected_LDKChannelMessageHandler_jcall,
12829                 .peer_connected = peer_connected_LDKChannelMessageHandler_jcall,
12830                 .handle_channel_reestablish = handle_channel_reestablish_LDKChannelMessageHandler_jcall,
12831                 .handle_channel_update = handle_channel_update_LDKChannelMessageHandler_jcall,
12832                 .handle_error = handle_error_LDKChannelMessageHandler_jcall,
12833                 .provided_node_features = provided_node_features_LDKChannelMessageHandler_jcall,
12834                 .provided_init_features = provided_init_features_LDKChannelMessageHandler_jcall,
12835                 .free = LDKChannelMessageHandler_JCalls_free,
12836                 .MessageSendEventsProvider = LDKMessageSendEventsProvider_init(env, clz, MessageSendEventsProvider),
12837         };
12838         calls->MessageSendEventsProvider = ret.MessageSendEventsProvider.this_arg;
12839         return ret;
12840 }
12841 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKChannelMessageHandler_1new(JNIEnv *env, jclass clz, jobject o, jobject MessageSendEventsProvider) {
12842         LDKChannelMessageHandler *res_ptr = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
12843         *res_ptr = LDKChannelMessageHandler_init(env, clz, o, MessageSendEventsProvider);
12844         return tag_ptr(res_ptr, true);
12845 }
12846 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKChannelMessageHandler_1get_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t arg) {
12847         LDKChannelMessageHandler *inp = (LDKChannelMessageHandler *)untag_ptr(arg);
12848         return tag_ptr(&inp->MessageSendEventsProvider, false);
12849 }
12850 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) {
12851         void* this_arg_ptr = untag_ptr(this_arg);
12852         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
12853         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
12854         LDKPublicKey their_node_id_ref;
12855         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12856         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12857         LDKInitFeatures their_features_conv;
12858         their_features_conv.inner = untag_ptr(their_features);
12859         their_features_conv.is_owned = ptr_is_owned(their_features);
12860         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_conv);
12861         their_features_conv = InitFeatures_clone(&their_features_conv);
12862         LDKOpenChannel msg_conv;
12863         msg_conv.inner = untag_ptr(msg);
12864         msg_conv.is_owned = ptr_is_owned(msg);
12865         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12866         msg_conv.is_owned = false;
12867         (this_arg_conv->handle_open_channel)(this_arg_conv->this_arg, their_node_id_ref, their_features_conv, &msg_conv);
12868 }
12869
12870 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) {
12871         void* this_arg_ptr = untag_ptr(this_arg);
12872         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
12873         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
12874         LDKPublicKey their_node_id_ref;
12875         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12876         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12877         LDKInitFeatures their_features_conv;
12878         their_features_conv.inner = untag_ptr(their_features);
12879         their_features_conv.is_owned = ptr_is_owned(their_features);
12880         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_conv);
12881         their_features_conv = InitFeatures_clone(&their_features_conv);
12882         LDKAcceptChannel msg_conv;
12883         msg_conv.inner = untag_ptr(msg);
12884         msg_conv.is_owned = ptr_is_owned(msg);
12885         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12886         msg_conv.is_owned = false;
12887         (this_arg_conv->handle_accept_channel)(this_arg_conv->this_arg, their_node_id_ref, their_features_conv, &msg_conv);
12888 }
12889
12890 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) {
12891         void* this_arg_ptr = untag_ptr(this_arg);
12892         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
12893         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
12894         LDKPublicKey their_node_id_ref;
12895         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12896         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12897         LDKFundingCreated msg_conv;
12898         msg_conv.inner = untag_ptr(msg);
12899         msg_conv.is_owned = ptr_is_owned(msg);
12900         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12901         msg_conv.is_owned = false;
12902         (this_arg_conv->handle_funding_created)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
12903 }
12904
12905 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) {
12906         void* this_arg_ptr = untag_ptr(this_arg);
12907         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
12908         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
12909         LDKPublicKey their_node_id_ref;
12910         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12911         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12912         LDKFundingSigned msg_conv;
12913         msg_conv.inner = untag_ptr(msg);
12914         msg_conv.is_owned = ptr_is_owned(msg);
12915         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12916         msg_conv.is_owned = false;
12917         (this_arg_conv->handle_funding_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
12918 }
12919
12920 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) {
12921         void* this_arg_ptr = untag_ptr(this_arg);
12922         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
12923         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
12924         LDKPublicKey their_node_id_ref;
12925         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12926         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12927         LDKChannelReady msg_conv;
12928         msg_conv.inner = untag_ptr(msg);
12929         msg_conv.is_owned = ptr_is_owned(msg);
12930         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12931         msg_conv.is_owned = false;
12932         (this_arg_conv->handle_channel_ready)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
12933 }
12934
12935 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) {
12936         void* this_arg_ptr = untag_ptr(this_arg);
12937         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
12938         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
12939         LDKPublicKey their_node_id_ref;
12940         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12941         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12942         LDKInitFeatures their_features_conv;
12943         their_features_conv.inner = untag_ptr(their_features);
12944         their_features_conv.is_owned = ptr_is_owned(their_features);
12945         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_conv);
12946         their_features_conv.is_owned = false;
12947         LDKShutdown msg_conv;
12948         msg_conv.inner = untag_ptr(msg);
12949         msg_conv.is_owned = ptr_is_owned(msg);
12950         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12951         msg_conv.is_owned = false;
12952         (this_arg_conv->handle_shutdown)(this_arg_conv->this_arg, their_node_id_ref, &their_features_conv, &msg_conv);
12953 }
12954
12955 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) {
12956         void* this_arg_ptr = untag_ptr(this_arg);
12957         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
12958         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
12959         LDKPublicKey their_node_id_ref;
12960         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12961         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12962         LDKClosingSigned msg_conv;
12963         msg_conv.inner = untag_ptr(msg);
12964         msg_conv.is_owned = ptr_is_owned(msg);
12965         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12966         msg_conv.is_owned = false;
12967         (this_arg_conv->handle_closing_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
12968 }
12969
12970 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) {
12971         void* this_arg_ptr = untag_ptr(this_arg);
12972         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
12973         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
12974         LDKPublicKey their_node_id_ref;
12975         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12976         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12977         LDKUpdateAddHTLC msg_conv;
12978         msg_conv.inner = untag_ptr(msg);
12979         msg_conv.is_owned = ptr_is_owned(msg);
12980         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12981         msg_conv.is_owned = false;
12982         (this_arg_conv->handle_update_add_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
12983 }
12984
12985 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) {
12986         void* this_arg_ptr = untag_ptr(this_arg);
12987         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
12988         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
12989         LDKPublicKey their_node_id_ref;
12990         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
12991         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
12992         LDKUpdateFulfillHTLC msg_conv;
12993         msg_conv.inner = untag_ptr(msg);
12994         msg_conv.is_owned = ptr_is_owned(msg);
12995         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
12996         msg_conv.is_owned = false;
12997         (this_arg_conv->handle_update_fulfill_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
12998 }
12999
13000 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) {
13001         void* this_arg_ptr = untag_ptr(this_arg);
13002         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13003         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
13004         LDKPublicKey their_node_id_ref;
13005         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
13006         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
13007         LDKUpdateFailHTLC msg_conv;
13008         msg_conv.inner = untag_ptr(msg);
13009         msg_conv.is_owned = ptr_is_owned(msg);
13010         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
13011         msg_conv.is_owned = false;
13012         (this_arg_conv->handle_update_fail_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
13013 }
13014
13015 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) {
13016         void* this_arg_ptr = untag_ptr(this_arg);
13017         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13018         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
13019         LDKPublicKey their_node_id_ref;
13020         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
13021         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
13022         LDKUpdateFailMalformedHTLC msg_conv;
13023         msg_conv.inner = untag_ptr(msg);
13024         msg_conv.is_owned = ptr_is_owned(msg);
13025         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
13026         msg_conv.is_owned = false;
13027         (this_arg_conv->handle_update_fail_malformed_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
13028 }
13029
13030 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) {
13031         void* this_arg_ptr = untag_ptr(this_arg);
13032         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13033         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
13034         LDKPublicKey their_node_id_ref;
13035         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
13036         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
13037         LDKCommitmentSigned msg_conv;
13038         msg_conv.inner = untag_ptr(msg);
13039         msg_conv.is_owned = ptr_is_owned(msg);
13040         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
13041         msg_conv.is_owned = false;
13042         (this_arg_conv->handle_commitment_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
13043 }
13044
13045 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) {
13046         void* this_arg_ptr = untag_ptr(this_arg);
13047         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13048         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
13049         LDKPublicKey their_node_id_ref;
13050         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
13051         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
13052         LDKRevokeAndACK msg_conv;
13053         msg_conv.inner = untag_ptr(msg);
13054         msg_conv.is_owned = ptr_is_owned(msg);
13055         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
13056         msg_conv.is_owned = false;
13057         (this_arg_conv->handle_revoke_and_ack)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
13058 }
13059
13060 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) {
13061         void* this_arg_ptr = untag_ptr(this_arg);
13062         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13063         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
13064         LDKPublicKey their_node_id_ref;
13065         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
13066         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
13067         LDKUpdateFee msg_conv;
13068         msg_conv.inner = untag_ptr(msg);
13069         msg_conv.is_owned = ptr_is_owned(msg);
13070         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
13071         msg_conv.is_owned = false;
13072         (this_arg_conv->handle_update_fee)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
13073 }
13074
13075 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) {
13076         void* this_arg_ptr = untag_ptr(this_arg);
13077         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13078         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
13079         LDKPublicKey their_node_id_ref;
13080         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
13081         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
13082         LDKAnnouncementSignatures msg_conv;
13083         msg_conv.inner = untag_ptr(msg);
13084         msg_conv.is_owned = ptr_is_owned(msg);
13085         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
13086         msg_conv.is_owned = false;
13087         (this_arg_conv->handle_announcement_signatures)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
13088 }
13089
13090 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) {
13091         void* this_arg_ptr = untag_ptr(this_arg);
13092         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13093         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
13094         LDKPublicKey their_node_id_ref;
13095         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
13096         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
13097         (this_arg_conv->peer_disconnected)(this_arg_conv->this_arg, their_node_id_ref, no_connection_possible);
13098 }
13099
13100 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) {
13101         void* this_arg_ptr = untag_ptr(this_arg);
13102         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13103         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
13104         LDKPublicKey their_node_id_ref;
13105         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
13106         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
13107         LDKInit msg_conv;
13108         msg_conv.inner = untag_ptr(msg);
13109         msg_conv.is_owned = ptr_is_owned(msg);
13110         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
13111         msg_conv.is_owned = false;
13112         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
13113         *ret_conv = (this_arg_conv->peer_connected)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
13114         return tag_ptr(ret_conv, true);
13115 }
13116
13117 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) {
13118         void* this_arg_ptr = untag_ptr(this_arg);
13119         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13120         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
13121         LDKPublicKey their_node_id_ref;
13122         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
13123         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
13124         LDKChannelReestablish msg_conv;
13125         msg_conv.inner = untag_ptr(msg);
13126         msg_conv.is_owned = ptr_is_owned(msg);
13127         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
13128         msg_conv.is_owned = false;
13129         (this_arg_conv->handle_channel_reestablish)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
13130 }
13131
13132 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) {
13133         void* this_arg_ptr = untag_ptr(this_arg);
13134         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13135         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
13136         LDKPublicKey their_node_id_ref;
13137         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
13138         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
13139         LDKChannelUpdate msg_conv;
13140         msg_conv.inner = untag_ptr(msg);
13141         msg_conv.is_owned = ptr_is_owned(msg);
13142         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
13143         msg_conv.is_owned = false;
13144         (this_arg_conv->handle_channel_update)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
13145 }
13146
13147 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) {
13148         void* this_arg_ptr = untag_ptr(this_arg);
13149         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13150         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
13151         LDKPublicKey their_node_id_ref;
13152         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
13153         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
13154         LDKErrorMessage msg_conv;
13155         msg_conv.inner = untag_ptr(msg);
13156         msg_conv.is_owned = ptr_is_owned(msg);
13157         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
13158         msg_conv.is_owned = false;
13159         (this_arg_conv->handle_error)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
13160 }
13161
13162 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1provided_1node_1features(JNIEnv *env, jclass clz, int64_t this_arg) {
13163         void* this_arg_ptr = untag_ptr(this_arg);
13164         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13165         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
13166         LDKNodeFeatures ret_var = (this_arg_conv->provided_node_features)(this_arg_conv->this_arg);
13167         int64_t ret_ref = 0;
13168         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
13169         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
13170         return ret_ref;
13171 }
13172
13173 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) {
13174         void* this_arg_ptr = untag_ptr(this_arg);
13175         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13176         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
13177         LDKPublicKey their_node_id_ref;
13178         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
13179         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
13180         LDKInitFeatures ret_var = (this_arg_conv->provided_init_features)(this_arg_conv->this_arg, their_node_id_ref);
13181         int64_t ret_ref = 0;
13182         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
13183         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
13184         return ret_ref;
13185 }
13186
13187 typedef struct LDKRoutingMessageHandler_JCalls {
13188         atomic_size_t refcnt;
13189         JavaVM *vm;
13190         jweak o;
13191         LDKMessageSendEventsProvider_JCalls* MessageSendEventsProvider;
13192         jmethodID handle_node_announcement_meth;
13193         jmethodID handle_channel_announcement_meth;
13194         jmethodID handle_channel_update_meth;
13195         jmethodID get_next_channel_announcement_meth;
13196         jmethodID get_next_node_announcement_meth;
13197         jmethodID peer_connected_meth;
13198         jmethodID handle_reply_channel_range_meth;
13199         jmethodID handle_reply_short_channel_ids_end_meth;
13200         jmethodID handle_query_channel_range_meth;
13201         jmethodID handle_query_short_channel_ids_meth;
13202         jmethodID provided_node_features_meth;
13203         jmethodID provided_init_features_meth;
13204 } LDKRoutingMessageHandler_JCalls;
13205 static void LDKRoutingMessageHandler_JCalls_free(void* this_arg) {
13206         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
13207         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
13208                 JNIEnv *env;
13209                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13210                 if (get_jenv_res == JNI_EDETACHED) {
13211                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13212                 } else {
13213                         DO_ASSERT(get_jenv_res == JNI_OK);
13214                 }
13215                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
13216                 if (get_jenv_res == JNI_EDETACHED) {
13217                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13218                 }
13219                 FREE(j_calls);
13220         }
13221 }
13222 LDKCResult_boolLightningErrorZ handle_node_announcement_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKNodeAnnouncement * msg) {
13223         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
13224         JNIEnv *env;
13225         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13226         if (get_jenv_res == JNI_EDETACHED) {
13227                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13228         } else {
13229                 DO_ASSERT(get_jenv_res == JNI_OK);
13230         }
13231         LDKNodeAnnouncement msg_var = *msg;
13232         int64_t msg_ref = 0;
13233         msg_var = NodeAnnouncement_clone(&msg_var);
13234         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
13235         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
13236         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13237         CHECK(obj != NULL);
13238         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_node_announcement_meth, msg_ref);
13239         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13240                 (*env)->ExceptionDescribe(env);
13241                 (*env)->FatalError(env, "A call to handle_node_announcement in LDKRoutingMessageHandler from rust threw an exception.");
13242         }
13243         void* ret_ptr = untag_ptr(ret);
13244         CHECK_ACCESS(ret_ptr);
13245         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(ret_ptr);
13246         FREE(untag_ptr(ret));
13247         if (get_jenv_res == JNI_EDETACHED) {
13248                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13249         }
13250         return ret_conv;
13251 }
13252 LDKCResult_boolLightningErrorZ handle_channel_announcement_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKChannelAnnouncement * msg) {
13253         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
13254         JNIEnv *env;
13255         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13256         if (get_jenv_res == JNI_EDETACHED) {
13257                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13258         } else {
13259                 DO_ASSERT(get_jenv_res == JNI_OK);
13260         }
13261         LDKChannelAnnouncement msg_var = *msg;
13262         int64_t msg_ref = 0;
13263         msg_var = ChannelAnnouncement_clone(&msg_var);
13264         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
13265         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
13266         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13267         CHECK(obj != NULL);
13268         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_channel_announcement_meth, msg_ref);
13269         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13270                 (*env)->ExceptionDescribe(env);
13271                 (*env)->FatalError(env, "A call to handle_channel_announcement in LDKRoutingMessageHandler from rust threw an exception.");
13272         }
13273         void* ret_ptr = untag_ptr(ret);
13274         CHECK_ACCESS(ret_ptr);
13275         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(ret_ptr);
13276         FREE(untag_ptr(ret));
13277         if (get_jenv_res == JNI_EDETACHED) {
13278                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13279         }
13280         return ret_conv;
13281 }
13282 LDKCResult_boolLightningErrorZ handle_channel_update_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKChannelUpdate * msg) {
13283         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
13284         JNIEnv *env;
13285         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13286         if (get_jenv_res == JNI_EDETACHED) {
13287                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13288         } else {
13289                 DO_ASSERT(get_jenv_res == JNI_OK);
13290         }
13291         LDKChannelUpdate msg_var = *msg;
13292         int64_t msg_ref = 0;
13293         msg_var = ChannelUpdate_clone(&msg_var);
13294         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
13295         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
13296         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13297         CHECK(obj != NULL);
13298         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_channel_update_meth, msg_ref);
13299         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13300                 (*env)->ExceptionDescribe(env);
13301                 (*env)->FatalError(env, "A call to handle_channel_update in LDKRoutingMessageHandler from rust threw an exception.");
13302         }
13303         void* ret_ptr = untag_ptr(ret);
13304         CHECK_ACCESS(ret_ptr);
13305         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(ret_ptr);
13306         FREE(untag_ptr(ret));
13307         if (get_jenv_res == JNI_EDETACHED) {
13308                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13309         }
13310         return ret_conv;
13311 }
13312 LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ get_next_channel_announcement_LDKRoutingMessageHandler_jcall(const void* this_arg, uint64_t starting_point) {
13313         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
13314         JNIEnv *env;
13315         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13316         if (get_jenv_res == JNI_EDETACHED) {
13317                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13318         } else {
13319                 DO_ASSERT(get_jenv_res == JNI_OK);
13320         }
13321         int64_t starting_point_conv = starting_point;
13322         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13323         CHECK(obj != NULL);
13324         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->get_next_channel_announcement_meth, starting_point_conv);
13325         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13326                 (*env)->ExceptionDescribe(env);
13327                 (*env)->FatalError(env, "A call to get_next_channel_announcement in LDKRoutingMessageHandler from rust threw an exception.");
13328         }
13329         void* ret_ptr = untag_ptr(ret);
13330         CHECK_ACCESS(ret_ptr);
13331         LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret_conv = *(LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ*)(ret_ptr);
13332         FREE(untag_ptr(ret));
13333         if (get_jenv_res == JNI_EDETACHED) {
13334                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13335         }
13336         return ret_conv;
13337 }
13338 LDKNodeAnnouncement get_next_node_announcement_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey starting_point) {
13339         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
13340         JNIEnv *env;
13341         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13342         if (get_jenv_res == JNI_EDETACHED) {
13343                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13344         } else {
13345                 DO_ASSERT(get_jenv_res == JNI_OK);
13346         }
13347         int8_tArray starting_point_arr = (*env)->NewByteArray(env, 33);
13348         (*env)->SetByteArrayRegion(env, starting_point_arr, 0, 33, starting_point.compressed_form);
13349         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13350         CHECK(obj != NULL);
13351         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->get_next_node_announcement_meth, starting_point_arr);
13352         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13353                 (*env)->ExceptionDescribe(env);
13354                 (*env)->FatalError(env, "A call to get_next_node_announcement in LDKRoutingMessageHandler from rust threw an exception.");
13355         }
13356         LDKNodeAnnouncement ret_conv;
13357         ret_conv.inner = untag_ptr(ret);
13358         ret_conv.is_owned = ptr_is_owned(ret);
13359         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv);
13360         if (get_jenv_res == JNI_EDETACHED) {
13361                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13362         }
13363         return ret_conv;
13364 }
13365 LDKCResult_NoneNoneZ peer_connected_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInit * init) {
13366         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
13367         JNIEnv *env;
13368         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13369         if (get_jenv_res == JNI_EDETACHED) {
13370                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13371         } else {
13372                 DO_ASSERT(get_jenv_res == JNI_OK);
13373         }
13374         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
13375         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
13376         LDKInit init_var = *init;
13377         int64_t init_ref = 0;
13378         init_var = Init_clone(&init_var);
13379         CHECK_INNER_FIELD_ACCESS_OR_NULL(init_var);
13380         init_ref = tag_ptr(init_var.inner, init_var.is_owned);
13381         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13382         CHECK(obj != NULL);
13383         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->peer_connected_meth, their_node_id_arr, init_ref);
13384         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13385                 (*env)->ExceptionDescribe(env);
13386                 (*env)->FatalError(env, "A call to peer_connected in LDKRoutingMessageHandler from rust threw an exception.");
13387         }
13388         void* ret_ptr = untag_ptr(ret);
13389         CHECK_ACCESS(ret_ptr);
13390         LDKCResult_NoneNoneZ ret_conv = *(LDKCResult_NoneNoneZ*)(ret_ptr);
13391         FREE(untag_ptr(ret));
13392         if (get_jenv_res == JNI_EDETACHED) {
13393                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13394         }
13395         return ret_conv;
13396 }
13397 LDKCResult_NoneLightningErrorZ handle_reply_channel_range_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKReplyChannelRange msg) {
13398         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
13399         JNIEnv *env;
13400         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13401         if (get_jenv_res == JNI_EDETACHED) {
13402                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13403         } else {
13404                 DO_ASSERT(get_jenv_res == JNI_OK);
13405         }
13406         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
13407         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
13408         LDKReplyChannelRange msg_var = msg;
13409         int64_t msg_ref = 0;
13410         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
13411         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
13412         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13413         CHECK(obj != NULL);
13414         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_reply_channel_range_meth, their_node_id_arr, msg_ref);
13415         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13416                 (*env)->ExceptionDescribe(env);
13417                 (*env)->FatalError(env, "A call to handle_reply_channel_range in LDKRoutingMessageHandler from rust threw an exception.");
13418         }
13419         void* ret_ptr = untag_ptr(ret);
13420         CHECK_ACCESS(ret_ptr);
13421         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
13422         FREE(untag_ptr(ret));
13423         if (get_jenv_res == JNI_EDETACHED) {
13424                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13425         }
13426         return ret_conv;
13427 }
13428 LDKCResult_NoneLightningErrorZ handle_reply_short_channel_ids_end_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKReplyShortChannelIdsEnd msg) {
13429         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
13430         JNIEnv *env;
13431         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13432         if (get_jenv_res == JNI_EDETACHED) {
13433                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13434         } else {
13435                 DO_ASSERT(get_jenv_res == JNI_OK);
13436         }
13437         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
13438         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
13439         LDKReplyShortChannelIdsEnd msg_var = msg;
13440         int64_t msg_ref = 0;
13441         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
13442         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
13443         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13444         CHECK(obj != NULL);
13445         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_reply_short_channel_ids_end_meth, their_node_id_arr, msg_ref);
13446         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13447                 (*env)->ExceptionDescribe(env);
13448                 (*env)->FatalError(env, "A call to handle_reply_short_channel_ids_end in LDKRoutingMessageHandler from rust threw an exception.");
13449         }
13450         void* ret_ptr = untag_ptr(ret);
13451         CHECK_ACCESS(ret_ptr);
13452         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
13453         FREE(untag_ptr(ret));
13454         if (get_jenv_res == JNI_EDETACHED) {
13455                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13456         }
13457         return ret_conv;
13458 }
13459 LDKCResult_NoneLightningErrorZ handle_query_channel_range_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKQueryChannelRange msg) {
13460         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
13461         JNIEnv *env;
13462         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13463         if (get_jenv_res == JNI_EDETACHED) {
13464                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13465         } else {
13466                 DO_ASSERT(get_jenv_res == JNI_OK);
13467         }
13468         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
13469         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
13470         LDKQueryChannelRange msg_var = msg;
13471         int64_t msg_ref = 0;
13472         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
13473         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
13474         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13475         CHECK(obj != NULL);
13476         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_query_channel_range_meth, their_node_id_arr, msg_ref);
13477         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13478                 (*env)->ExceptionDescribe(env);
13479                 (*env)->FatalError(env, "A call to handle_query_channel_range in LDKRoutingMessageHandler from rust threw an exception.");
13480         }
13481         void* ret_ptr = untag_ptr(ret);
13482         CHECK_ACCESS(ret_ptr);
13483         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
13484         FREE(untag_ptr(ret));
13485         if (get_jenv_res == JNI_EDETACHED) {
13486                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13487         }
13488         return ret_conv;
13489 }
13490 LDKCResult_NoneLightningErrorZ handle_query_short_channel_ids_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKQueryShortChannelIds msg) {
13491         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
13492         JNIEnv *env;
13493         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13494         if (get_jenv_res == JNI_EDETACHED) {
13495                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13496         } else {
13497                 DO_ASSERT(get_jenv_res == JNI_OK);
13498         }
13499         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
13500         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
13501         LDKQueryShortChannelIds msg_var = msg;
13502         int64_t msg_ref = 0;
13503         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
13504         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
13505         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13506         CHECK(obj != NULL);
13507         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_query_short_channel_ids_meth, their_node_id_arr, msg_ref);
13508         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13509                 (*env)->ExceptionDescribe(env);
13510                 (*env)->FatalError(env, "A call to handle_query_short_channel_ids in LDKRoutingMessageHandler from rust threw an exception.");
13511         }
13512         void* ret_ptr = untag_ptr(ret);
13513         CHECK_ACCESS(ret_ptr);
13514         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
13515         FREE(untag_ptr(ret));
13516         if (get_jenv_res == JNI_EDETACHED) {
13517                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13518         }
13519         return ret_conv;
13520 }
13521 LDKNodeFeatures provided_node_features_LDKRoutingMessageHandler_jcall(const void* this_arg) {
13522         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
13523         JNIEnv *env;
13524         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13525         if (get_jenv_res == JNI_EDETACHED) {
13526                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13527         } else {
13528                 DO_ASSERT(get_jenv_res == JNI_OK);
13529         }
13530         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13531         CHECK(obj != NULL);
13532         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->provided_node_features_meth);
13533         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13534                 (*env)->ExceptionDescribe(env);
13535                 (*env)->FatalError(env, "A call to provided_node_features in LDKRoutingMessageHandler from rust threw an exception.");
13536         }
13537         LDKNodeFeatures ret_conv;
13538         ret_conv.inner = untag_ptr(ret);
13539         ret_conv.is_owned = ptr_is_owned(ret);
13540         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv);
13541         if (get_jenv_res == JNI_EDETACHED) {
13542                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13543         }
13544         return ret_conv;
13545 }
13546 LDKInitFeatures provided_init_features_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id) {
13547         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
13548         JNIEnv *env;
13549         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13550         if (get_jenv_res == JNI_EDETACHED) {
13551                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13552         } else {
13553                 DO_ASSERT(get_jenv_res == JNI_OK);
13554         }
13555         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
13556         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
13557         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13558         CHECK(obj != NULL);
13559         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->provided_init_features_meth, their_node_id_arr);
13560         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13561                 (*env)->ExceptionDescribe(env);
13562                 (*env)->FatalError(env, "A call to provided_init_features in LDKRoutingMessageHandler from rust threw an exception.");
13563         }
13564         LDKInitFeatures ret_conv;
13565         ret_conv.inner = untag_ptr(ret);
13566         ret_conv.is_owned = ptr_is_owned(ret);
13567         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv);
13568         if (get_jenv_res == JNI_EDETACHED) {
13569                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13570         }
13571         return ret_conv;
13572 }
13573 static void LDKRoutingMessageHandler_JCalls_cloned(LDKRoutingMessageHandler* new_obj) {
13574         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) new_obj->this_arg;
13575         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
13576         atomic_fetch_add_explicit(&j_calls->MessageSendEventsProvider->refcnt, 1, memory_order_release);
13577 }
13578 static inline LDKRoutingMessageHandler LDKRoutingMessageHandler_init (JNIEnv *env, jclass clz, jobject o, jobject MessageSendEventsProvider) {
13579         jclass c = (*env)->GetObjectClass(env, o);
13580         CHECK(c != NULL);
13581         LDKRoutingMessageHandler_JCalls *calls = MALLOC(sizeof(LDKRoutingMessageHandler_JCalls), "LDKRoutingMessageHandler_JCalls");
13582         atomic_init(&calls->refcnt, 1);
13583         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
13584         calls->o = (*env)->NewWeakGlobalRef(env, o);
13585         calls->handle_node_announcement_meth = (*env)->GetMethodID(env, c, "handle_node_announcement", "(J)J");
13586         CHECK(calls->handle_node_announcement_meth != NULL);
13587         calls->handle_channel_announcement_meth = (*env)->GetMethodID(env, c, "handle_channel_announcement", "(J)J");
13588         CHECK(calls->handle_channel_announcement_meth != NULL);
13589         calls->handle_channel_update_meth = (*env)->GetMethodID(env, c, "handle_channel_update", "(J)J");
13590         CHECK(calls->handle_channel_update_meth != NULL);
13591         calls->get_next_channel_announcement_meth = (*env)->GetMethodID(env, c, "get_next_channel_announcement", "(J)J");
13592         CHECK(calls->get_next_channel_announcement_meth != NULL);
13593         calls->get_next_node_announcement_meth = (*env)->GetMethodID(env, c, "get_next_node_announcement", "([B)J");
13594         CHECK(calls->get_next_node_announcement_meth != NULL);
13595         calls->peer_connected_meth = (*env)->GetMethodID(env, c, "peer_connected", "([BJ)J");
13596         CHECK(calls->peer_connected_meth != NULL);
13597         calls->handle_reply_channel_range_meth = (*env)->GetMethodID(env, c, "handle_reply_channel_range", "([BJ)J");
13598         CHECK(calls->handle_reply_channel_range_meth != NULL);
13599         calls->handle_reply_short_channel_ids_end_meth = (*env)->GetMethodID(env, c, "handle_reply_short_channel_ids_end", "([BJ)J");
13600         CHECK(calls->handle_reply_short_channel_ids_end_meth != NULL);
13601         calls->handle_query_channel_range_meth = (*env)->GetMethodID(env, c, "handle_query_channel_range", "([BJ)J");
13602         CHECK(calls->handle_query_channel_range_meth != NULL);
13603         calls->handle_query_short_channel_ids_meth = (*env)->GetMethodID(env, c, "handle_query_short_channel_ids", "([BJ)J");
13604         CHECK(calls->handle_query_short_channel_ids_meth != NULL);
13605         calls->provided_node_features_meth = (*env)->GetMethodID(env, c, "provided_node_features", "()J");
13606         CHECK(calls->provided_node_features_meth != NULL);
13607         calls->provided_init_features_meth = (*env)->GetMethodID(env, c, "provided_init_features", "([B)J");
13608         CHECK(calls->provided_init_features_meth != NULL);
13609
13610         LDKRoutingMessageHandler ret = {
13611                 .this_arg = (void*) calls,
13612                 .handle_node_announcement = handle_node_announcement_LDKRoutingMessageHandler_jcall,
13613                 .handle_channel_announcement = handle_channel_announcement_LDKRoutingMessageHandler_jcall,
13614                 .handle_channel_update = handle_channel_update_LDKRoutingMessageHandler_jcall,
13615                 .get_next_channel_announcement = get_next_channel_announcement_LDKRoutingMessageHandler_jcall,
13616                 .get_next_node_announcement = get_next_node_announcement_LDKRoutingMessageHandler_jcall,
13617                 .peer_connected = peer_connected_LDKRoutingMessageHandler_jcall,
13618                 .handle_reply_channel_range = handle_reply_channel_range_LDKRoutingMessageHandler_jcall,
13619                 .handle_reply_short_channel_ids_end = handle_reply_short_channel_ids_end_LDKRoutingMessageHandler_jcall,
13620                 .handle_query_channel_range = handle_query_channel_range_LDKRoutingMessageHandler_jcall,
13621                 .handle_query_short_channel_ids = handle_query_short_channel_ids_LDKRoutingMessageHandler_jcall,
13622                 .provided_node_features = provided_node_features_LDKRoutingMessageHandler_jcall,
13623                 .provided_init_features = provided_init_features_LDKRoutingMessageHandler_jcall,
13624                 .free = LDKRoutingMessageHandler_JCalls_free,
13625                 .MessageSendEventsProvider = LDKMessageSendEventsProvider_init(env, clz, MessageSendEventsProvider),
13626         };
13627         calls->MessageSendEventsProvider = ret.MessageSendEventsProvider.this_arg;
13628         return ret;
13629 }
13630 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKRoutingMessageHandler_1new(JNIEnv *env, jclass clz, jobject o, jobject MessageSendEventsProvider) {
13631         LDKRoutingMessageHandler *res_ptr = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
13632         *res_ptr = LDKRoutingMessageHandler_init(env, clz, o, MessageSendEventsProvider);
13633         return tag_ptr(res_ptr, true);
13634 }
13635 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKRoutingMessageHandler_1get_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t arg) {
13636         LDKRoutingMessageHandler *inp = (LDKRoutingMessageHandler *)untag_ptr(arg);
13637         return tag_ptr(&inp->MessageSendEventsProvider, false);
13638 }
13639 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1handle_1node_1announcement(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
13640         void* this_arg_ptr = untag_ptr(this_arg);
13641         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13642         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
13643         LDKNodeAnnouncement msg_conv;
13644         msg_conv.inner = untag_ptr(msg);
13645         msg_conv.is_owned = ptr_is_owned(msg);
13646         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
13647         msg_conv.is_owned = false;
13648         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
13649         *ret_conv = (this_arg_conv->handle_node_announcement)(this_arg_conv->this_arg, &msg_conv);
13650         return tag_ptr(ret_conv, true);
13651 }
13652
13653 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1handle_1channel_1announcement(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
13654         void* this_arg_ptr = untag_ptr(this_arg);
13655         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13656         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
13657         LDKChannelAnnouncement msg_conv;
13658         msg_conv.inner = untag_ptr(msg);
13659         msg_conv.is_owned = ptr_is_owned(msg);
13660         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
13661         msg_conv.is_owned = false;
13662         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
13663         *ret_conv = (this_arg_conv->handle_channel_announcement)(this_arg_conv->this_arg, &msg_conv);
13664         return tag_ptr(ret_conv, true);
13665 }
13666
13667 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1handle_1channel_1update(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
13668         void* this_arg_ptr = untag_ptr(this_arg);
13669         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13670         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
13671         LDKChannelUpdate msg_conv;
13672         msg_conv.inner = untag_ptr(msg);
13673         msg_conv.is_owned = ptr_is_owned(msg);
13674         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
13675         msg_conv.is_owned = false;
13676         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
13677         *ret_conv = (this_arg_conv->handle_channel_update)(this_arg_conv->this_arg, &msg_conv);
13678         return tag_ptr(ret_conv, true);
13679 }
13680
13681 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) {
13682         void* this_arg_ptr = untag_ptr(this_arg);
13683         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13684         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
13685         LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ *ret_copy = MALLOC(sizeof(LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ), "LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ");
13686         *ret_copy = (this_arg_conv->get_next_channel_announcement)(this_arg_conv->this_arg, starting_point);
13687         int64_t ret_ref = tag_ptr(ret_copy, true);
13688         return ret_ref;
13689 }
13690
13691 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) {
13692         void* this_arg_ptr = untag_ptr(this_arg);
13693         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13694         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
13695         LDKPublicKey starting_point_ref;
13696         CHECK((*env)->GetArrayLength(env, starting_point) == 33);
13697         (*env)->GetByteArrayRegion(env, starting_point, 0, 33, starting_point_ref.compressed_form);
13698         LDKNodeAnnouncement ret_var = (this_arg_conv->get_next_node_announcement)(this_arg_conv->this_arg, starting_point_ref);
13699         int64_t ret_ref = 0;
13700         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
13701         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
13702         return ret_ref;
13703 }
13704
13705 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) {
13706         void* this_arg_ptr = untag_ptr(this_arg);
13707         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13708         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
13709         LDKPublicKey their_node_id_ref;
13710         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
13711         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
13712         LDKInit init_conv;
13713         init_conv.inner = untag_ptr(init);
13714         init_conv.is_owned = ptr_is_owned(init);
13715         CHECK_INNER_FIELD_ACCESS_OR_NULL(init_conv);
13716         init_conv.is_owned = false;
13717         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
13718         *ret_conv = (this_arg_conv->peer_connected)(this_arg_conv->this_arg, their_node_id_ref, &init_conv);
13719         return tag_ptr(ret_conv, true);
13720 }
13721
13722 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) {
13723         void* this_arg_ptr = untag_ptr(this_arg);
13724         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13725         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
13726         LDKPublicKey their_node_id_ref;
13727         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
13728         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
13729         LDKReplyChannelRange msg_conv;
13730         msg_conv.inner = untag_ptr(msg);
13731         msg_conv.is_owned = ptr_is_owned(msg);
13732         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
13733         msg_conv = ReplyChannelRange_clone(&msg_conv);
13734         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
13735         *ret_conv = (this_arg_conv->handle_reply_channel_range)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
13736         return tag_ptr(ret_conv, true);
13737 }
13738
13739 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) {
13740         void* this_arg_ptr = untag_ptr(this_arg);
13741         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13742         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
13743         LDKPublicKey their_node_id_ref;
13744         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
13745         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
13746         LDKReplyShortChannelIdsEnd msg_conv;
13747         msg_conv.inner = untag_ptr(msg);
13748         msg_conv.is_owned = ptr_is_owned(msg);
13749         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
13750         msg_conv = ReplyShortChannelIdsEnd_clone(&msg_conv);
13751         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
13752         *ret_conv = (this_arg_conv->handle_reply_short_channel_ids_end)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
13753         return tag_ptr(ret_conv, true);
13754 }
13755
13756 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) {
13757         void* this_arg_ptr = untag_ptr(this_arg);
13758         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13759         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
13760         LDKPublicKey their_node_id_ref;
13761         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
13762         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
13763         LDKQueryChannelRange msg_conv;
13764         msg_conv.inner = untag_ptr(msg);
13765         msg_conv.is_owned = ptr_is_owned(msg);
13766         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
13767         msg_conv = QueryChannelRange_clone(&msg_conv);
13768         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
13769         *ret_conv = (this_arg_conv->handle_query_channel_range)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
13770         return tag_ptr(ret_conv, true);
13771 }
13772
13773 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) {
13774         void* this_arg_ptr = untag_ptr(this_arg);
13775         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
13776         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
13777         LDKPublicKey their_node_id_ref;
13778         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
13779         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
13780         LDKQueryShortChannelIds msg_conv;
13781         msg_conv.inner = untag_ptr(msg);
13782         msg_conv.is_owned = ptr_is_owned(msg);
13783         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
13784         msg_conv = QueryShortChannelIds_clone(&msg_conv);
13785         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
13786         *ret_conv = (this_arg_conv->handle_query_short_channel_ids)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
13787         return tag_ptr(ret_conv, true);
13788 }
13789
13790 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_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         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)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_RoutingMessageHandler_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         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)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 LDKOnionMessageHandler_JCalls {
13816         atomic_size_t refcnt;
13817         JavaVM *vm;
13818         jweak o;
13819         LDKOnionMessageProvider_JCalls* OnionMessageProvider;
13820         jmethodID handle_onion_message_meth;
13821         jmethodID peer_connected_meth;
13822         jmethodID peer_disconnected_meth;
13823         jmethodID provided_node_features_meth;
13824         jmethodID provided_init_features_meth;
13825 } LDKOnionMessageHandler_JCalls;
13826 static void LDKOnionMessageHandler_JCalls_free(void* this_arg) {
13827         LDKOnionMessageHandler_JCalls *j_calls = (LDKOnionMessageHandler_JCalls*) this_arg;
13828         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
13829                 JNIEnv *env;
13830                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13831                 if (get_jenv_res == JNI_EDETACHED) {
13832                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13833                 } else {
13834                         DO_ASSERT(get_jenv_res == JNI_OK);
13835                 }
13836                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
13837                 if (get_jenv_res == JNI_EDETACHED) {
13838                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13839                 }
13840                 FREE(j_calls);
13841         }
13842 }
13843 void handle_onion_message_LDKOnionMessageHandler_jcall(const void* this_arg, LDKPublicKey peer_node_id, const LDKOnionMessage * msg) {
13844         LDKOnionMessageHandler_JCalls *j_calls = (LDKOnionMessageHandler_JCalls*) this_arg;
13845         JNIEnv *env;
13846         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13847         if (get_jenv_res == JNI_EDETACHED) {
13848                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13849         } else {
13850                 DO_ASSERT(get_jenv_res == JNI_OK);
13851         }
13852         int8_tArray peer_node_id_arr = (*env)->NewByteArray(env, 33);
13853         (*env)->SetByteArrayRegion(env, peer_node_id_arr, 0, 33, peer_node_id.compressed_form);
13854         LDKOnionMessage msg_var = *msg;
13855         int64_t msg_ref = 0;
13856         msg_var = OnionMessage_clone(&msg_var);
13857         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
13858         msg_ref = tag_ptr(msg_var.inner, msg_var.is_owned);
13859         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13860         CHECK(obj != NULL);
13861         (*env)->CallVoidMethod(env, obj, j_calls->handle_onion_message_meth, peer_node_id_arr, msg_ref);
13862         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13863                 (*env)->ExceptionDescribe(env);
13864                 (*env)->FatalError(env, "A call to handle_onion_message in LDKOnionMessageHandler from rust threw an exception.");
13865         }
13866         if (get_jenv_res == JNI_EDETACHED) {
13867                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13868         }
13869 }
13870 LDKCResult_NoneNoneZ peer_connected_LDKOnionMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInit * init) {
13871         LDKOnionMessageHandler_JCalls *j_calls = (LDKOnionMessageHandler_JCalls*) this_arg;
13872         JNIEnv *env;
13873         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13874         if (get_jenv_res == JNI_EDETACHED) {
13875                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13876         } else {
13877                 DO_ASSERT(get_jenv_res == JNI_OK);
13878         }
13879         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
13880         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
13881         LDKInit init_var = *init;
13882         int64_t init_ref = 0;
13883         init_var = Init_clone(&init_var);
13884         CHECK_INNER_FIELD_ACCESS_OR_NULL(init_var);
13885         init_ref = tag_ptr(init_var.inner, init_var.is_owned);
13886         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13887         CHECK(obj != NULL);
13888         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->peer_connected_meth, their_node_id_arr, init_ref);
13889         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13890                 (*env)->ExceptionDescribe(env);
13891                 (*env)->FatalError(env, "A call to peer_connected in LDKOnionMessageHandler from rust threw an exception.");
13892         }
13893         void* ret_ptr = untag_ptr(ret);
13894         CHECK_ACCESS(ret_ptr);
13895         LDKCResult_NoneNoneZ ret_conv = *(LDKCResult_NoneNoneZ*)(ret_ptr);
13896         FREE(untag_ptr(ret));
13897         if (get_jenv_res == JNI_EDETACHED) {
13898                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13899         }
13900         return ret_conv;
13901 }
13902 void peer_disconnected_LDKOnionMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, bool no_connection_possible) {
13903         LDKOnionMessageHandler_JCalls *j_calls = (LDKOnionMessageHandler_JCalls*) this_arg;
13904         JNIEnv *env;
13905         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13906         if (get_jenv_res == JNI_EDETACHED) {
13907                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13908         } else {
13909                 DO_ASSERT(get_jenv_res == JNI_OK);
13910         }
13911         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
13912         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
13913         jboolean no_connection_possible_conv = no_connection_possible;
13914         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13915         CHECK(obj != NULL);
13916         (*env)->CallVoidMethod(env, obj, j_calls->peer_disconnected_meth, their_node_id_arr, no_connection_possible_conv);
13917         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13918                 (*env)->ExceptionDescribe(env);
13919                 (*env)->FatalError(env, "A call to peer_disconnected in LDKOnionMessageHandler from rust threw an exception.");
13920         }
13921         if (get_jenv_res == JNI_EDETACHED) {
13922                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13923         }
13924 }
13925 LDKNodeFeatures provided_node_features_LDKOnionMessageHandler_jcall(const void* this_arg) {
13926         LDKOnionMessageHandler_JCalls *j_calls = (LDKOnionMessageHandler_JCalls*) this_arg;
13927         JNIEnv *env;
13928         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13929         if (get_jenv_res == JNI_EDETACHED) {
13930                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13931         } else {
13932                 DO_ASSERT(get_jenv_res == JNI_OK);
13933         }
13934         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13935         CHECK(obj != NULL);
13936         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->provided_node_features_meth);
13937         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13938                 (*env)->ExceptionDescribe(env);
13939                 (*env)->FatalError(env, "A call to provided_node_features in LDKOnionMessageHandler from rust threw an exception.");
13940         }
13941         LDKNodeFeatures ret_conv;
13942         ret_conv.inner = untag_ptr(ret);
13943         ret_conv.is_owned = ptr_is_owned(ret);
13944         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv);
13945         if (get_jenv_res == JNI_EDETACHED) {
13946                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13947         }
13948         return ret_conv;
13949 }
13950 LDKInitFeatures provided_init_features_LDKOnionMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id) {
13951         LDKOnionMessageHandler_JCalls *j_calls = (LDKOnionMessageHandler_JCalls*) this_arg;
13952         JNIEnv *env;
13953         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
13954         if (get_jenv_res == JNI_EDETACHED) {
13955                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
13956         } else {
13957                 DO_ASSERT(get_jenv_res == JNI_OK);
13958         }
13959         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
13960         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
13961         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
13962         CHECK(obj != NULL);
13963         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->provided_init_features_meth, their_node_id_arr);
13964         if (UNLIKELY((*env)->ExceptionCheck(env))) {
13965                 (*env)->ExceptionDescribe(env);
13966                 (*env)->FatalError(env, "A call to provided_init_features in LDKOnionMessageHandler from rust threw an exception.");
13967         }
13968         LDKInitFeatures ret_conv;
13969         ret_conv.inner = untag_ptr(ret);
13970         ret_conv.is_owned = ptr_is_owned(ret);
13971         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv);
13972         if (get_jenv_res == JNI_EDETACHED) {
13973                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
13974         }
13975         return ret_conv;
13976 }
13977 static void LDKOnionMessageHandler_JCalls_cloned(LDKOnionMessageHandler* new_obj) {
13978         LDKOnionMessageHandler_JCalls *j_calls = (LDKOnionMessageHandler_JCalls*) new_obj->this_arg;
13979         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
13980         atomic_fetch_add_explicit(&j_calls->OnionMessageProvider->refcnt, 1, memory_order_release);
13981 }
13982 static inline LDKOnionMessageHandler LDKOnionMessageHandler_init (JNIEnv *env, jclass clz, jobject o, jobject OnionMessageProvider) {
13983         jclass c = (*env)->GetObjectClass(env, o);
13984         CHECK(c != NULL);
13985         LDKOnionMessageHandler_JCalls *calls = MALLOC(sizeof(LDKOnionMessageHandler_JCalls), "LDKOnionMessageHandler_JCalls");
13986         atomic_init(&calls->refcnt, 1);
13987         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
13988         calls->o = (*env)->NewWeakGlobalRef(env, o);
13989         calls->handle_onion_message_meth = (*env)->GetMethodID(env, c, "handle_onion_message", "([BJ)V");
13990         CHECK(calls->handle_onion_message_meth != NULL);
13991         calls->peer_connected_meth = (*env)->GetMethodID(env, c, "peer_connected", "([BJ)J");
13992         CHECK(calls->peer_connected_meth != NULL);
13993         calls->peer_disconnected_meth = (*env)->GetMethodID(env, c, "peer_disconnected", "([BZ)V");
13994         CHECK(calls->peer_disconnected_meth != NULL);
13995         calls->provided_node_features_meth = (*env)->GetMethodID(env, c, "provided_node_features", "()J");
13996         CHECK(calls->provided_node_features_meth != NULL);
13997         calls->provided_init_features_meth = (*env)->GetMethodID(env, c, "provided_init_features", "([B)J");
13998         CHECK(calls->provided_init_features_meth != NULL);
13999
14000         LDKOnionMessageHandler ret = {
14001                 .this_arg = (void*) calls,
14002                 .handle_onion_message = handle_onion_message_LDKOnionMessageHandler_jcall,
14003                 .peer_connected = peer_connected_LDKOnionMessageHandler_jcall,
14004                 .peer_disconnected = peer_disconnected_LDKOnionMessageHandler_jcall,
14005                 .provided_node_features = provided_node_features_LDKOnionMessageHandler_jcall,
14006                 .provided_init_features = provided_init_features_LDKOnionMessageHandler_jcall,
14007                 .free = LDKOnionMessageHandler_JCalls_free,
14008                 .OnionMessageProvider = LDKOnionMessageProvider_init(env, clz, OnionMessageProvider),
14009         };
14010         calls->OnionMessageProvider = ret.OnionMessageProvider.this_arg;
14011         return ret;
14012 }
14013 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKOnionMessageHandler_1new(JNIEnv *env, jclass clz, jobject o, jobject OnionMessageProvider) {
14014         LDKOnionMessageHandler *res_ptr = MALLOC(sizeof(LDKOnionMessageHandler), "LDKOnionMessageHandler");
14015         *res_ptr = LDKOnionMessageHandler_init(env, clz, o, OnionMessageProvider);
14016         return tag_ptr(res_ptr, true);
14017 }
14018 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKOnionMessageHandler_1get_1OnionMessageProvider(JNIEnv *env, jclass clz, int64_t arg) {
14019         LDKOnionMessageHandler *inp = (LDKOnionMessageHandler *)untag_ptr(arg);
14020         return tag_ptr(&inp->OnionMessageProvider, false);
14021 }
14022 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) {
14023         void* this_arg_ptr = untag_ptr(this_arg);
14024         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
14025         LDKOnionMessageHandler* this_arg_conv = (LDKOnionMessageHandler*)this_arg_ptr;
14026         LDKPublicKey peer_node_id_ref;
14027         CHECK((*env)->GetArrayLength(env, peer_node_id) == 33);
14028         (*env)->GetByteArrayRegion(env, peer_node_id, 0, 33, peer_node_id_ref.compressed_form);
14029         LDKOnionMessage msg_conv;
14030         msg_conv.inner = untag_ptr(msg);
14031         msg_conv.is_owned = ptr_is_owned(msg);
14032         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
14033         msg_conv.is_owned = false;
14034         (this_arg_conv->handle_onion_message)(this_arg_conv->this_arg, peer_node_id_ref, &msg_conv);
14035 }
14036
14037 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) {
14038         void* this_arg_ptr = untag_ptr(this_arg);
14039         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
14040         LDKOnionMessageHandler* this_arg_conv = (LDKOnionMessageHandler*)this_arg_ptr;
14041         LDKPublicKey their_node_id_ref;
14042         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
14043         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
14044         LDKInit init_conv;
14045         init_conv.inner = untag_ptr(init);
14046         init_conv.is_owned = ptr_is_owned(init);
14047         CHECK_INNER_FIELD_ACCESS_OR_NULL(init_conv);
14048         init_conv.is_owned = false;
14049         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
14050         *ret_conv = (this_arg_conv->peer_connected)(this_arg_conv->this_arg, their_node_id_ref, &init_conv);
14051         return tag_ptr(ret_conv, true);
14052 }
14053
14054 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) {
14055         void* this_arg_ptr = untag_ptr(this_arg);
14056         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
14057         LDKOnionMessageHandler* this_arg_conv = (LDKOnionMessageHandler*)this_arg_ptr;
14058         LDKPublicKey their_node_id_ref;
14059         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
14060         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
14061         (this_arg_conv->peer_disconnected)(this_arg_conv->this_arg, their_node_id_ref, no_connection_possible);
14062 }
14063
14064 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OnionMessageHandler_1provided_1node_1features(JNIEnv *env, jclass clz, int64_t this_arg) {
14065         void* this_arg_ptr = untag_ptr(this_arg);
14066         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
14067         LDKOnionMessageHandler* this_arg_conv = (LDKOnionMessageHandler*)this_arg_ptr;
14068         LDKNodeFeatures ret_var = (this_arg_conv->provided_node_features)(this_arg_conv->this_arg);
14069         int64_t ret_ref = 0;
14070         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
14071         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
14072         return ret_ref;
14073 }
14074
14075 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) {
14076         void* this_arg_ptr = untag_ptr(this_arg);
14077         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
14078         LDKOnionMessageHandler* this_arg_conv = (LDKOnionMessageHandler*)this_arg_ptr;
14079         LDKPublicKey their_node_id_ref;
14080         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
14081         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
14082         LDKInitFeatures ret_var = (this_arg_conv->provided_init_features)(this_arg_conv->this_arg, their_node_id_ref);
14083         int64_t ret_ref = 0;
14084         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
14085         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
14086         return ret_ref;
14087 }
14088
14089 typedef struct LDKCustomMessageReader_JCalls {
14090         atomic_size_t refcnt;
14091         JavaVM *vm;
14092         jweak o;
14093         jmethodID read_meth;
14094 } LDKCustomMessageReader_JCalls;
14095 static void LDKCustomMessageReader_JCalls_free(void* this_arg) {
14096         LDKCustomMessageReader_JCalls *j_calls = (LDKCustomMessageReader_JCalls*) this_arg;
14097         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
14098                 JNIEnv *env;
14099                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
14100                 if (get_jenv_res == JNI_EDETACHED) {
14101                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
14102                 } else {
14103                         DO_ASSERT(get_jenv_res == JNI_OK);
14104                 }
14105                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
14106                 if (get_jenv_res == JNI_EDETACHED) {
14107                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
14108                 }
14109                 FREE(j_calls);
14110         }
14111 }
14112 LDKCResult_COption_TypeZDecodeErrorZ read_LDKCustomMessageReader_jcall(const void* this_arg, uint16_t message_type, LDKu8slice buffer) {
14113         LDKCustomMessageReader_JCalls *j_calls = (LDKCustomMessageReader_JCalls*) this_arg;
14114         JNIEnv *env;
14115         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
14116         if (get_jenv_res == JNI_EDETACHED) {
14117                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
14118         } else {
14119                 DO_ASSERT(get_jenv_res == JNI_OK);
14120         }
14121         int16_t message_type_conv = message_type;
14122         LDKu8slice buffer_var = buffer;
14123         int8_tArray buffer_arr = (*env)->NewByteArray(env, buffer_var.datalen);
14124         (*env)->SetByteArrayRegion(env, buffer_arr, 0, buffer_var.datalen, buffer_var.data);
14125         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
14126         CHECK(obj != NULL);
14127         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->read_meth, message_type_conv, buffer_arr);
14128         if (UNLIKELY((*env)->ExceptionCheck(env))) {
14129                 (*env)->ExceptionDescribe(env);
14130                 (*env)->FatalError(env, "A call to read in LDKCustomMessageReader from rust threw an exception.");
14131         }
14132         void* ret_ptr = untag_ptr(ret);
14133         CHECK_ACCESS(ret_ptr);
14134         LDKCResult_COption_TypeZDecodeErrorZ ret_conv = *(LDKCResult_COption_TypeZDecodeErrorZ*)(ret_ptr);
14135         FREE(untag_ptr(ret));
14136         if (get_jenv_res == JNI_EDETACHED) {
14137                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
14138         }
14139         return ret_conv;
14140 }
14141 static void LDKCustomMessageReader_JCalls_cloned(LDKCustomMessageReader* new_obj) {
14142         LDKCustomMessageReader_JCalls *j_calls = (LDKCustomMessageReader_JCalls*) new_obj->this_arg;
14143         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
14144 }
14145 static inline LDKCustomMessageReader LDKCustomMessageReader_init (JNIEnv *env, jclass clz, jobject o) {
14146         jclass c = (*env)->GetObjectClass(env, o);
14147         CHECK(c != NULL);
14148         LDKCustomMessageReader_JCalls *calls = MALLOC(sizeof(LDKCustomMessageReader_JCalls), "LDKCustomMessageReader_JCalls");
14149         atomic_init(&calls->refcnt, 1);
14150         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
14151         calls->o = (*env)->NewWeakGlobalRef(env, o);
14152         calls->read_meth = (*env)->GetMethodID(env, c, "read", "(S[B)J");
14153         CHECK(calls->read_meth != NULL);
14154
14155         LDKCustomMessageReader ret = {
14156                 .this_arg = (void*) calls,
14157                 .read = read_LDKCustomMessageReader_jcall,
14158                 .free = LDKCustomMessageReader_JCalls_free,
14159         };
14160         return ret;
14161 }
14162 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCustomMessageReader_1new(JNIEnv *env, jclass clz, jobject o) {
14163         LDKCustomMessageReader *res_ptr = MALLOC(sizeof(LDKCustomMessageReader), "LDKCustomMessageReader");
14164         *res_ptr = LDKCustomMessageReader_init(env, clz, o);
14165         return tag_ptr(res_ptr, true);
14166 }
14167 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) {
14168         void* this_arg_ptr = untag_ptr(this_arg);
14169         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
14170         LDKCustomMessageReader* this_arg_conv = (LDKCustomMessageReader*)this_arg_ptr;
14171         LDKu8slice buffer_ref;
14172         buffer_ref.datalen = (*env)->GetArrayLength(env, buffer);
14173         buffer_ref.data = (*env)->GetByteArrayElements (env, buffer, NULL);
14174         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
14175         *ret_conv = (this_arg_conv->read)(this_arg_conv->this_arg, message_type, buffer_ref);
14176         (*env)->ReleaseByteArrayElements(env, buffer, (int8_t*)buffer_ref.data, 0);
14177         return tag_ptr(ret_conv, true);
14178 }
14179
14180 typedef struct LDKCustomMessageHandler_JCalls {
14181         atomic_size_t refcnt;
14182         JavaVM *vm;
14183         jweak o;
14184         LDKCustomMessageReader_JCalls* CustomMessageReader;
14185         jmethodID handle_custom_message_meth;
14186         jmethodID get_and_clear_pending_msg_meth;
14187 } LDKCustomMessageHandler_JCalls;
14188 static void LDKCustomMessageHandler_JCalls_free(void* this_arg) {
14189         LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) this_arg;
14190         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
14191                 JNIEnv *env;
14192                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
14193                 if (get_jenv_res == JNI_EDETACHED) {
14194                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
14195                 } else {
14196                         DO_ASSERT(get_jenv_res == JNI_OK);
14197                 }
14198                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
14199                 if (get_jenv_res == JNI_EDETACHED) {
14200                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
14201                 }
14202                 FREE(j_calls);
14203         }
14204 }
14205 LDKCResult_NoneLightningErrorZ handle_custom_message_LDKCustomMessageHandler_jcall(const void* this_arg, LDKType msg, LDKPublicKey sender_node_id) {
14206         LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) this_arg;
14207         JNIEnv *env;
14208         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
14209         if (get_jenv_res == JNI_EDETACHED) {
14210                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
14211         } else {
14212                 DO_ASSERT(get_jenv_res == JNI_OK);
14213         }
14214         LDKType* msg_ret = MALLOC(sizeof(LDKType), "LDKType");
14215         *msg_ret = msg;
14216         int8_tArray sender_node_id_arr = (*env)->NewByteArray(env, 33);
14217         (*env)->SetByteArrayRegion(env, sender_node_id_arr, 0, 33, sender_node_id.compressed_form);
14218         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
14219         CHECK(obj != NULL);
14220         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_custom_message_meth, tag_ptr(msg_ret, true), sender_node_id_arr);
14221         if (UNLIKELY((*env)->ExceptionCheck(env))) {
14222                 (*env)->ExceptionDescribe(env);
14223                 (*env)->FatalError(env, "A call to handle_custom_message in LDKCustomMessageHandler from rust threw an exception.");
14224         }
14225         void* ret_ptr = untag_ptr(ret);
14226         CHECK_ACCESS(ret_ptr);
14227         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
14228         FREE(untag_ptr(ret));
14229         if (get_jenv_res == JNI_EDETACHED) {
14230                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
14231         }
14232         return ret_conv;
14233 }
14234 LDKCVec_C2Tuple_PublicKeyTypeZZ get_and_clear_pending_msg_LDKCustomMessageHandler_jcall(const void* this_arg) {
14235         LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) this_arg;
14236         JNIEnv *env;
14237         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
14238         if (get_jenv_res == JNI_EDETACHED) {
14239                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
14240         } else {
14241                 DO_ASSERT(get_jenv_res == JNI_OK);
14242         }
14243         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
14244         CHECK(obj != NULL);
14245         int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_and_clear_pending_msg_meth);
14246         if (UNLIKELY((*env)->ExceptionCheck(env))) {
14247                 (*env)->ExceptionDescribe(env);
14248                 (*env)->FatalError(env, "A call to get_and_clear_pending_msg in LDKCustomMessageHandler from rust threw an exception.");
14249         }
14250         LDKCVec_C2Tuple_PublicKeyTypeZZ ret_constr;
14251         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
14252         if (ret_constr.datalen > 0)
14253                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKCVec_C2Tuple_PublicKeyTypeZZ Elements");
14254         else
14255                 ret_constr.data = NULL;
14256         int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
14257         for (size_t z = 0; z < ret_constr.datalen; z++) {
14258                 int64_t ret_conv_25 = ret_vals[z];
14259                 void* ret_conv_25_ptr = untag_ptr(ret_conv_25);
14260                 CHECK_ACCESS(ret_conv_25_ptr);
14261                 LDKC2Tuple_PublicKeyTypeZ ret_conv_25_conv = *(LDKC2Tuple_PublicKeyTypeZ*)(ret_conv_25_ptr);
14262                 FREE(untag_ptr(ret_conv_25));
14263                 ret_constr.data[z] = ret_conv_25_conv;
14264         }
14265         (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
14266         if (get_jenv_res == JNI_EDETACHED) {
14267                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
14268         }
14269         return ret_constr;
14270 }
14271 static void LDKCustomMessageHandler_JCalls_cloned(LDKCustomMessageHandler* new_obj) {
14272         LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) new_obj->this_arg;
14273         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
14274         atomic_fetch_add_explicit(&j_calls->CustomMessageReader->refcnt, 1, memory_order_release);
14275 }
14276 static inline LDKCustomMessageHandler LDKCustomMessageHandler_init (JNIEnv *env, jclass clz, jobject o, jobject CustomMessageReader) {
14277         jclass c = (*env)->GetObjectClass(env, o);
14278         CHECK(c != NULL);
14279         LDKCustomMessageHandler_JCalls *calls = MALLOC(sizeof(LDKCustomMessageHandler_JCalls), "LDKCustomMessageHandler_JCalls");
14280         atomic_init(&calls->refcnt, 1);
14281         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
14282         calls->o = (*env)->NewWeakGlobalRef(env, o);
14283         calls->handle_custom_message_meth = (*env)->GetMethodID(env, c, "handle_custom_message", "(J[B)J");
14284         CHECK(calls->handle_custom_message_meth != NULL);
14285         calls->get_and_clear_pending_msg_meth = (*env)->GetMethodID(env, c, "get_and_clear_pending_msg", "()[J");
14286         CHECK(calls->get_and_clear_pending_msg_meth != NULL);
14287
14288         LDKCustomMessageHandler ret = {
14289                 .this_arg = (void*) calls,
14290                 .handle_custom_message = handle_custom_message_LDKCustomMessageHandler_jcall,
14291                 .get_and_clear_pending_msg = get_and_clear_pending_msg_LDKCustomMessageHandler_jcall,
14292                 .free = LDKCustomMessageHandler_JCalls_free,
14293                 .CustomMessageReader = LDKCustomMessageReader_init(env, clz, CustomMessageReader),
14294         };
14295         calls->CustomMessageReader = ret.CustomMessageReader.this_arg;
14296         return ret;
14297 }
14298 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCustomMessageHandler_1new(JNIEnv *env, jclass clz, jobject o, jobject CustomMessageReader) {
14299         LDKCustomMessageHandler *res_ptr = MALLOC(sizeof(LDKCustomMessageHandler), "LDKCustomMessageHandler");
14300         *res_ptr = LDKCustomMessageHandler_init(env, clz, o, CustomMessageReader);
14301         return tag_ptr(res_ptr, true);
14302 }
14303 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCustomMessageHandler_1get_1CustomMessageReader(JNIEnv *env, jclass clz, int64_t arg) {
14304         LDKCustomMessageHandler *inp = (LDKCustomMessageHandler *)untag_ptr(arg);
14305         return tag_ptr(&inp->CustomMessageReader, false);
14306 }
14307 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) {
14308         void* this_arg_ptr = untag_ptr(this_arg);
14309         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
14310         LDKCustomMessageHandler* this_arg_conv = (LDKCustomMessageHandler*)this_arg_ptr;
14311         void* msg_ptr = untag_ptr(msg);
14312         CHECK_ACCESS(msg_ptr);
14313         LDKType msg_conv = *(LDKType*)(msg_ptr);
14314         if (msg_conv.free == LDKType_JCalls_free) {
14315                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
14316                 LDKType_JCalls_cloned(&msg_conv);
14317         }
14318         LDKPublicKey sender_node_id_ref;
14319         CHECK((*env)->GetArrayLength(env, sender_node_id) == 33);
14320         (*env)->GetByteArrayRegion(env, sender_node_id, 0, 33, sender_node_id_ref.compressed_form);
14321         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
14322         *ret_conv = (this_arg_conv->handle_custom_message)(this_arg_conv->this_arg, msg_conv, sender_node_id_ref);
14323         return tag_ptr(ret_conv, true);
14324 }
14325
14326 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_CustomMessageHandler_1get_1and_1clear_1pending_1msg(JNIEnv *env, jclass clz, int64_t this_arg) {
14327         void* this_arg_ptr = untag_ptr(this_arg);
14328         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
14329         LDKCustomMessageHandler* this_arg_conv = (LDKCustomMessageHandler*)this_arg_ptr;
14330         LDKCVec_C2Tuple_PublicKeyTypeZZ ret_var = (this_arg_conv->get_and_clear_pending_msg)(this_arg_conv->this_arg);
14331         int64_tArray ret_arr = NULL;
14332         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
14333         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
14334         for (size_t z = 0; z < ret_var.datalen; z++) {
14335                 LDKC2Tuple_PublicKeyTypeZ* ret_conv_25_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ");
14336                 *ret_conv_25_conv = ret_var.data[z];
14337                 ret_arr_ptr[z] = tag_ptr(ret_conv_25_conv, true);
14338         }
14339         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
14340         FREE(ret_var.data);
14341         return ret_arr;
14342 }
14343
14344 typedef struct LDKCustomOnionMessageHandler_JCalls {
14345         atomic_size_t refcnt;
14346         JavaVM *vm;
14347         jweak o;
14348         jmethodID handle_custom_message_meth;
14349         jmethodID read_custom_message_meth;
14350 } LDKCustomOnionMessageHandler_JCalls;
14351 static void LDKCustomOnionMessageHandler_JCalls_free(void* this_arg) {
14352         LDKCustomOnionMessageHandler_JCalls *j_calls = (LDKCustomOnionMessageHandler_JCalls*) this_arg;
14353         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
14354                 JNIEnv *env;
14355                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
14356                 if (get_jenv_res == JNI_EDETACHED) {
14357                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
14358                 } else {
14359                         DO_ASSERT(get_jenv_res == JNI_OK);
14360                 }
14361                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
14362                 if (get_jenv_res == JNI_EDETACHED) {
14363                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
14364                 }
14365                 FREE(j_calls);
14366         }
14367 }
14368 void handle_custom_message_LDKCustomOnionMessageHandler_jcall(const void* this_arg, LDKCustomOnionMessageContents msg) {
14369         LDKCustomOnionMessageHandler_JCalls *j_calls = (LDKCustomOnionMessageHandler_JCalls*) this_arg;
14370         JNIEnv *env;
14371         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
14372         if (get_jenv_res == JNI_EDETACHED) {
14373                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
14374         } else {
14375                 DO_ASSERT(get_jenv_res == JNI_OK);
14376         }
14377         LDKCustomOnionMessageContents* msg_ret = MALLOC(sizeof(LDKCustomOnionMessageContents), "LDKCustomOnionMessageContents");
14378         *msg_ret = msg;
14379         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
14380         CHECK(obj != NULL);
14381         (*env)->CallVoidMethod(env, obj, j_calls->handle_custom_message_meth, tag_ptr(msg_ret, true));
14382         if (UNLIKELY((*env)->ExceptionCheck(env))) {
14383                 (*env)->ExceptionDescribe(env);
14384                 (*env)->FatalError(env, "A call to handle_custom_message in LDKCustomOnionMessageHandler from rust threw an exception.");
14385         }
14386         if (get_jenv_res == JNI_EDETACHED) {
14387                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
14388         }
14389 }
14390 LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ read_custom_message_LDKCustomOnionMessageHandler_jcall(const void* this_arg, uint64_t message_type, LDKu8slice buffer) {
14391         LDKCustomOnionMessageHandler_JCalls *j_calls = (LDKCustomOnionMessageHandler_JCalls*) this_arg;
14392         JNIEnv *env;
14393         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
14394         if (get_jenv_res == JNI_EDETACHED) {
14395                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
14396         } else {
14397                 DO_ASSERT(get_jenv_res == JNI_OK);
14398         }
14399         int64_t message_type_conv = message_type;
14400         LDKu8slice buffer_var = buffer;
14401         int8_tArray buffer_arr = (*env)->NewByteArray(env, buffer_var.datalen);
14402         (*env)->SetByteArrayRegion(env, buffer_arr, 0, buffer_var.datalen, buffer_var.data);
14403         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
14404         CHECK(obj != NULL);
14405         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->read_custom_message_meth, message_type_conv, buffer_arr);
14406         if (UNLIKELY((*env)->ExceptionCheck(env))) {
14407                 (*env)->ExceptionDescribe(env);
14408                 (*env)->FatalError(env, "A call to read_custom_message in LDKCustomOnionMessageHandler from rust threw an exception.");
14409         }
14410         void* ret_ptr = untag_ptr(ret);
14411         CHECK_ACCESS(ret_ptr);
14412         LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ ret_conv = *(LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ*)(ret_ptr);
14413         FREE(untag_ptr(ret));
14414         if (get_jenv_res == JNI_EDETACHED) {
14415                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
14416         }
14417         return ret_conv;
14418 }
14419 static void LDKCustomOnionMessageHandler_JCalls_cloned(LDKCustomOnionMessageHandler* new_obj) {
14420         LDKCustomOnionMessageHandler_JCalls *j_calls = (LDKCustomOnionMessageHandler_JCalls*) new_obj->this_arg;
14421         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
14422 }
14423 static inline LDKCustomOnionMessageHandler LDKCustomOnionMessageHandler_init (JNIEnv *env, jclass clz, jobject o) {
14424         jclass c = (*env)->GetObjectClass(env, o);
14425         CHECK(c != NULL);
14426         LDKCustomOnionMessageHandler_JCalls *calls = MALLOC(sizeof(LDKCustomOnionMessageHandler_JCalls), "LDKCustomOnionMessageHandler_JCalls");
14427         atomic_init(&calls->refcnt, 1);
14428         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
14429         calls->o = (*env)->NewWeakGlobalRef(env, o);
14430         calls->handle_custom_message_meth = (*env)->GetMethodID(env, c, "handle_custom_message", "(J)V");
14431         CHECK(calls->handle_custom_message_meth != NULL);
14432         calls->read_custom_message_meth = (*env)->GetMethodID(env, c, "read_custom_message", "(J[B)J");
14433         CHECK(calls->read_custom_message_meth != NULL);
14434
14435         LDKCustomOnionMessageHandler ret = {
14436                 .this_arg = (void*) calls,
14437                 .handle_custom_message = handle_custom_message_LDKCustomOnionMessageHandler_jcall,
14438                 .read_custom_message = read_custom_message_LDKCustomOnionMessageHandler_jcall,
14439                 .free = LDKCustomOnionMessageHandler_JCalls_free,
14440         };
14441         return ret;
14442 }
14443 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCustomOnionMessageHandler_1new(JNIEnv *env, jclass clz, jobject o) {
14444         LDKCustomOnionMessageHandler *res_ptr = MALLOC(sizeof(LDKCustomOnionMessageHandler), "LDKCustomOnionMessageHandler");
14445         *res_ptr = LDKCustomOnionMessageHandler_init(env, clz, o);
14446         return tag_ptr(res_ptr, true);
14447 }
14448 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CustomOnionMessageHandler_1handle_1custom_1message(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
14449         void* this_arg_ptr = untag_ptr(this_arg);
14450         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
14451         LDKCustomOnionMessageHandler* this_arg_conv = (LDKCustomOnionMessageHandler*)this_arg_ptr;
14452         void* msg_ptr = untag_ptr(msg);
14453         CHECK_ACCESS(msg_ptr);
14454         LDKCustomOnionMessageContents msg_conv = *(LDKCustomOnionMessageContents*)(msg_ptr);
14455         if (msg_conv.free == LDKCustomOnionMessageContents_JCalls_free) {
14456                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
14457                 LDKCustomOnionMessageContents_JCalls_cloned(&msg_conv);
14458         }
14459         (this_arg_conv->handle_custom_message)(this_arg_conv->this_arg, msg_conv);
14460 }
14461
14462 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) {
14463         void* this_arg_ptr = untag_ptr(this_arg);
14464         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
14465         LDKCustomOnionMessageHandler* this_arg_conv = (LDKCustomOnionMessageHandler*)this_arg_ptr;
14466         LDKu8slice buffer_ref;
14467         buffer_ref.datalen = (*env)->GetArrayLength(env, buffer);
14468         buffer_ref.data = (*env)->GetByteArrayElements (env, buffer, NULL);
14469         LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ), "LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ");
14470         *ret_conv = (this_arg_conv->read_custom_message)(this_arg_conv->this_arg, message_type, buffer_ref);
14471         (*env)->ReleaseByteArrayElements(env, buffer, (int8_t*)buffer_ref.data, 0);
14472         return tag_ptr(ret_conv, true);
14473 }
14474
14475 typedef struct LDKSocketDescriptor_JCalls {
14476         atomic_size_t refcnt;
14477         JavaVM *vm;
14478         jweak o;
14479         jmethodID send_data_meth;
14480         jmethodID disconnect_socket_meth;
14481         jmethodID eq_meth;
14482         jmethodID hash_meth;
14483 } LDKSocketDescriptor_JCalls;
14484 static void LDKSocketDescriptor_JCalls_free(void* this_arg) {
14485         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
14486         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
14487                 JNIEnv *env;
14488                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
14489                 if (get_jenv_res == JNI_EDETACHED) {
14490                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
14491                 } else {
14492                         DO_ASSERT(get_jenv_res == JNI_OK);
14493                 }
14494                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
14495                 if (get_jenv_res == JNI_EDETACHED) {
14496                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
14497                 }
14498                 FREE(j_calls);
14499         }
14500 }
14501 uintptr_t send_data_LDKSocketDescriptor_jcall(void* this_arg, LDKu8slice data, bool resume_read) {
14502         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
14503         JNIEnv *env;
14504         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
14505         if (get_jenv_res == JNI_EDETACHED) {
14506                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
14507         } else {
14508                 DO_ASSERT(get_jenv_res == JNI_OK);
14509         }
14510         LDKu8slice data_var = data;
14511         int8_tArray data_arr = (*env)->NewByteArray(env, data_var.datalen);
14512         (*env)->SetByteArrayRegion(env, data_arr, 0, data_var.datalen, data_var.data);
14513         jboolean resume_read_conv = resume_read;
14514         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
14515         CHECK(obj != NULL);
14516         int64_t ret = (*env)->CallLongMethod(env, obj, j_calls->send_data_meth, data_arr, resume_read_conv);
14517         if (UNLIKELY((*env)->ExceptionCheck(env))) {
14518                 (*env)->ExceptionDescribe(env);
14519                 (*env)->FatalError(env, "A call to send_data in LDKSocketDescriptor from rust threw an exception.");
14520         }
14521         if (get_jenv_res == JNI_EDETACHED) {
14522                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
14523         }
14524         return ret;
14525 }
14526 void disconnect_socket_LDKSocketDescriptor_jcall(void* this_arg) {
14527         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
14528         JNIEnv *env;
14529         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
14530         if (get_jenv_res == JNI_EDETACHED) {
14531                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
14532         } else {
14533                 DO_ASSERT(get_jenv_res == JNI_OK);
14534         }
14535         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
14536         CHECK(obj != NULL);
14537         (*env)->CallVoidMethod(env, obj, j_calls->disconnect_socket_meth);
14538         if (UNLIKELY((*env)->ExceptionCheck(env))) {
14539                 (*env)->ExceptionDescribe(env);
14540                 (*env)->FatalError(env, "A call to disconnect_socket in LDKSocketDescriptor from rust threw an exception.");
14541         }
14542         if (get_jenv_res == JNI_EDETACHED) {
14543                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
14544         }
14545 }
14546 bool eq_LDKSocketDescriptor_jcall(const void* this_arg, const LDKSocketDescriptor * other_arg) {
14547         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
14548         JNIEnv *env;
14549         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
14550         if (get_jenv_res == JNI_EDETACHED) {
14551                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
14552         } else {
14553                 DO_ASSERT(get_jenv_res == JNI_OK);
14554         }
14555         LDKSocketDescriptor *other_arg_clone = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
14556         *other_arg_clone = SocketDescriptor_clone(other_arg);
14557         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
14558         CHECK(obj != NULL);
14559         jboolean ret = (*env)->CallBooleanMethod(env, obj, j_calls->eq_meth, tag_ptr(other_arg_clone, true));
14560         if (UNLIKELY((*env)->ExceptionCheck(env))) {
14561                 (*env)->ExceptionDescribe(env);
14562                 (*env)->FatalError(env, "A call to eq in LDKSocketDescriptor from rust threw an exception.");
14563         }
14564         if (get_jenv_res == JNI_EDETACHED) {
14565                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
14566         }
14567         return ret;
14568 }
14569 uint64_t hash_LDKSocketDescriptor_jcall(const void* this_arg) {
14570         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
14571         JNIEnv *env;
14572         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
14573         if (get_jenv_res == JNI_EDETACHED) {
14574                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
14575         } else {
14576                 DO_ASSERT(get_jenv_res == JNI_OK);
14577         }
14578         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
14579         CHECK(obj != NULL);
14580         int64_t ret = (*env)->CallLongMethod(env, obj, j_calls->hash_meth);
14581         if (UNLIKELY((*env)->ExceptionCheck(env))) {
14582                 (*env)->ExceptionDescribe(env);
14583                 (*env)->FatalError(env, "A call to hash in LDKSocketDescriptor from rust threw an exception.");
14584         }
14585         if (get_jenv_res == JNI_EDETACHED) {
14586                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
14587         }
14588         return ret;
14589 }
14590 static void LDKSocketDescriptor_JCalls_cloned(LDKSocketDescriptor* new_obj) {
14591         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) new_obj->this_arg;
14592         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
14593 }
14594 static inline LDKSocketDescriptor LDKSocketDescriptor_init (JNIEnv *env, jclass clz, jobject o) {
14595         jclass c = (*env)->GetObjectClass(env, o);
14596         CHECK(c != NULL);
14597         LDKSocketDescriptor_JCalls *calls = MALLOC(sizeof(LDKSocketDescriptor_JCalls), "LDKSocketDescriptor_JCalls");
14598         atomic_init(&calls->refcnt, 1);
14599         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
14600         calls->o = (*env)->NewWeakGlobalRef(env, o);
14601         calls->send_data_meth = (*env)->GetMethodID(env, c, "send_data", "([BZ)J");
14602         CHECK(calls->send_data_meth != NULL);
14603         calls->disconnect_socket_meth = (*env)->GetMethodID(env, c, "disconnect_socket", "()V");
14604         CHECK(calls->disconnect_socket_meth != NULL);
14605         calls->eq_meth = (*env)->GetMethodID(env, c, "eq", "(J)Z");
14606         CHECK(calls->eq_meth != NULL);
14607         calls->hash_meth = (*env)->GetMethodID(env, c, "hash", "()J");
14608         CHECK(calls->hash_meth != NULL);
14609
14610         LDKSocketDescriptor ret = {
14611                 .this_arg = (void*) calls,
14612                 .send_data = send_data_LDKSocketDescriptor_jcall,
14613                 .disconnect_socket = disconnect_socket_LDKSocketDescriptor_jcall,
14614                 .eq = eq_LDKSocketDescriptor_jcall,
14615                 .hash = hash_LDKSocketDescriptor_jcall,
14616                 .cloned = LDKSocketDescriptor_JCalls_cloned,
14617                 .free = LDKSocketDescriptor_JCalls_free,
14618         };
14619         return ret;
14620 }
14621 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKSocketDescriptor_1new(JNIEnv *env, jclass clz, jobject o) {
14622         LDKSocketDescriptor *res_ptr = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
14623         *res_ptr = LDKSocketDescriptor_init(env, clz, o);
14624         return tag_ptr(res_ptr, true);
14625 }
14626 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) {
14627         void* this_arg_ptr = untag_ptr(this_arg);
14628         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
14629         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)this_arg_ptr;
14630         LDKu8slice data_ref;
14631         data_ref.datalen = (*env)->GetArrayLength(env, data);
14632         data_ref.data = (*env)->GetByteArrayElements (env, data, NULL);
14633         int64_t ret_conv = (this_arg_conv->send_data)(this_arg_conv->this_arg, data_ref, resume_read);
14634         (*env)->ReleaseByteArrayElements(env, data, (int8_t*)data_ref.data, 0);
14635         return ret_conv;
14636 }
14637
14638 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1disconnect_1socket(JNIEnv *env, jclass clz, int64_t this_arg) {
14639         void* this_arg_ptr = untag_ptr(this_arg);
14640         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
14641         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)this_arg_ptr;
14642         (this_arg_conv->disconnect_socket)(this_arg_conv->this_arg);
14643 }
14644
14645 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
14646         void* this_arg_ptr = untag_ptr(this_arg);
14647         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
14648         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)this_arg_ptr;
14649         int64_t ret_conv = (this_arg_conv->hash)(this_arg_conv->this_arg);
14650         return ret_conv;
14651 }
14652
14653 static jclass LDKEffectiveCapacity_ExactLiquidity_class = NULL;
14654 static jmethodID LDKEffectiveCapacity_ExactLiquidity_meth = NULL;
14655 static jclass LDKEffectiveCapacity_MaximumHTLC_class = NULL;
14656 static jmethodID LDKEffectiveCapacity_MaximumHTLC_meth = NULL;
14657 static jclass LDKEffectiveCapacity_Total_class = NULL;
14658 static jmethodID LDKEffectiveCapacity_Total_meth = NULL;
14659 static jclass LDKEffectiveCapacity_Infinite_class = NULL;
14660 static jmethodID LDKEffectiveCapacity_Infinite_meth = NULL;
14661 static jclass LDKEffectiveCapacity_Unknown_class = NULL;
14662 static jmethodID LDKEffectiveCapacity_Unknown_meth = NULL;
14663 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKEffectiveCapacity_init (JNIEnv *env, jclass clz) {
14664         LDKEffectiveCapacity_ExactLiquidity_class =
14665                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEffectiveCapacity$ExactLiquidity"));
14666         CHECK(LDKEffectiveCapacity_ExactLiquidity_class != NULL);
14667         LDKEffectiveCapacity_ExactLiquidity_meth = (*env)->GetMethodID(env, LDKEffectiveCapacity_ExactLiquidity_class, "<init>", "(J)V");
14668         CHECK(LDKEffectiveCapacity_ExactLiquidity_meth != NULL);
14669         LDKEffectiveCapacity_MaximumHTLC_class =
14670                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEffectiveCapacity$MaximumHTLC"));
14671         CHECK(LDKEffectiveCapacity_MaximumHTLC_class != NULL);
14672         LDKEffectiveCapacity_MaximumHTLC_meth = (*env)->GetMethodID(env, LDKEffectiveCapacity_MaximumHTLC_class, "<init>", "(J)V");
14673         CHECK(LDKEffectiveCapacity_MaximumHTLC_meth != NULL);
14674         LDKEffectiveCapacity_Total_class =
14675                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEffectiveCapacity$Total"));
14676         CHECK(LDKEffectiveCapacity_Total_class != NULL);
14677         LDKEffectiveCapacity_Total_meth = (*env)->GetMethodID(env, LDKEffectiveCapacity_Total_class, "<init>", "(JJ)V");
14678         CHECK(LDKEffectiveCapacity_Total_meth != NULL);
14679         LDKEffectiveCapacity_Infinite_class =
14680                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEffectiveCapacity$Infinite"));
14681         CHECK(LDKEffectiveCapacity_Infinite_class != NULL);
14682         LDKEffectiveCapacity_Infinite_meth = (*env)->GetMethodID(env, LDKEffectiveCapacity_Infinite_class, "<init>", "()V");
14683         CHECK(LDKEffectiveCapacity_Infinite_meth != NULL);
14684         LDKEffectiveCapacity_Unknown_class =
14685                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKEffectiveCapacity$Unknown"));
14686         CHECK(LDKEffectiveCapacity_Unknown_class != NULL);
14687         LDKEffectiveCapacity_Unknown_meth = (*env)->GetMethodID(env, LDKEffectiveCapacity_Unknown_class, "<init>", "()V");
14688         CHECK(LDKEffectiveCapacity_Unknown_meth != NULL);
14689 }
14690 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKEffectiveCapacity_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
14691         LDKEffectiveCapacity *obj = (LDKEffectiveCapacity*)untag_ptr(ptr);
14692         switch(obj->tag) {
14693                 case LDKEffectiveCapacity_ExactLiquidity: {
14694                         int64_t liquidity_msat_conv = obj->exact_liquidity.liquidity_msat;
14695                         return (*env)->NewObject(env, LDKEffectiveCapacity_ExactLiquidity_class, LDKEffectiveCapacity_ExactLiquidity_meth, liquidity_msat_conv);
14696                 }
14697                 case LDKEffectiveCapacity_MaximumHTLC: {
14698                         int64_t amount_msat_conv = obj->maximum_htlc.amount_msat;
14699                         return (*env)->NewObject(env, LDKEffectiveCapacity_MaximumHTLC_class, LDKEffectiveCapacity_MaximumHTLC_meth, amount_msat_conv);
14700                 }
14701                 case LDKEffectiveCapacity_Total: {
14702                         int64_t capacity_msat_conv = obj->total.capacity_msat;
14703                         int64_t htlc_maximum_msat_conv = obj->total.htlc_maximum_msat;
14704                         return (*env)->NewObject(env, LDKEffectiveCapacity_Total_class, LDKEffectiveCapacity_Total_meth, capacity_msat_conv, htlc_maximum_msat_conv);
14705                 }
14706                 case LDKEffectiveCapacity_Infinite: {
14707                         return (*env)->NewObject(env, LDKEffectiveCapacity_Infinite_class, LDKEffectiveCapacity_Infinite_meth);
14708                 }
14709                 case LDKEffectiveCapacity_Unknown: {
14710                         return (*env)->NewObject(env, LDKEffectiveCapacity_Unknown_class, LDKEffectiveCapacity_Unknown_meth);
14711                 }
14712                 default: abort();
14713         }
14714 }
14715 typedef struct LDKRouter_JCalls {
14716         atomic_size_t refcnt;
14717         JavaVM *vm;
14718         jweak o;
14719         jmethodID find_route_meth;
14720         jmethodID find_route_with_id_meth;
14721         jmethodID notify_payment_path_failed_meth;
14722         jmethodID notify_payment_path_successful_meth;
14723         jmethodID notify_payment_probe_successful_meth;
14724         jmethodID notify_payment_probe_failed_meth;
14725 } LDKRouter_JCalls;
14726 static void LDKRouter_JCalls_free(void* this_arg) {
14727         LDKRouter_JCalls *j_calls = (LDKRouter_JCalls*) this_arg;
14728         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
14729                 JNIEnv *env;
14730                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
14731                 if (get_jenv_res == JNI_EDETACHED) {
14732                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
14733                 } else {
14734                         DO_ASSERT(get_jenv_res == JNI_OK);
14735                 }
14736                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
14737                 if (get_jenv_res == JNI_EDETACHED) {
14738                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
14739                 }
14740                 FREE(j_calls);
14741         }
14742 }
14743 LDKCResult_RouteLightningErrorZ find_route_LDKRouter_jcall(const void* this_arg, LDKPublicKey payer, const LDKRouteParameters * route_params, LDKCVec_ChannelDetailsZ * first_hops, LDKInFlightHtlcs inflight_htlcs) {
14744         LDKRouter_JCalls *j_calls = (LDKRouter_JCalls*) this_arg;
14745         JNIEnv *env;
14746         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
14747         if (get_jenv_res == JNI_EDETACHED) {
14748                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
14749         } else {
14750                 DO_ASSERT(get_jenv_res == JNI_OK);
14751         }
14752         int8_tArray payer_arr = (*env)->NewByteArray(env, 33);
14753         (*env)->SetByteArrayRegion(env, payer_arr, 0, 33, payer.compressed_form);
14754         LDKRouteParameters route_params_var = *route_params;
14755         int64_t route_params_ref = 0;
14756         route_params_var = RouteParameters_clone(&route_params_var);
14757         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_params_var);
14758         route_params_ref = tag_ptr(route_params_var.inner, route_params_var.is_owned);
14759         LDKCVec_ChannelDetailsZ *first_hops_var_ptr = first_hops;
14760         int64_tArray first_hops_arr = NULL;
14761         if (first_hops != NULL) {
14762                 LDKCVec_ChannelDetailsZ first_hops_var = *first_hops_var_ptr;
14763                 first_hops_arr = (*env)->NewLongArray(env, first_hops_var.datalen);
14764                 int64_t *first_hops_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, first_hops_arr, NULL);
14765                 for (size_t q = 0; q < first_hops_var.datalen; q++) {
14766                         LDKChannelDetails first_hops_conv_16_var =      first_hops_var.data[q];
14767                         int64_t first_hops_conv_16_ref = 0;
14768                         CHECK_INNER_FIELD_ACCESS_OR_NULL(first_hops_conv_16_var);
14769                         first_hops_conv_16_ref = tag_ptr(first_hops_conv_16_var.inner, first_hops_conv_16_var.is_owned);
14770                         first_hops_arr_ptr[q] = first_hops_conv_16_ref;
14771                 }
14772                 (*env)->ReleasePrimitiveArrayCritical(env, first_hops_arr, first_hops_arr_ptr, 0);
14773         }
14774         LDKInFlightHtlcs inflight_htlcs_var = inflight_htlcs;
14775         int64_t inflight_htlcs_ref = 0;
14776         CHECK_INNER_FIELD_ACCESS_OR_NULL(inflight_htlcs_var);
14777         inflight_htlcs_ref = tag_ptr(inflight_htlcs_var.inner, inflight_htlcs_var.is_owned);
14778         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
14779         CHECK(obj != NULL);
14780         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->find_route_meth, payer_arr, route_params_ref, first_hops_arr, inflight_htlcs_ref);
14781         if (UNLIKELY((*env)->ExceptionCheck(env))) {
14782                 (*env)->ExceptionDescribe(env);
14783                 (*env)->FatalError(env, "A call to find_route in LDKRouter from rust threw an exception.");
14784         }
14785         void* ret_ptr = untag_ptr(ret);
14786         CHECK_ACCESS(ret_ptr);
14787         LDKCResult_RouteLightningErrorZ ret_conv = *(LDKCResult_RouteLightningErrorZ*)(ret_ptr);
14788         FREE(untag_ptr(ret));
14789         if (get_jenv_res == JNI_EDETACHED) {
14790                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
14791         }
14792         return ret_conv;
14793 }
14794 LDKCResult_RouteLightningErrorZ find_route_with_id_LDKRouter_jcall(const void* this_arg, LDKPublicKey payer, const LDKRouteParameters * route_params, LDKCVec_ChannelDetailsZ * first_hops, LDKInFlightHtlcs inflight_htlcs, LDKThirtyTwoBytes _payment_hash, LDKThirtyTwoBytes _payment_id) {
14795         LDKRouter_JCalls *j_calls = (LDKRouter_JCalls*) this_arg;
14796         JNIEnv *env;
14797         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
14798         if (get_jenv_res == JNI_EDETACHED) {
14799                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
14800         } else {
14801                 DO_ASSERT(get_jenv_res == JNI_OK);
14802         }
14803         int8_tArray payer_arr = (*env)->NewByteArray(env, 33);
14804         (*env)->SetByteArrayRegion(env, payer_arr, 0, 33, payer.compressed_form);
14805         LDKRouteParameters route_params_var = *route_params;
14806         int64_t route_params_ref = 0;
14807         route_params_var = RouteParameters_clone(&route_params_var);
14808         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_params_var);
14809         route_params_ref = tag_ptr(route_params_var.inner, route_params_var.is_owned);
14810         LDKCVec_ChannelDetailsZ *first_hops_var_ptr = first_hops;
14811         int64_tArray first_hops_arr = NULL;
14812         if (first_hops != NULL) {
14813                 LDKCVec_ChannelDetailsZ first_hops_var = *first_hops_var_ptr;
14814                 first_hops_arr = (*env)->NewLongArray(env, first_hops_var.datalen);
14815                 int64_t *first_hops_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, first_hops_arr, NULL);
14816                 for (size_t q = 0; q < first_hops_var.datalen; q++) {
14817                         LDKChannelDetails first_hops_conv_16_var =      first_hops_var.data[q];
14818                         int64_t first_hops_conv_16_ref = 0;
14819                         CHECK_INNER_FIELD_ACCESS_OR_NULL(first_hops_conv_16_var);
14820                         first_hops_conv_16_ref = tag_ptr(first_hops_conv_16_var.inner, first_hops_conv_16_var.is_owned);
14821                         first_hops_arr_ptr[q] = first_hops_conv_16_ref;
14822                 }
14823                 (*env)->ReleasePrimitiveArrayCritical(env, first_hops_arr, first_hops_arr_ptr, 0);
14824         }
14825         LDKInFlightHtlcs inflight_htlcs_var = inflight_htlcs;
14826         int64_t inflight_htlcs_ref = 0;
14827         CHECK_INNER_FIELD_ACCESS_OR_NULL(inflight_htlcs_var);
14828         inflight_htlcs_ref = tag_ptr(inflight_htlcs_var.inner, inflight_htlcs_var.is_owned);
14829         int8_tArray _payment_hash_arr = (*env)->NewByteArray(env, 32);
14830         (*env)->SetByteArrayRegion(env, _payment_hash_arr, 0, 32, _payment_hash.data);
14831         int8_tArray _payment_id_arr = (*env)->NewByteArray(env, 32);
14832         (*env)->SetByteArrayRegion(env, _payment_id_arr, 0, 32, _payment_id.data);
14833         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
14834         CHECK(obj != NULL);
14835         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->find_route_with_id_meth, payer_arr, route_params_ref, first_hops_arr, inflight_htlcs_ref, _payment_hash_arr, _payment_id_arr);
14836         if (UNLIKELY((*env)->ExceptionCheck(env))) {
14837                 (*env)->ExceptionDescribe(env);
14838                 (*env)->FatalError(env, "A call to find_route_with_id in LDKRouter from rust threw an exception.");
14839         }
14840         void* ret_ptr = untag_ptr(ret);
14841         CHECK_ACCESS(ret_ptr);
14842         LDKCResult_RouteLightningErrorZ ret_conv = *(LDKCResult_RouteLightningErrorZ*)(ret_ptr);
14843         FREE(untag_ptr(ret));
14844         if (get_jenv_res == JNI_EDETACHED) {
14845                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
14846         }
14847         return ret_conv;
14848 }
14849 void notify_payment_path_failed_LDKRouter_jcall(const void* this_arg, LDKCVec_RouteHopZ path, uint64_t short_channel_id) {
14850         LDKRouter_JCalls *j_calls = (LDKRouter_JCalls*) this_arg;
14851         JNIEnv *env;
14852         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
14853         if (get_jenv_res == JNI_EDETACHED) {
14854                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
14855         } else {
14856                 DO_ASSERT(get_jenv_res == JNI_OK);
14857         }
14858         LDKCVec_RouteHopZ path_var = path;
14859         int64_tArray path_arr = NULL;
14860         path_arr = (*env)->NewLongArray(env, path_var.datalen);
14861         int64_t *path_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, path_arr, NULL);
14862         for (size_t k = 0; k < path_var.datalen; k++) {
14863                 LDKRouteHop path_conv_10_var = path_var.data[k];
14864                 int64_t path_conv_10_ref = 0;
14865                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
14866                 path_conv_10_ref = tag_ptr(path_conv_10_var.inner, path_conv_10_var.is_owned);
14867                 path_arr_ptr[k] = path_conv_10_ref;
14868         }
14869         (*env)->ReleasePrimitiveArrayCritical(env, path_arr, path_arr_ptr, 0);
14870         FREE(path_var.data);
14871         int64_t short_channel_id_conv = short_channel_id;
14872         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
14873         CHECK(obj != NULL);
14874         (*env)->CallVoidMethod(env, obj, j_calls->notify_payment_path_failed_meth, path_arr, short_channel_id_conv);
14875         if (UNLIKELY((*env)->ExceptionCheck(env))) {
14876                 (*env)->ExceptionDescribe(env);
14877                 (*env)->FatalError(env, "A call to notify_payment_path_failed in LDKRouter from rust threw an exception.");
14878         }
14879         if (get_jenv_res == JNI_EDETACHED) {
14880                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
14881         }
14882 }
14883 void notify_payment_path_successful_LDKRouter_jcall(const void* this_arg, LDKCVec_RouteHopZ path) {
14884         LDKRouter_JCalls *j_calls = (LDKRouter_JCalls*) this_arg;
14885         JNIEnv *env;
14886         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
14887         if (get_jenv_res == JNI_EDETACHED) {
14888                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
14889         } else {
14890                 DO_ASSERT(get_jenv_res == JNI_OK);
14891         }
14892         LDKCVec_RouteHopZ path_var = path;
14893         int64_tArray path_arr = NULL;
14894         path_arr = (*env)->NewLongArray(env, path_var.datalen);
14895         int64_t *path_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, path_arr, NULL);
14896         for (size_t k = 0; k < path_var.datalen; k++) {
14897                 LDKRouteHop path_conv_10_var = path_var.data[k];
14898                 int64_t path_conv_10_ref = 0;
14899                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
14900                 path_conv_10_ref = tag_ptr(path_conv_10_var.inner, path_conv_10_var.is_owned);
14901                 path_arr_ptr[k] = path_conv_10_ref;
14902         }
14903         (*env)->ReleasePrimitiveArrayCritical(env, path_arr, path_arr_ptr, 0);
14904         FREE(path_var.data);
14905         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
14906         CHECK(obj != NULL);
14907         (*env)->CallVoidMethod(env, obj, j_calls->notify_payment_path_successful_meth, path_arr);
14908         if (UNLIKELY((*env)->ExceptionCheck(env))) {
14909                 (*env)->ExceptionDescribe(env);
14910                 (*env)->FatalError(env, "A call to notify_payment_path_successful in LDKRouter from rust threw an exception.");
14911         }
14912         if (get_jenv_res == JNI_EDETACHED) {
14913                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
14914         }
14915 }
14916 void notify_payment_probe_successful_LDKRouter_jcall(const void* this_arg, LDKCVec_RouteHopZ path) {
14917         LDKRouter_JCalls *j_calls = (LDKRouter_JCalls*) this_arg;
14918         JNIEnv *env;
14919         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
14920         if (get_jenv_res == JNI_EDETACHED) {
14921                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
14922         } else {
14923                 DO_ASSERT(get_jenv_res == JNI_OK);
14924         }
14925         LDKCVec_RouteHopZ path_var = path;
14926         int64_tArray path_arr = NULL;
14927         path_arr = (*env)->NewLongArray(env, path_var.datalen);
14928         int64_t *path_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, path_arr, NULL);
14929         for (size_t k = 0; k < path_var.datalen; k++) {
14930                 LDKRouteHop path_conv_10_var = path_var.data[k];
14931                 int64_t path_conv_10_ref = 0;
14932                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
14933                 path_conv_10_ref = tag_ptr(path_conv_10_var.inner, path_conv_10_var.is_owned);
14934                 path_arr_ptr[k] = path_conv_10_ref;
14935         }
14936         (*env)->ReleasePrimitiveArrayCritical(env, path_arr, path_arr_ptr, 0);
14937         FREE(path_var.data);
14938         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
14939         CHECK(obj != NULL);
14940         (*env)->CallVoidMethod(env, obj, j_calls->notify_payment_probe_successful_meth, path_arr);
14941         if (UNLIKELY((*env)->ExceptionCheck(env))) {
14942                 (*env)->ExceptionDescribe(env);
14943                 (*env)->FatalError(env, "A call to notify_payment_probe_successful in LDKRouter from rust threw an exception.");
14944         }
14945         if (get_jenv_res == JNI_EDETACHED) {
14946                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
14947         }
14948 }
14949 void notify_payment_probe_failed_LDKRouter_jcall(const void* this_arg, LDKCVec_RouteHopZ path, uint64_t short_channel_id) {
14950         LDKRouter_JCalls *j_calls = (LDKRouter_JCalls*) this_arg;
14951         JNIEnv *env;
14952         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
14953         if (get_jenv_res == JNI_EDETACHED) {
14954                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
14955         } else {
14956                 DO_ASSERT(get_jenv_res == JNI_OK);
14957         }
14958         LDKCVec_RouteHopZ path_var = path;
14959         int64_tArray path_arr = NULL;
14960         path_arr = (*env)->NewLongArray(env, path_var.datalen);
14961         int64_t *path_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, path_arr, NULL);
14962         for (size_t k = 0; k < path_var.datalen; k++) {
14963                 LDKRouteHop path_conv_10_var = path_var.data[k];
14964                 int64_t path_conv_10_ref = 0;
14965                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
14966                 path_conv_10_ref = tag_ptr(path_conv_10_var.inner, path_conv_10_var.is_owned);
14967                 path_arr_ptr[k] = path_conv_10_ref;
14968         }
14969         (*env)->ReleasePrimitiveArrayCritical(env, path_arr, path_arr_ptr, 0);
14970         FREE(path_var.data);
14971         int64_t short_channel_id_conv = short_channel_id;
14972         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
14973         CHECK(obj != NULL);
14974         (*env)->CallVoidMethod(env, obj, j_calls->notify_payment_probe_failed_meth, path_arr, short_channel_id_conv);
14975         if (UNLIKELY((*env)->ExceptionCheck(env))) {
14976                 (*env)->ExceptionDescribe(env);
14977                 (*env)->FatalError(env, "A call to notify_payment_probe_failed in LDKRouter from rust threw an exception.");
14978         }
14979         if (get_jenv_res == JNI_EDETACHED) {
14980                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
14981         }
14982 }
14983 static void LDKRouter_JCalls_cloned(LDKRouter* new_obj) {
14984         LDKRouter_JCalls *j_calls = (LDKRouter_JCalls*) new_obj->this_arg;
14985         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
14986 }
14987 static inline LDKRouter LDKRouter_init (JNIEnv *env, jclass clz, jobject o) {
14988         jclass c = (*env)->GetObjectClass(env, o);
14989         CHECK(c != NULL);
14990         LDKRouter_JCalls *calls = MALLOC(sizeof(LDKRouter_JCalls), "LDKRouter_JCalls");
14991         atomic_init(&calls->refcnt, 1);
14992         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
14993         calls->o = (*env)->NewWeakGlobalRef(env, o);
14994         calls->find_route_meth = (*env)->GetMethodID(env, c, "find_route", "([BJ[JJ)J");
14995         CHECK(calls->find_route_meth != NULL);
14996         calls->find_route_with_id_meth = (*env)->GetMethodID(env, c, "find_route_with_id", "([BJ[JJ[B[B)J");
14997         CHECK(calls->find_route_with_id_meth != NULL);
14998         calls->notify_payment_path_failed_meth = (*env)->GetMethodID(env, c, "notify_payment_path_failed", "([JJ)V");
14999         CHECK(calls->notify_payment_path_failed_meth != NULL);
15000         calls->notify_payment_path_successful_meth = (*env)->GetMethodID(env, c, "notify_payment_path_successful", "([J)V");
15001         CHECK(calls->notify_payment_path_successful_meth != NULL);
15002         calls->notify_payment_probe_successful_meth = (*env)->GetMethodID(env, c, "notify_payment_probe_successful", "([J)V");
15003         CHECK(calls->notify_payment_probe_successful_meth != NULL);
15004         calls->notify_payment_probe_failed_meth = (*env)->GetMethodID(env, c, "notify_payment_probe_failed", "([JJ)V");
15005         CHECK(calls->notify_payment_probe_failed_meth != NULL);
15006
15007         LDKRouter ret = {
15008                 .this_arg = (void*) calls,
15009                 .find_route = find_route_LDKRouter_jcall,
15010                 .find_route_with_id = find_route_with_id_LDKRouter_jcall,
15011                 .notify_payment_path_failed = notify_payment_path_failed_LDKRouter_jcall,
15012                 .notify_payment_path_successful = notify_payment_path_successful_LDKRouter_jcall,
15013                 .notify_payment_probe_successful = notify_payment_probe_successful_LDKRouter_jcall,
15014                 .notify_payment_probe_failed = notify_payment_probe_failed_LDKRouter_jcall,
15015                 .free = LDKRouter_JCalls_free,
15016         };
15017         return ret;
15018 }
15019 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKRouter_1new(JNIEnv *env, jclass clz, jobject o) {
15020         LDKRouter *res_ptr = MALLOC(sizeof(LDKRouter), "LDKRouter");
15021         *res_ptr = LDKRouter_init(env, clz, o);
15022         return tag_ptr(res_ptr, true);
15023 }
15024 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, int64_tArray first_hops, int64_t inflight_htlcs) {
15025         void* this_arg_ptr = untag_ptr(this_arg);
15026         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
15027         LDKRouter* this_arg_conv = (LDKRouter*)this_arg_ptr;
15028         LDKPublicKey payer_ref;
15029         CHECK((*env)->GetArrayLength(env, payer) == 33);
15030         (*env)->GetByteArrayRegion(env, payer, 0, 33, payer_ref.compressed_form);
15031         LDKRouteParameters route_params_conv;
15032         route_params_conv.inner = untag_ptr(route_params);
15033         route_params_conv.is_owned = ptr_is_owned(route_params);
15034         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_params_conv);
15035         route_params_conv.is_owned = false;
15036         LDKCVec_ChannelDetailsZ first_hops_constr;
15037         LDKCVec_ChannelDetailsZ *first_hops_ptr = NULL;
15038         if (first_hops != NULL) {
15039                 first_hops_constr.datalen = (*env)->GetArrayLength(env, first_hops);
15040                 if (first_hops_constr.datalen > 0)
15041                         first_hops_constr.data = MALLOC(first_hops_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
15042                 else
15043                         first_hops_constr.data = NULL;
15044                 int64_t* first_hops_vals = (*env)->GetLongArrayElements (env, first_hops, NULL);
15045                 for (size_t q = 0; q < first_hops_constr.datalen; q++) {
15046                         int64_t first_hops_conv_16 = first_hops_vals[q];
15047                         LDKChannelDetails first_hops_conv_16_conv;
15048                         first_hops_conv_16_conv.inner = untag_ptr(first_hops_conv_16);
15049                         first_hops_conv_16_conv.is_owned = ptr_is_owned(first_hops_conv_16);
15050                         CHECK_INNER_FIELD_ACCESS_OR_NULL(first_hops_conv_16_conv);
15051                         first_hops_conv_16_conv.is_owned = false;
15052                         first_hops_constr.data[q] = first_hops_conv_16_conv;
15053                 }
15054                 (*env)->ReleaseLongArrayElements(env, first_hops, first_hops_vals, 0);
15055                 first_hops_ptr = &first_hops_constr;
15056         }
15057         LDKInFlightHtlcs inflight_htlcs_conv;
15058         inflight_htlcs_conv.inner = untag_ptr(inflight_htlcs);
15059         inflight_htlcs_conv.is_owned = ptr_is_owned(inflight_htlcs);
15060         CHECK_INNER_FIELD_ACCESS_OR_NULL(inflight_htlcs_conv);
15061         inflight_htlcs_conv = InFlightHtlcs_clone(&inflight_htlcs_conv);
15062         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
15063         *ret_conv = (this_arg_conv->find_route)(this_arg_conv->this_arg, payer_ref, &route_params_conv, first_hops_ptr, inflight_htlcs_conv);
15064         if (first_hops_ptr != NULL) { FREE(first_hops_constr.data); }
15065         return tag_ptr(ret_conv, true);
15066 }
15067
15068 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Router_1find_1route_1with_1id(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray payer, int64_t route_params, int64_tArray first_hops, int64_t inflight_htlcs, int8_tArray _payment_hash, int8_tArray _payment_id) {
15069         void* this_arg_ptr = untag_ptr(this_arg);
15070         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
15071         LDKRouter* this_arg_conv = (LDKRouter*)this_arg_ptr;
15072         LDKPublicKey payer_ref;
15073         CHECK((*env)->GetArrayLength(env, payer) == 33);
15074         (*env)->GetByteArrayRegion(env, payer, 0, 33, payer_ref.compressed_form);
15075         LDKRouteParameters route_params_conv;
15076         route_params_conv.inner = untag_ptr(route_params);
15077         route_params_conv.is_owned = ptr_is_owned(route_params);
15078         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_params_conv);
15079         route_params_conv.is_owned = false;
15080         LDKCVec_ChannelDetailsZ first_hops_constr;
15081         LDKCVec_ChannelDetailsZ *first_hops_ptr = NULL;
15082         if (first_hops != NULL) {
15083                 first_hops_constr.datalen = (*env)->GetArrayLength(env, first_hops);
15084                 if (first_hops_constr.datalen > 0)
15085                         first_hops_constr.data = MALLOC(first_hops_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
15086                 else
15087                         first_hops_constr.data = NULL;
15088                 int64_t* first_hops_vals = (*env)->GetLongArrayElements (env, first_hops, NULL);
15089                 for (size_t q = 0; q < first_hops_constr.datalen; q++) {
15090                         int64_t first_hops_conv_16 = first_hops_vals[q];
15091                         LDKChannelDetails first_hops_conv_16_conv;
15092                         first_hops_conv_16_conv.inner = untag_ptr(first_hops_conv_16);
15093                         first_hops_conv_16_conv.is_owned = ptr_is_owned(first_hops_conv_16);
15094                         CHECK_INNER_FIELD_ACCESS_OR_NULL(first_hops_conv_16_conv);
15095                         first_hops_conv_16_conv.is_owned = false;
15096                         first_hops_constr.data[q] = first_hops_conv_16_conv;
15097                 }
15098                 (*env)->ReleaseLongArrayElements(env, first_hops, first_hops_vals, 0);
15099                 first_hops_ptr = &first_hops_constr;
15100         }
15101         LDKInFlightHtlcs inflight_htlcs_conv;
15102         inflight_htlcs_conv.inner = untag_ptr(inflight_htlcs);
15103         inflight_htlcs_conv.is_owned = ptr_is_owned(inflight_htlcs);
15104         CHECK_INNER_FIELD_ACCESS_OR_NULL(inflight_htlcs_conv);
15105         inflight_htlcs_conv = InFlightHtlcs_clone(&inflight_htlcs_conv);
15106         LDKThirtyTwoBytes _payment_hash_ref;
15107         CHECK((*env)->GetArrayLength(env, _payment_hash) == 32);
15108         (*env)->GetByteArrayRegion(env, _payment_hash, 0, 32, _payment_hash_ref.data);
15109         LDKThirtyTwoBytes _payment_id_ref;
15110         CHECK((*env)->GetArrayLength(env, _payment_id) == 32);
15111         (*env)->GetByteArrayRegion(env, _payment_id, 0, 32, _payment_id_ref.data);
15112         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
15113         *ret_conv = (this_arg_conv->find_route_with_id)(this_arg_conv->this_arg, payer_ref, &route_params_conv, first_hops_ptr, inflight_htlcs_conv, _payment_hash_ref, _payment_id_ref);
15114         if (first_hops_ptr != NULL) { FREE(first_hops_constr.data); }
15115         return tag_ptr(ret_conv, true);
15116 }
15117
15118 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) {
15119         void* this_arg_ptr = untag_ptr(this_arg);
15120         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
15121         LDKRouter* this_arg_conv = (LDKRouter*)this_arg_ptr;
15122         LDKCVec_RouteHopZ path_constr;
15123         path_constr.datalen = (*env)->GetArrayLength(env, path);
15124         if (path_constr.datalen > 0)
15125                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
15126         else
15127                 path_constr.data = NULL;
15128         int64_t* path_vals = (*env)->GetLongArrayElements (env, path, NULL);
15129         for (size_t k = 0; k < path_constr.datalen; k++) {
15130                 int64_t path_conv_10 = path_vals[k];
15131                 LDKRouteHop path_conv_10_conv;
15132                 path_conv_10_conv.inner = untag_ptr(path_conv_10);
15133                 path_conv_10_conv.is_owned = ptr_is_owned(path_conv_10);
15134                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
15135                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
15136                 path_constr.data[k] = path_conv_10_conv;
15137         }
15138         (*env)->ReleaseLongArrayElements(env, path, path_vals, 0);
15139         (this_arg_conv->notify_payment_path_failed)(this_arg_conv->this_arg, path_constr, short_channel_id);
15140 }
15141
15142 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Router_1notify_1payment_1path_1successful(JNIEnv *env, jclass clz, int64_t this_arg, int64_tArray path) {
15143         void* this_arg_ptr = untag_ptr(this_arg);
15144         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
15145         LDKRouter* this_arg_conv = (LDKRouter*)this_arg_ptr;
15146         LDKCVec_RouteHopZ path_constr;
15147         path_constr.datalen = (*env)->GetArrayLength(env, path);
15148         if (path_constr.datalen > 0)
15149                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
15150         else
15151                 path_constr.data = NULL;
15152         int64_t* path_vals = (*env)->GetLongArrayElements (env, path, NULL);
15153         for (size_t k = 0; k < path_constr.datalen; k++) {
15154                 int64_t path_conv_10 = path_vals[k];
15155                 LDKRouteHop path_conv_10_conv;
15156                 path_conv_10_conv.inner = untag_ptr(path_conv_10);
15157                 path_conv_10_conv.is_owned = ptr_is_owned(path_conv_10);
15158                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
15159                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
15160                 path_constr.data[k] = path_conv_10_conv;
15161         }
15162         (*env)->ReleaseLongArrayElements(env, path, path_vals, 0);
15163         (this_arg_conv->notify_payment_path_successful)(this_arg_conv->this_arg, path_constr);
15164 }
15165
15166 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Router_1notify_1payment_1probe_1successful(JNIEnv *env, jclass clz, int64_t this_arg, int64_tArray path) {
15167         void* this_arg_ptr = untag_ptr(this_arg);
15168         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
15169         LDKRouter* this_arg_conv = (LDKRouter*)this_arg_ptr;
15170         LDKCVec_RouteHopZ path_constr;
15171         path_constr.datalen = (*env)->GetArrayLength(env, path);
15172         if (path_constr.datalen > 0)
15173                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
15174         else
15175                 path_constr.data = NULL;
15176         int64_t* path_vals = (*env)->GetLongArrayElements (env, path, NULL);
15177         for (size_t k = 0; k < path_constr.datalen; k++) {
15178                 int64_t path_conv_10 = path_vals[k];
15179                 LDKRouteHop path_conv_10_conv;
15180                 path_conv_10_conv.inner = untag_ptr(path_conv_10);
15181                 path_conv_10_conv.is_owned = ptr_is_owned(path_conv_10);
15182                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
15183                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
15184                 path_constr.data[k] = path_conv_10_conv;
15185         }
15186         (*env)->ReleaseLongArrayElements(env, path, path_vals, 0);
15187         (this_arg_conv->notify_payment_probe_successful)(this_arg_conv->this_arg, path_constr);
15188 }
15189
15190 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) {
15191         void* this_arg_ptr = untag_ptr(this_arg);
15192         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
15193         LDKRouter* this_arg_conv = (LDKRouter*)this_arg_ptr;
15194         LDKCVec_RouteHopZ path_constr;
15195         path_constr.datalen = (*env)->GetArrayLength(env, path);
15196         if (path_constr.datalen > 0)
15197                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
15198         else
15199                 path_constr.data = NULL;
15200         int64_t* path_vals = (*env)->GetLongArrayElements (env, path, NULL);
15201         for (size_t k = 0; k < path_constr.datalen; k++) {
15202                 int64_t path_conv_10 = path_vals[k];
15203                 LDKRouteHop path_conv_10_conv;
15204                 path_conv_10_conv.inner = untag_ptr(path_conv_10);
15205                 path_conv_10_conv.is_owned = ptr_is_owned(path_conv_10);
15206                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
15207                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
15208                 path_constr.data[k] = path_conv_10_conv;
15209         }
15210         (*env)->ReleaseLongArrayElements(env, path, path_vals, 0);
15211         (this_arg_conv->notify_payment_probe_failed)(this_arg_conv->this_arg, path_constr, short_channel_id);
15212 }
15213
15214 static jclass LDKDestination_Node_class = NULL;
15215 static jmethodID LDKDestination_Node_meth = NULL;
15216 static jclass LDKDestination_BlindedPath_class = NULL;
15217 static jmethodID LDKDestination_BlindedPath_meth = NULL;
15218 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKDestination_init (JNIEnv *env, jclass clz) {
15219         LDKDestination_Node_class =
15220                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKDestination$Node"));
15221         CHECK(LDKDestination_Node_class != NULL);
15222         LDKDestination_Node_meth = (*env)->GetMethodID(env, LDKDestination_Node_class, "<init>", "([B)V");
15223         CHECK(LDKDestination_Node_meth != NULL);
15224         LDKDestination_BlindedPath_class =
15225                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKDestination$BlindedPath"));
15226         CHECK(LDKDestination_BlindedPath_class != NULL);
15227         LDKDestination_BlindedPath_meth = (*env)->GetMethodID(env, LDKDestination_BlindedPath_class, "<init>", "(J)V");
15228         CHECK(LDKDestination_BlindedPath_meth != NULL);
15229 }
15230 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKDestination_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
15231         LDKDestination *obj = (LDKDestination*)untag_ptr(ptr);
15232         switch(obj->tag) {
15233                 case LDKDestination_Node: {
15234                         int8_tArray node_arr = (*env)->NewByteArray(env, 33);
15235                         (*env)->SetByteArrayRegion(env, node_arr, 0, 33, obj->node.compressed_form);
15236                         return (*env)->NewObject(env, LDKDestination_Node_class, LDKDestination_Node_meth, node_arr);
15237                 }
15238                 case LDKDestination_BlindedPath: {
15239                         LDKBlindedPath blinded_path_var = obj->blinded_path;
15240                         int64_t blinded_path_ref = 0;
15241                         CHECK_INNER_FIELD_ACCESS_OR_NULL(blinded_path_var);
15242                         blinded_path_ref = tag_ptr(blinded_path_var.inner, false);
15243                         return (*env)->NewObject(env, LDKDestination_BlindedPath_class, LDKDestination_BlindedPath_meth, blinded_path_ref);
15244                 }
15245                 default: abort();
15246         }
15247 }
15248 static jclass LDKOnionMessageContents_Custom_class = NULL;
15249 static jmethodID LDKOnionMessageContents_Custom_meth = NULL;
15250 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKOnionMessageContents_init (JNIEnv *env, jclass clz) {
15251         LDKOnionMessageContents_Custom_class =
15252                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKOnionMessageContents$Custom"));
15253         CHECK(LDKOnionMessageContents_Custom_class != NULL);
15254         LDKOnionMessageContents_Custom_meth = (*env)->GetMethodID(env, LDKOnionMessageContents_Custom_class, "<init>", "(J)V");
15255         CHECK(LDKOnionMessageContents_Custom_meth != NULL);
15256 }
15257 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKOnionMessageContents_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
15258         LDKOnionMessageContents *obj = (LDKOnionMessageContents*)untag_ptr(ptr);
15259         switch(obj->tag) {
15260                 case LDKOnionMessageContents_Custom: {
15261                         LDKCustomOnionMessageContents* custom_ret = MALLOC(sizeof(LDKCustomOnionMessageContents), "LDKCustomOnionMessageContents");
15262                         *custom_ret = CustomOnionMessageContents_clone(&obj->custom);
15263                         return (*env)->NewObject(env, LDKOnionMessageContents_Custom_class, LDKOnionMessageContents_Custom_meth, tag_ptr(custom_ret, true));
15264                 }
15265                 default: abort();
15266         }
15267 }
15268 static jclass LDKGossipSync_P2P_class = NULL;
15269 static jmethodID LDKGossipSync_P2P_meth = NULL;
15270 static jclass LDKGossipSync_Rapid_class = NULL;
15271 static jmethodID LDKGossipSync_Rapid_meth = NULL;
15272 static jclass LDKGossipSync_None_class = NULL;
15273 static jmethodID LDKGossipSync_None_meth = NULL;
15274 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKGossipSync_init (JNIEnv *env, jclass clz) {
15275         LDKGossipSync_P2P_class =
15276                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKGossipSync$P2P"));
15277         CHECK(LDKGossipSync_P2P_class != NULL);
15278         LDKGossipSync_P2P_meth = (*env)->GetMethodID(env, LDKGossipSync_P2P_class, "<init>", "(J)V");
15279         CHECK(LDKGossipSync_P2P_meth != NULL);
15280         LDKGossipSync_Rapid_class =
15281                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKGossipSync$Rapid"));
15282         CHECK(LDKGossipSync_Rapid_class != NULL);
15283         LDKGossipSync_Rapid_meth = (*env)->GetMethodID(env, LDKGossipSync_Rapid_class, "<init>", "(J)V");
15284         CHECK(LDKGossipSync_Rapid_meth != NULL);
15285         LDKGossipSync_None_class =
15286                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKGossipSync$None"));
15287         CHECK(LDKGossipSync_None_class != NULL);
15288         LDKGossipSync_None_meth = (*env)->GetMethodID(env, LDKGossipSync_None_class, "<init>", "()V");
15289         CHECK(LDKGossipSync_None_meth != NULL);
15290 }
15291 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKGossipSync_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
15292         LDKGossipSync *obj = (LDKGossipSync*)untag_ptr(ptr);
15293         switch(obj->tag) {
15294                 case LDKGossipSync_P2P: {
15295                         LDKP2PGossipSync p2p_var = obj->p2p;
15296                         int64_t p2p_ref = 0;
15297                         CHECK_INNER_FIELD_ACCESS_OR_NULL(p2p_var);
15298                         p2p_ref = tag_ptr(p2p_var.inner, false);
15299                         return (*env)->NewObject(env, LDKGossipSync_P2P_class, LDKGossipSync_P2P_meth, p2p_ref);
15300                 }
15301                 case LDKGossipSync_Rapid: {
15302                         LDKRapidGossipSync rapid_var = obj->rapid;
15303                         int64_t rapid_ref = 0;
15304                         CHECK_INNER_FIELD_ACCESS_OR_NULL(rapid_var);
15305                         rapid_ref = tag_ptr(rapid_var.inner, false);
15306                         return (*env)->NewObject(env, LDKGossipSync_Rapid_class, LDKGossipSync_Rapid_meth, rapid_ref);
15307                 }
15308                 case LDKGossipSync_None: {
15309                         return (*env)->NewObject(env, LDKGossipSync_None_class, LDKGossipSync_None_meth);
15310                 }
15311                 default: abort();
15312         }
15313 }
15314 static jclass LDKFallback_SegWitProgram_class = NULL;
15315 static jmethodID LDKFallback_SegWitProgram_meth = NULL;
15316 static jclass LDKFallback_PubKeyHash_class = NULL;
15317 static jmethodID LDKFallback_PubKeyHash_meth = NULL;
15318 static jclass LDKFallback_ScriptHash_class = NULL;
15319 static jmethodID LDKFallback_ScriptHash_meth = NULL;
15320 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKFallback_init (JNIEnv *env, jclass clz) {
15321         LDKFallback_SegWitProgram_class =
15322                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKFallback$SegWitProgram"));
15323         CHECK(LDKFallback_SegWitProgram_class != NULL);
15324         LDKFallback_SegWitProgram_meth = (*env)->GetMethodID(env, LDKFallback_SegWitProgram_class, "<init>", "(B[B)V");
15325         CHECK(LDKFallback_SegWitProgram_meth != NULL);
15326         LDKFallback_PubKeyHash_class =
15327                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKFallback$PubKeyHash"));
15328         CHECK(LDKFallback_PubKeyHash_class != NULL);
15329         LDKFallback_PubKeyHash_meth = (*env)->GetMethodID(env, LDKFallback_PubKeyHash_class, "<init>", "([B)V");
15330         CHECK(LDKFallback_PubKeyHash_meth != NULL);
15331         LDKFallback_ScriptHash_class =
15332                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKFallback$ScriptHash"));
15333         CHECK(LDKFallback_ScriptHash_class != NULL);
15334         LDKFallback_ScriptHash_meth = (*env)->GetMethodID(env, LDKFallback_ScriptHash_class, "<init>", "([B)V");
15335         CHECK(LDKFallback_ScriptHash_meth != NULL);
15336 }
15337 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKFallback_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
15338         LDKFallback *obj = (LDKFallback*)untag_ptr(ptr);
15339         switch(obj->tag) {
15340                 case LDKFallback_SegWitProgram: {
15341                         uint8_t version_val = obj->seg_wit_program.version._0;
15342                         LDKCVec_u8Z program_var = obj->seg_wit_program.program;
15343                         int8_tArray program_arr = (*env)->NewByteArray(env, program_var.datalen);
15344                         (*env)->SetByteArrayRegion(env, program_arr, 0, program_var.datalen, program_var.data);
15345                         return (*env)->NewObject(env, LDKFallback_SegWitProgram_class, LDKFallback_SegWitProgram_meth, version_val, program_arr);
15346                 }
15347                 case LDKFallback_PubKeyHash: {
15348                         int8_tArray pub_key_hash_arr = (*env)->NewByteArray(env, 20);
15349                         (*env)->SetByteArrayRegion(env, pub_key_hash_arr, 0, 20, obj->pub_key_hash.data);
15350                         return (*env)->NewObject(env, LDKFallback_PubKeyHash_class, LDKFallback_PubKeyHash_meth, pub_key_hash_arr);
15351                 }
15352                 case LDKFallback_ScriptHash: {
15353                         int8_tArray script_hash_arr = (*env)->NewByteArray(env, 20);
15354                         (*env)->SetByteArrayRegion(env, script_hash_arr, 0, 20, obj->script_hash.data);
15355                         return (*env)->NewObject(env, LDKFallback_ScriptHash_class, LDKFallback_ScriptHash_meth, script_hash_arr);
15356                 }
15357                 default: abort();
15358         }
15359 }
15360 typedef struct LDKPayer_JCalls {
15361         atomic_size_t refcnt;
15362         JavaVM *vm;
15363         jweak o;
15364         jmethodID node_id_meth;
15365         jmethodID first_hops_meth;
15366         jmethodID send_payment_meth;
15367         jmethodID send_spontaneous_payment_meth;
15368         jmethodID retry_payment_meth;
15369         jmethodID abandon_payment_meth;
15370         jmethodID inflight_htlcs_meth;
15371 } LDKPayer_JCalls;
15372 static void LDKPayer_JCalls_free(void* this_arg) {
15373         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
15374         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
15375                 JNIEnv *env;
15376                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
15377                 if (get_jenv_res == JNI_EDETACHED) {
15378                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
15379                 } else {
15380                         DO_ASSERT(get_jenv_res == JNI_OK);
15381                 }
15382                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
15383                 if (get_jenv_res == JNI_EDETACHED) {
15384                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
15385                 }
15386                 FREE(j_calls);
15387         }
15388 }
15389 LDKPublicKey node_id_LDKPayer_jcall(const void* this_arg) {
15390         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
15391         JNIEnv *env;
15392         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
15393         if (get_jenv_res == JNI_EDETACHED) {
15394                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
15395         } else {
15396                 DO_ASSERT(get_jenv_res == JNI_OK);
15397         }
15398         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
15399         CHECK(obj != NULL);
15400         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->node_id_meth);
15401         if (UNLIKELY((*env)->ExceptionCheck(env))) {
15402                 (*env)->ExceptionDescribe(env);
15403                 (*env)->FatalError(env, "A call to node_id in LDKPayer from rust threw an exception.");
15404         }
15405         LDKPublicKey ret_ref;
15406         CHECK((*env)->GetArrayLength(env, ret) == 33);
15407         (*env)->GetByteArrayRegion(env, ret, 0, 33, ret_ref.compressed_form);
15408         if (get_jenv_res == JNI_EDETACHED) {
15409                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
15410         }
15411         return ret_ref;
15412 }
15413 LDKCVec_ChannelDetailsZ first_hops_LDKPayer_jcall(const void* this_arg) {
15414         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
15415         JNIEnv *env;
15416         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
15417         if (get_jenv_res == JNI_EDETACHED) {
15418                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
15419         } else {
15420                 DO_ASSERT(get_jenv_res == JNI_OK);
15421         }
15422         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
15423         CHECK(obj != NULL);
15424         int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->first_hops_meth);
15425         if (UNLIKELY((*env)->ExceptionCheck(env))) {
15426                 (*env)->ExceptionDescribe(env);
15427                 (*env)->FatalError(env, "A call to first_hops in LDKPayer from rust threw an exception.");
15428         }
15429         LDKCVec_ChannelDetailsZ ret_constr;
15430         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
15431         if (ret_constr.datalen > 0)
15432                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
15433         else
15434                 ret_constr.data = NULL;
15435         int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
15436         for (size_t q = 0; q < ret_constr.datalen; q++) {
15437                 int64_t ret_conv_16 = ret_vals[q];
15438                 LDKChannelDetails ret_conv_16_conv;
15439                 ret_conv_16_conv.inner = untag_ptr(ret_conv_16);
15440                 ret_conv_16_conv.is_owned = ptr_is_owned(ret_conv_16);
15441                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_conv);
15442                 ret_constr.data[q] = ret_conv_16_conv;
15443         }
15444         (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
15445         if (get_jenv_res == JNI_EDETACHED) {
15446                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
15447         }
15448         return ret_constr;
15449 }
15450 LDKCResult_NonePaymentSendFailureZ send_payment_LDKPayer_jcall(const void* this_arg, const LDKRoute * route, LDKThirtyTwoBytes payment_hash, LDKThirtyTwoBytes payment_secret, LDKThirtyTwoBytes payment_id) {
15451         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
15452         JNIEnv *env;
15453         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
15454         if (get_jenv_res == JNI_EDETACHED) {
15455                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
15456         } else {
15457                 DO_ASSERT(get_jenv_res == JNI_OK);
15458         }
15459         LDKRoute route_var = *route;
15460         int64_t route_ref = 0;
15461         route_var = Route_clone(&route_var);
15462         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_var);
15463         route_ref = tag_ptr(route_var.inner, route_var.is_owned);
15464         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
15465         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, payment_hash.data);
15466         int8_tArray payment_secret_arr = (*env)->NewByteArray(env, 32);
15467         (*env)->SetByteArrayRegion(env, payment_secret_arr, 0, 32, payment_secret.data);
15468         int8_tArray payment_id_arr = (*env)->NewByteArray(env, 32);
15469         (*env)->SetByteArrayRegion(env, payment_id_arr, 0, 32, payment_id.data);
15470         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
15471         CHECK(obj != NULL);
15472         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->send_payment_meth, route_ref, payment_hash_arr, payment_secret_arr, payment_id_arr);
15473         if (UNLIKELY((*env)->ExceptionCheck(env))) {
15474                 (*env)->ExceptionDescribe(env);
15475                 (*env)->FatalError(env, "A call to send_payment in LDKPayer from rust threw an exception.");
15476         }
15477         void* ret_ptr = untag_ptr(ret);
15478         CHECK_ACCESS(ret_ptr);
15479         LDKCResult_NonePaymentSendFailureZ ret_conv = *(LDKCResult_NonePaymentSendFailureZ*)(ret_ptr);
15480         FREE(untag_ptr(ret));
15481         if (get_jenv_res == JNI_EDETACHED) {
15482                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
15483         }
15484         return ret_conv;
15485 }
15486 LDKCResult_NonePaymentSendFailureZ send_spontaneous_payment_LDKPayer_jcall(const void* this_arg, const LDKRoute * route, LDKThirtyTwoBytes payment_preimage, LDKThirtyTwoBytes payment_id) {
15487         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
15488         JNIEnv *env;
15489         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
15490         if (get_jenv_res == JNI_EDETACHED) {
15491                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
15492         } else {
15493                 DO_ASSERT(get_jenv_res == JNI_OK);
15494         }
15495         LDKRoute route_var = *route;
15496         int64_t route_ref = 0;
15497         route_var = Route_clone(&route_var);
15498         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_var);
15499         route_ref = tag_ptr(route_var.inner, route_var.is_owned);
15500         int8_tArray payment_preimage_arr = (*env)->NewByteArray(env, 32);
15501         (*env)->SetByteArrayRegion(env, payment_preimage_arr, 0, 32, payment_preimage.data);
15502         int8_tArray payment_id_arr = (*env)->NewByteArray(env, 32);
15503         (*env)->SetByteArrayRegion(env, payment_id_arr, 0, 32, payment_id.data);
15504         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
15505         CHECK(obj != NULL);
15506         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->send_spontaneous_payment_meth, route_ref, payment_preimage_arr, payment_id_arr);
15507         if (UNLIKELY((*env)->ExceptionCheck(env))) {
15508                 (*env)->ExceptionDescribe(env);
15509                 (*env)->FatalError(env, "A call to send_spontaneous_payment in LDKPayer from rust threw an exception.");
15510         }
15511         void* ret_ptr = untag_ptr(ret);
15512         CHECK_ACCESS(ret_ptr);
15513         LDKCResult_NonePaymentSendFailureZ ret_conv = *(LDKCResult_NonePaymentSendFailureZ*)(ret_ptr);
15514         FREE(untag_ptr(ret));
15515         if (get_jenv_res == JNI_EDETACHED) {
15516                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
15517         }
15518         return ret_conv;
15519 }
15520 LDKCResult_NonePaymentSendFailureZ retry_payment_LDKPayer_jcall(const void* this_arg, const LDKRoute * route, LDKThirtyTwoBytes payment_id) {
15521         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
15522         JNIEnv *env;
15523         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
15524         if (get_jenv_res == JNI_EDETACHED) {
15525                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
15526         } else {
15527                 DO_ASSERT(get_jenv_res == JNI_OK);
15528         }
15529         LDKRoute route_var = *route;
15530         int64_t route_ref = 0;
15531         route_var = Route_clone(&route_var);
15532         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_var);
15533         route_ref = tag_ptr(route_var.inner, route_var.is_owned);
15534         int8_tArray payment_id_arr = (*env)->NewByteArray(env, 32);
15535         (*env)->SetByteArrayRegion(env, payment_id_arr, 0, 32, payment_id.data);
15536         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
15537         CHECK(obj != NULL);
15538         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->retry_payment_meth, route_ref, payment_id_arr);
15539         if (UNLIKELY((*env)->ExceptionCheck(env))) {
15540                 (*env)->ExceptionDescribe(env);
15541                 (*env)->FatalError(env, "A call to retry_payment in LDKPayer from rust threw an exception.");
15542         }
15543         void* ret_ptr = untag_ptr(ret);
15544         CHECK_ACCESS(ret_ptr);
15545         LDKCResult_NonePaymentSendFailureZ ret_conv = *(LDKCResult_NonePaymentSendFailureZ*)(ret_ptr);
15546         FREE(untag_ptr(ret));
15547         if (get_jenv_res == JNI_EDETACHED) {
15548                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
15549         }
15550         return ret_conv;
15551 }
15552 void abandon_payment_LDKPayer_jcall(const void* this_arg, LDKThirtyTwoBytes payment_id) {
15553         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
15554         JNIEnv *env;
15555         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
15556         if (get_jenv_res == JNI_EDETACHED) {
15557                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
15558         } else {
15559                 DO_ASSERT(get_jenv_res == JNI_OK);
15560         }
15561         int8_tArray payment_id_arr = (*env)->NewByteArray(env, 32);
15562         (*env)->SetByteArrayRegion(env, payment_id_arr, 0, 32, payment_id.data);
15563         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
15564         CHECK(obj != NULL);
15565         (*env)->CallVoidMethod(env, obj, j_calls->abandon_payment_meth, payment_id_arr);
15566         if (UNLIKELY((*env)->ExceptionCheck(env))) {
15567                 (*env)->ExceptionDescribe(env);
15568                 (*env)->FatalError(env, "A call to abandon_payment in LDKPayer from rust threw an exception.");
15569         }
15570         if (get_jenv_res == JNI_EDETACHED) {
15571                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
15572         }
15573 }
15574 LDKInFlightHtlcs inflight_htlcs_LDKPayer_jcall(const void* this_arg) {
15575         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
15576         JNIEnv *env;
15577         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
15578         if (get_jenv_res == JNI_EDETACHED) {
15579                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
15580         } else {
15581                 DO_ASSERT(get_jenv_res == JNI_OK);
15582         }
15583         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
15584         CHECK(obj != NULL);
15585         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->inflight_htlcs_meth);
15586         if (UNLIKELY((*env)->ExceptionCheck(env))) {
15587                 (*env)->ExceptionDescribe(env);
15588                 (*env)->FatalError(env, "A call to inflight_htlcs in LDKPayer from rust threw an exception.");
15589         }
15590         LDKInFlightHtlcs ret_conv;
15591         ret_conv.inner = untag_ptr(ret);
15592         ret_conv.is_owned = ptr_is_owned(ret);
15593         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv);
15594         if (get_jenv_res == JNI_EDETACHED) {
15595                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
15596         }
15597         return ret_conv;
15598 }
15599 static void LDKPayer_JCalls_cloned(LDKPayer* new_obj) {
15600         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) new_obj->this_arg;
15601         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
15602 }
15603 static inline LDKPayer LDKPayer_init (JNIEnv *env, jclass clz, jobject o) {
15604         jclass c = (*env)->GetObjectClass(env, o);
15605         CHECK(c != NULL);
15606         LDKPayer_JCalls *calls = MALLOC(sizeof(LDKPayer_JCalls), "LDKPayer_JCalls");
15607         atomic_init(&calls->refcnt, 1);
15608         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
15609         calls->o = (*env)->NewWeakGlobalRef(env, o);
15610         calls->node_id_meth = (*env)->GetMethodID(env, c, "node_id", "()[B");
15611         CHECK(calls->node_id_meth != NULL);
15612         calls->first_hops_meth = (*env)->GetMethodID(env, c, "first_hops", "()[J");
15613         CHECK(calls->first_hops_meth != NULL);
15614         calls->send_payment_meth = (*env)->GetMethodID(env, c, "send_payment", "(J[B[B[B)J");
15615         CHECK(calls->send_payment_meth != NULL);
15616         calls->send_spontaneous_payment_meth = (*env)->GetMethodID(env, c, "send_spontaneous_payment", "(J[B[B)J");
15617         CHECK(calls->send_spontaneous_payment_meth != NULL);
15618         calls->retry_payment_meth = (*env)->GetMethodID(env, c, "retry_payment", "(J[B)J");
15619         CHECK(calls->retry_payment_meth != NULL);
15620         calls->abandon_payment_meth = (*env)->GetMethodID(env, c, "abandon_payment", "([B)V");
15621         CHECK(calls->abandon_payment_meth != NULL);
15622         calls->inflight_htlcs_meth = (*env)->GetMethodID(env, c, "inflight_htlcs", "()J");
15623         CHECK(calls->inflight_htlcs_meth != NULL);
15624
15625         LDKPayer ret = {
15626                 .this_arg = (void*) calls,
15627                 .node_id = node_id_LDKPayer_jcall,
15628                 .first_hops = first_hops_LDKPayer_jcall,
15629                 .send_payment = send_payment_LDKPayer_jcall,
15630                 .send_spontaneous_payment = send_spontaneous_payment_LDKPayer_jcall,
15631                 .retry_payment = retry_payment_LDKPayer_jcall,
15632                 .abandon_payment = abandon_payment_LDKPayer_jcall,
15633                 .inflight_htlcs = inflight_htlcs_LDKPayer_jcall,
15634                 .free = LDKPayer_JCalls_free,
15635         };
15636         return ret;
15637 }
15638 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKPayer_1new(JNIEnv *env, jclass clz, jobject o) {
15639         LDKPayer *res_ptr = MALLOC(sizeof(LDKPayer), "LDKPayer");
15640         *res_ptr = LDKPayer_init(env, clz, o);
15641         return tag_ptr(res_ptr, true);
15642 }
15643 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Payer_1node_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
15644         void* this_arg_ptr = untag_ptr(this_arg);
15645         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
15646         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
15647         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
15648         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, (this_arg_conv->node_id)(this_arg_conv->this_arg).compressed_form);
15649         return ret_arr;
15650 }
15651
15652 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_Payer_1first_1hops(JNIEnv *env, jclass clz, int64_t this_arg) {
15653         void* this_arg_ptr = untag_ptr(this_arg);
15654         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
15655         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
15656         LDKCVec_ChannelDetailsZ ret_var = (this_arg_conv->first_hops)(this_arg_conv->this_arg);
15657         int64_tArray ret_arr = NULL;
15658         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
15659         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
15660         for (size_t q = 0; q < ret_var.datalen; q++) {
15661                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
15662                 int64_t ret_conv_16_ref = 0;
15663                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
15664                 ret_conv_16_ref = tag_ptr(ret_conv_16_var.inner, ret_conv_16_var.is_owned);
15665                 ret_arr_ptr[q] = ret_conv_16_ref;
15666         }
15667         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
15668         FREE(ret_var.data);
15669         return ret_arr;
15670 }
15671
15672 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, int8_tArray payment_id) {
15673         void* this_arg_ptr = untag_ptr(this_arg);
15674         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
15675         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
15676         LDKRoute route_conv;
15677         route_conv.inner = untag_ptr(route);
15678         route_conv.is_owned = ptr_is_owned(route);
15679         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
15680         route_conv.is_owned = false;
15681         LDKThirtyTwoBytes payment_hash_ref;
15682         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
15683         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
15684         LDKThirtyTwoBytes payment_secret_ref;
15685         CHECK((*env)->GetArrayLength(env, payment_secret) == 32);
15686         (*env)->GetByteArrayRegion(env, payment_secret, 0, 32, payment_secret_ref.data);
15687         LDKThirtyTwoBytes payment_id_ref;
15688         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
15689         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
15690         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
15691         *ret_conv = (this_arg_conv->send_payment)(this_arg_conv->this_arg, &route_conv, payment_hash_ref, payment_secret_ref, payment_id_ref);
15692         return tag_ptr(ret_conv, true);
15693 }
15694
15695 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, int8_tArray payment_id) {
15696         void* this_arg_ptr = untag_ptr(this_arg);
15697         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
15698         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
15699         LDKRoute route_conv;
15700         route_conv.inner = untag_ptr(route);
15701         route_conv.is_owned = ptr_is_owned(route);
15702         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
15703         route_conv.is_owned = false;
15704         LDKThirtyTwoBytes payment_preimage_ref;
15705         CHECK((*env)->GetArrayLength(env, payment_preimage) == 32);
15706         (*env)->GetByteArrayRegion(env, payment_preimage, 0, 32, payment_preimage_ref.data);
15707         LDKThirtyTwoBytes payment_id_ref;
15708         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
15709         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
15710         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
15711         *ret_conv = (this_arg_conv->send_spontaneous_payment)(this_arg_conv->this_arg, &route_conv, payment_preimage_ref, payment_id_ref);
15712         return tag_ptr(ret_conv, true);
15713 }
15714
15715 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) {
15716         void* this_arg_ptr = untag_ptr(this_arg);
15717         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
15718         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
15719         LDKRoute route_conv;
15720         route_conv.inner = untag_ptr(route);
15721         route_conv.is_owned = ptr_is_owned(route);
15722         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
15723         route_conv.is_owned = false;
15724         LDKThirtyTwoBytes payment_id_ref;
15725         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
15726         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
15727         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
15728         *ret_conv = (this_arg_conv->retry_payment)(this_arg_conv->this_arg, &route_conv, payment_id_ref);
15729         return tag_ptr(ret_conv, true);
15730 }
15731
15732 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Payer_1abandon_1payment(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray payment_id) {
15733         void* this_arg_ptr = untag_ptr(this_arg);
15734         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
15735         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
15736         LDKThirtyTwoBytes payment_id_ref;
15737         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
15738         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
15739         (this_arg_conv->abandon_payment)(this_arg_conv->this_arg, payment_id_ref);
15740 }
15741
15742 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Payer_1inflight_1htlcs(JNIEnv *env, jclass clz, int64_t this_arg) {
15743         void* this_arg_ptr = untag_ptr(this_arg);
15744         if (ptr_is_owned(this_arg)) { CHECK_ACCESS(this_arg_ptr); }
15745         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
15746         LDKInFlightHtlcs ret_var = (this_arg_conv->inflight_htlcs)(this_arg_conv->this_arg);
15747         int64_t ret_ref = 0;
15748         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
15749         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
15750         return ret_ref;
15751 }
15752
15753 static jclass LDKRetry_Attempts_class = NULL;
15754 static jmethodID LDKRetry_Attempts_meth = NULL;
15755 static jclass LDKRetry_Timeout_class = NULL;
15756 static jmethodID LDKRetry_Timeout_meth = NULL;
15757 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKRetry_init (JNIEnv *env, jclass clz) {
15758         LDKRetry_Attempts_class =
15759                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKRetry$Attempts"));
15760         CHECK(LDKRetry_Attempts_class != NULL);
15761         LDKRetry_Attempts_meth = (*env)->GetMethodID(env, LDKRetry_Attempts_class, "<init>", "(J)V");
15762         CHECK(LDKRetry_Attempts_meth != NULL);
15763         LDKRetry_Timeout_class =
15764                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "org/ldk/impl/bindings$LDKRetry$Timeout"));
15765         CHECK(LDKRetry_Timeout_class != NULL);
15766         LDKRetry_Timeout_meth = (*env)->GetMethodID(env, LDKRetry_Timeout_class, "<init>", "(J)V");
15767         CHECK(LDKRetry_Timeout_meth != NULL);
15768 }
15769 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKRetry_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
15770         LDKRetry *obj = (LDKRetry*)untag_ptr(ptr);
15771         switch(obj->tag) {
15772                 case LDKRetry_Attempts: {
15773                         int64_t attempts_conv = obj->attempts;
15774                         return (*env)->NewObject(env, LDKRetry_Attempts_class, LDKRetry_Attempts_meth, attempts_conv);
15775                 }
15776                 case LDKRetry_Timeout: {
15777                         int64_t timeout_conv = obj->timeout;
15778                         return (*env)->NewObject(env, LDKRetry_Timeout_class, LDKRetry_Timeout_meth, timeout_conv);
15779                 }
15780                 default: abort();
15781         }
15782 }
15783 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings__1ldk_1get_1compiled_1version(JNIEnv *env, jclass clz) {
15784         LDKStr ret_str = _ldk_get_compiled_version();
15785         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
15786         Str_free(ret_str);
15787         return ret_conv;
15788 }
15789
15790 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings__1ldk_1c_1bindings_1get_1compiled_1version(JNIEnv *env, jclass clz) {
15791         LDKStr ret_str = _ldk_c_bindings_get_compiled_version();
15792         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
15793         Str_free(ret_str);
15794         return ret_conv;
15795 }
15796
15797 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_U128_1le_1bytes(JNIEnv *env, jclass clz, int8_tArray val) {
15798         LDKU128 val_ref;
15799         CHECK((*env)->GetArrayLength(env, val) == 16);
15800         (*env)->GetByteArrayRegion(env, val, 0, 16, val_ref.le_bytes);
15801         int8_tArray ret_arr = (*env)->NewByteArray(env, 16);
15802         (*env)->SetByteArrayRegion(env, ret_arr, 0, 16, U128_le_bytes(val_ref).data);
15803         return ret_arr;
15804 }
15805
15806 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_U128_1new(JNIEnv *env, jclass clz, int8_tArray le_bytes) {
15807         LDKSixteenBytes le_bytes_ref;
15808         CHECK((*env)->GetArrayLength(env, le_bytes) == 16);
15809         (*env)->GetByteArrayRegion(env, le_bytes, 0, 16, le_bytes_ref.data);
15810         int8_tArray ret_arr = (*env)->NewByteArray(env, 16);
15811         (*env)->SetByteArrayRegion(env, ret_arr, 0, 16, U128_new(le_bytes_ref).le_bytes);
15812         return ret_arr;
15813 }
15814
15815 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BigEndianScalar_1new(JNIEnv *env, jclass clz, int8_tArray big_endian_bytes) {
15816         LDKThirtyTwoBytes big_endian_bytes_ref;
15817         CHECK((*env)->GetArrayLength(env, big_endian_bytes) == 32);
15818         (*env)->GetByteArrayRegion(env, big_endian_bytes, 0, 32, big_endian_bytes_ref.data);
15819         LDKBigEndianScalar* ret_ref = MALLOC(sizeof(LDKBigEndianScalar), "LDKBigEndianScalar");
15820         *ret_ref = BigEndianScalar_new(big_endian_bytes_ref);
15821         return tag_ptr(ret_ref, true);
15822 }
15823
15824 static inline uint64_t Bech32Error_clone_ptr(LDKBech32Error *NONNULL_PTR arg) {
15825         LDKBech32Error *ret_copy = MALLOC(sizeof(LDKBech32Error), "LDKBech32Error");
15826         *ret_copy = Bech32Error_clone(arg);
15827         int64_t ret_ref = tag_ptr(ret_copy, true);
15828         return ret_ref;
15829 }
15830 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Bech32Error_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15831         LDKBech32Error* arg_conv = (LDKBech32Error*)untag_ptr(arg);
15832         int64_t ret_conv = Bech32Error_clone_ptr(arg_conv);
15833         return ret_conv;
15834 }
15835
15836 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Bech32Error_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15837         LDKBech32Error* orig_conv = (LDKBech32Error*)untag_ptr(orig);
15838         LDKBech32Error *ret_copy = MALLOC(sizeof(LDKBech32Error), "LDKBech32Error");
15839         *ret_copy = Bech32Error_clone(orig_conv);
15840         int64_t ret_ref = tag_ptr(ret_copy, true);
15841         return ret_ref;
15842 }
15843
15844 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Bech32Error_1free(JNIEnv *env, jclass clz, int64_t o) {
15845         if (!ptr_is_owned(o)) return;
15846         void* o_ptr = untag_ptr(o);
15847         CHECK_ACCESS(o_ptr);
15848         LDKBech32Error o_conv = *(LDKBech32Error*)(o_ptr);
15849         FREE(untag_ptr(o));
15850         Bech32Error_free(o_conv);
15851 }
15852
15853 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Transaction_1free(JNIEnv *env, jclass clz, int8_tArray _res) {
15854         LDKTransaction _res_ref;
15855         _res_ref.datalen = (*env)->GetArrayLength(env, _res);
15856         _res_ref.data = MALLOC(_res_ref.datalen, "LDKTransaction Bytes");
15857         (*env)->GetByteArrayRegion(env, _res, 0, _res_ref.datalen, _res_ref.data);
15858         _res_ref.data_is_owned = true;
15859         Transaction_free(_res_ref);
15860 }
15861
15862 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Witness_1free(JNIEnv *env, jclass clz, int8_tArray _res) {
15863         LDKWitness _res_ref;
15864         _res_ref.datalen = (*env)->GetArrayLength(env, _res);
15865         _res_ref.data = MALLOC(_res_ref.datalen, "LDKWitness Bytes");
15866         (*env)->GetByteArrayRegion(env, _res, 0, _res_ref.datalen, _res_ref.data);
15867         _res_ref.data_is_owned = true;
15868         Witness_free(_res_ref);
15869 }
15870
15871 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxOut_1new(JNIEnv *env, jclass clz, int8_tArray script_pubkey, int64_t value) {
15872         LDKCVec_u8Z script_pubkey_ref;
15873         script_pubkey_ref.datalen = (*env)->GetArrayLength(env, script_pubkey);
15874         script_pubkey_ref.data = MALLOC(script_pubkey_ref.datalen, "LDKCVec_u8Z Bytes");
15875         (*env)->GetByteArrayRegion(env, script_pubkey, 0, script_pubkey_ref.datalen, script_pubkey_ref.data);
15876         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
15877         *ret_ref = TxOut_new(script_pubkey_ref, value);
15878         return tag_ptr(ret_ref, true);
15879 }
15880
15881 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxOut_1free(JNIEnv *env, jclass clz, int64_t _res) {
15882         if (!ptr_is_owned(_res)) return;
15883         void* _res_ptr = untag_ptr(_res);
15884         CHECK_ACCESS(_res_ptr);
15885         LDKTxOut _res_conv = *(LDKTxOut*)(_res_ptr);
15886         FREE(untag_ptr(_res));
15887         TxOut_free(_res_conv);
15888 }
15889
15890 static inline uint64_t TxOut_clone_ptr(LDKTxOut *NONNULL_PTR arg) {
15891         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
15892         *ret_ref = TxOut_clone(arg);
15893         return tag_ptr(ret_ref, true);
15894 }
15895 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxOut_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15896         LDKTxOut* arg_conv = (LDKTxOut*)untag_ptr(arg);
15897         int64_t ret_conv = TxOut_clone_ptr(arg_conv);
15898         return ret_conv;
15899 }
15900
15901 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxOut_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15902         LDKTxOut* orig_conv = (LDKTxOut*)untag_ptr(orig);
15903         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
15904         *ret_ref = TxOut_clone(orig_conv);
15905         return tag_ptr(ret_ref, true);
15906 }
15907
15908 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Str_1free(JNIEnv *env, jclass clz, jstring _res) {
15909         LDKStr dummy = { .chars = NULL, .len = 0, .chars_is_owned = false };
15910         Str_free(dummy);
15911 }
15912
15913 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1HTLCClaimZ_1some(JNIEnv *env, jclass clz, jclass o) {
15914         LDKHTLCClaim o_conv = LDKHTLCClaim_from_java(env, o);
15915         LDKCOption_HTLCClaimZ *ret_copy = MALLOC(sizeof(LDKCOption_HTLCClaimZ), "LDKCOption_HTLCClaimZ");
15916         *ret_copy = COption_HTLCClaimZ_some(o_conv);
15917         int64_t ret_ref = tag_ptr(ret_copy, true);
15918         return ret_ref;
15919 }
15920
15921 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1HTLCClaimZ_1none(JNIEnv *env, jclass clz) {
15922         LDKCOption_HTLCClaimZ *ret_copy = MALLOC(sizeof(LDKCOption_HTLCClaimZ), "LDKCOption_HTLCClaimZ");
15923         *ret_copy = COption_HTLCClaimZ_none();
15924         int64_t ret_ref = tag_ptr(ret_copy, true);
15925         return ret_ref;
15926 }
15927
15928 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1HTLCClaimZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15929         if (!ptr_is_owned(_res)) return;
15930         void* _res_ptr = untag_ptr(_res);
15931         CHECK_ACCESS(_res_ptr);
15932         LDKCOption_HTLCClaimZ _res_conv = *(LDKCOption_HTLCClaimZ*)(_res_ptr);
15933         FREE(untag_ptr(_res));
15934         COption_HTLCClaimZ_free(_res_conv);
15935 }
15936
15937 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneNoneZ_1ok(JNIEnv *env, jclass clz) {
15938         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
15939         *ret_conv = CResult_NoneNoneZ_ok();
15940         return tag_ptr(ret_conv, true);
15941 }
15942
15943 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneNoneZ_1err(JNIEnv *env, jclass clz) {
15944         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
15945         *ret_conv = CResult_NoneNoneZ_err();
15946         return tag_ptr(ret_conv, true);
15947 }
15948
15949 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NoneNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15950         LDKCResult_NoneNoneZ* o_conv = (LDKCResult_NoneNoneZ*)untag_ptr(o);
15951         jboolean ret_conv = CResult_NoneNoneZ_is_ok(o_conv);
15952         return ret_conv;
15953 }
15954
15955 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15956         if (!ptr_is_owned(_res)) return;
15957         void* _res_ptr = untag_ptr(_res);
15958         CHECK_ACCESS(_res_ptr);
15959         LDKCResult_NoneNoneZ _res_conv = *(LDKCResult_NoneNoneZ*)(_res_ptr);
15960         FREE(untag_ptr(_res));
15961         CResult_NoneNoneZ_free(_res_conv);
15962 }
15963
15964 static inline uint64_t CResult_NoneNoneZ_clone_ptr(LDKCResult_NoneNoneZ *NONNULL_PTR arg) {
15965         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
15966         *ret_conv = CResult_NoneNoneZ_clone(arg);
15967         return tag_ptr(ret_conv, true);
15968 }
15969 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15970         LDKCResult_NoneNoneZ* arg_conv = (LDKCResult_NoneNoneZ*)untag_ptr(arg);
15971         int64_t ret_conv = CResult_NoneNoneZ_clone_ptr(arg_conv);
15972         return ret_conv;
15973 }
15974
15975 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15976         LDKCResult_NoneNoneZ* orig_conv = (LDKCResult_NoneNoneZ*)untag_ptr(orig);
15977         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
15978         *ret_conv = CResult_NoneNoneZ_clone(orig_conv);
15979         return tag_ptr(ret_conv, true);
15980 }
15981
15982 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyCommitmentSecretsDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15983         LDKCounterpartyCommitmentSecrets o_conv;
15984         o_conv.inner = untag_ptr(o);
15985         o_conv.is_owned = ptr_is_owned(o);
15986         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15987         o_conv = CounterpartyCommitmentSecrets_clone(&o_conv);
15988         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ), "LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ");
15989         *ret_conv = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_ok(o_conv);
15990         return tag_ptr(ret_conv, true);
15991 }
15992
15993 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyCommitmentSecretsDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15994         void* e_ptr = untag_ptr(e);
15995         CHECK_ACCESS(e_ptr);
15996         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
15997         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
15998         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ), "LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ");
15999         *ret_conv = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_err(e_conv);
16000         return tag_ptr(ret_conv, true);
16001 }
16002
16003 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyCommitmentSecretsDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16004         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* o_conv = (LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ*)untag_ptr(o);
16005         jboolean ret_conv = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_is_ok(o_conv);
16006         return ret_conv;
16007 }
16008
16009 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyCommitmentSecretsDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16010         if (!ptr_is_owned(_res)) return;
16011         void* _res_ptr = untag_ptr(_res);
16012         CHECK_ACCESS(_res_ptr);
16013         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ _res_conv = *(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ*)(_res_ptr);
16014         FREE(untag_ptr(_res));
16015         CResult_CounterpartyCommitmentSecretsDecodeErrorZ_free(_res_conv);
16016 }
16017
16018 static inline uint64_t CResult_CounterpartyCommitmentSecretsDecodeErrorZ_clone_ptr(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ *NONNULL_PTR arg) {
16019         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ), "LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ");
16020         *ret_conv = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_clone(arg);
16021         return tag_ptr(ret_conv, true);
16022 }
16023 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyCommitmentSecretsDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16024         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* arg_conv = (LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ*)untag_ptr(arg);
16025         int64_t ret_conv = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_clone_ptr(arg_conv);
16026         return ret_conv;
16027 }
16028
16029 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyCommitmentSecretsDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16030         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* orig_conv = (LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ*)untag_ptr(orig);
16031         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ), "LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ");
16032         *ret_conv = CResult_CounterpartyCommitmentSecretsDecodeErrorZ_clone(orig_conv);
16033         return tag_ptr(ret_conv, true);
16034 }
16035
16036 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16037         LDKTxCreationKeys o_conv;
16038         o_conv.inner = untag_ptr(o);
16039         o_conv.is_owned = ptr_is_owned(o);
16040         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16041         o_conv = TxCreationKeys_clone(&o_conv);
16042         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
16043         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_ok(o_conv);
16044         return tag_ptr(ret_conv, true);
16045 }
16046
16047 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16048         void* e_ptr = untag_ptr(e);
16049         CHECK_ACCESS(e_ptr);
16050         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
16051         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
16052         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
16053         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_err(e_conv);
16054         return tag_ptr(ret_conv, true);
16055 }
16056
16057 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16058         LDKCResult_TxCreationKeysDecodeErrorZ* o_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)untag_ptr(o);
16059         jboolean ret_conv = CResult_TxCreationKeysDecodeErrorZ_is_ok(o_conv);
16060         return ret_conv;
16061 }
16062
16063 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16064         if (!ptr_is_owned(_res)) return;
16065         void* _res_ptr = untag_ptr(_res);
16066         CHECK_ACCESS(_res_ptr);
16067         LDKCResult_TxCreationKeysDecodeErrorZ _res_conv = *(LDKCResult_TxCreationKeysDecodeErrorZ*)(_res_ptr);
16068         FREE(untag_ptr(_res));
16069         CResult_TxCreationKeysDecodeErrorZ_free(_res_conv);
16070 }
16071
16072 static inline uint64_t CResult_TxCreationKeysDecodeErrorZ_clone_ptr(LDKCResult_TxCreationKeysDecodeErrorZ *NONNULL_PTR arg) {
16073         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
16074         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_clone(arg);
16075         return tag_ptr(ret_conv, true);
16076 }
16077 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16078         LDKCResult_TxCreationKeysDecodeErrorZ* arg_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)untag_ptr(arg);
16079         int64_t ret_conv = CResult_TxCreationKeysDecodeErrorZ_clone_ptr(arg_conv);
16080         return ret_conv;
16081 }
16082
16083 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16084         LDKCResult_TxCreationKeysDecodeErrorZ* orig_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)untag_ptr(orig);
16085         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
16086         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_clone(orig_conv);
16087         return tag_ptr(ret_conv, true);
16088 }
16089
16090 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16091         LDKChannelPublicKeys o_conv;
16092         o_conv.inner = untag_ptr(o);
16093         o_conv.is_owned = ptr_is_owned(o);
16094         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16095         o_conv = ChannelPublicKeys_clone(&o_conv);
16096         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
16097         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_ok(o_conv);
16098         return tag_ptr(ret_conv, true);
16099 }
16100
16101 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16102         void* e_ptr = untag_ptr(e);
16103         CHECK_ACCESS(e_ptr);
16104         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
16105         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
16106         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
16107         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_err(e_conv);
16108         return tag_ptr(ret_conv, true);
16109 }
16110
16111 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16112         LDKCResult_ChannelPublicKeysDecodeErrorZ* o_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)untag_ptr(o);
16113         jboolean ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_is_ok(o_conv);
16114         return ret_conv;
16115 }
16116
16117 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16118         if (!ptr_is_owned(_res)) return;
16119         void* _res_ptr = untag_ptr(_res);
16120         CHECK_ACCESS(_res_ptr);
16121         LDKCResult_ChannelPublicKeysDecodeErrorZ _res_conv = *(LDKCResult_ChannelPublicKeysDecodeErrorZ*)(_res_ptr);
16122         FREE(untag_ptr(_res));
16123         CResult_ChannelPublicKeysDecodeErrorZ_free(_res_conv);
16124 }
16125
16126 static inline uint64_t CResult_ChannelPublicKeysDecodeErrorZ_clone_ptr(LDKCResult_ChannelPublicKeysDecodeErrorZ *NONNULL_PTR arg) {
16127         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
16128         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_clone(arg);
16129         return tag_ptr(ret_conv, true);
16130 }
16131 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16132         LDKCResult_ChannelPublicKeysDecodeErrorZ* arg_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)untag_ptr(arg);
16133         int64_t ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_clone_ptr(arg_conv);
16134         return ret_conv;
16135 }
16136
16137 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16138         LDKCResult_ChannelPublicKeysDecodeErrorZ* orig_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)untag_ptr(orig);
16139         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
16140         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_clone(orig_conv);
16141         return tag_ptr(ret_conv, true);
16142 }
16143
16144 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u32Z_1some(JNIEnv *env, jclass clz, int32_t o) {
16145         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
16146         *ret_copy = COption_u32Z_some(o);
16147         int64_t ret_ref = tag_ptr(ret_copy, true);
16148         return ret_ref;
16149 }
16150
16151 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u32Z_1none(JNIEnv *env, jclass clz) {
16152         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
16153         *ret_copy = COption_u32Z_none();
16154         int64_t ret_ref = tag_ptr(ret_copy, true);
16155         return ret_ref;
16156 }
16157
16158 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1u32Z_1free(JNIEnv *env, jclass clz, int64_t _res) {
16159         if (!ptr_is_owned(_res)) return;
16160         void* _res_ptr = untag_ptr(_res);
16161         CHECK_ACCESS(_res_ptr);
16162         LDKCOption_u32Z _res_conv = *(LDKCOption_u32Z*)(_res_ptr);
16163         FREE(untag_ptr(_res));
16164         COption_u32Z_free(_res_conv);
16165 }
16166
16167 static inline uint64_t COption_u32Z_clone_ptr(LDKCOption_u32Z *NONNULL_PTR arg) {
16168         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
16169         *ret_copy = COption_u32Z_clone(arg);
16170         int64_t ret_ref = tag_ptr(ret_copy, true);
16171         return ret_ref;
16172 }
16173 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u32Z_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16174         LDKCOption_u32Z* arg_conv = (LDKCOption_u32Z*)untag_ptr(arg);
16175         int64_t ret_conv = COption_u32Z_clone_ptr(arg_conv);
16176         return ret_conv;
16177 }
16178
16179 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u32Z_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16180         LDKCOption_u32Z* orig_conv = (LDKCOption_u32Z*)untag_ptr(orig);
16181         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
16182         *ret_copy = COption_u32Z_clone(orig_conv);
16183         int64_t ret_ref = tag_ptr(ret_copy, true);
16184         return ret_ref;
16185 }
16186
16187 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16188         LDKHTLCOutputInCommitment o_conv;
16189         o_conv.inner = untag_ptr(o);
16190         o_conv.is_owned = ptr_is_owned(o);
16191         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16192         o_conv = HTLCOutputInCommitment_clone(&o_conv);
16193         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
16194         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_ok(o_conv);
16195         return tag_ptr(ret_conv, true);
16196 }
16197
16198 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16199         void* e_ptr = untag_ptr(e);
16200         CHECK_ACCESS(e_ptr);
16201         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
16202         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
16203         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
16204         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_err(e_conv);
16205         return tag_ptr(ret_conv, true);
16206 }
16207
16208 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16209         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* o_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)untag_ptr(o);
16210         jboolean ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_is_ok(o_conv);
16211         return ret_conv;
16212 }
16213
16214 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16215         if (!ptr_is_owned(_res)) return;
16216         void* _res_ptr = untag_ptr(_res);
16217         CHECK_ACCESS(_res_ptr);
16218         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ _res_conv = *(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(_res_ptr);
16219         FREE(untag_ptr(_res));
16220         CResult_HTLCOutputInCommitmentDecodeErrorZ_free(_res_conv);
16221 }
16222
16223 static inline uint64_t CResult_HTLCOutputInCommitmentDecodeErrorZ_clone_ptr(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ *NONNULL_PTR arg) {
16224         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
16225         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_clone(arg);
16226         return tag_ptr(ret_conv, true);
16227 }
16228 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16229         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* arg_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)untag_ptr(arg);
16230         int64_t ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_clone_ptr(arg_conv);
16231         return ret_conv;
16232 }
16233
16234 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16235         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* orig_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)untag_ptr(orig);
16236         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
16237         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_clone(orig_conv);
16238         return tag_ptr(ret_conv, true);
16239 }
16240
16241 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_COption_1NoneZ_1some(JNIEnv *env, jclass clz) {
16242         jclass ret_conv = LDKCOption_NoneZ_to_java(env, COption_NoneZ_some());
16243         return ret_conv;
16244 }
16245
16246 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_COption_1NoneZ_1none(JNIEnv *env, jclass clz) {
16247         jclass ret_conv = LDKCOption_NoneZ_to_java(env, COption_NoneZ_none());
16248         return ret_conv;
16249 }
16250
16251 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1NoneZ_1free(JNIEnv *env, jclass clz, jclass _res) {
16252         LDKCOption_NoneZ _res_conv = LDKCOption_NoneZ_from_java(env, _res);
16253         COption_NoneZ_free(_res_conv);
16254 }
16255
16256 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16257         LDKCounterpartyChannelTransactionParameters o_conv;
16258         o_conv.inner = untag_ptr(o);
16259         o_conv.is_owned = ptr_is_owned(o);
16260         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16261         o_conv = CounterpartyChannelTransactionParameters_clone(&o_conv);
16262         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
16263         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_ok(o_conv);
16264         return tag_ptr(ret_conv, true);
16265 }
16266
16267 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16268         void* e_ptr = untag_ptr(e);
16269         CHECK_ACCESS(e_ptr);
16270         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
16271         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
16272         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
16273         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_err(e_conv);
16274         return tag_ptr(ret_conv, true);
16275 }
16276
16277 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16278         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* o_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)untag_ptr(o);
16279         jboolean ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_is_ok(o_conv);
16280         return ret_conv;
16281 }
16282
16283 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16284         if (!ptr_is_owned(_res)) return;
16285         void* _res_ptr = untag_ptr(_res);
16286         CHECK_ACCESS(_res_ptr);
16287         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ _res_conv = *(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(_res_ptr);
16288         FREE(untag_ptr(_res));
16289         CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_free(_res_conv);
16290 }
16291
16292 static inline uint64_t CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone_ptr(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ *NONNULL_PTR arg) {
16293         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
16294         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone(arg);
16295         return tag_ptr(ret_conv, true);
16296 }
16297 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16298         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* arg_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)untag_ptr(arg);
16299         int64_t ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone_ptr(arg_conv);
16300         return ret_conv;
16301 }
16302
16303 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16304         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* orig_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)untag_ptr(orig);
16305         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
16306         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone(orig_conv);
16307         return tag_ptr(ret_conv, true);
16308 }
16309
16310 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16311         LDKChannelTransactionParameters o_conv;
16312         o_conv.inner = untag_ptr(o);
16313         o_conv.is_owned = ptr_is_owned(o);
16314         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16315         o_conv = ChannelTransactionParameters_clone(&o_conv);
16316         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
16317         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_ok(o_conv);
16318         return tag_ptr(ret_conv, true);
16319 }
16320
16321 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16322         void* e_ptr = untag_ptr(e);
16323         CHECK_ACCESS(e_ptr);
16324         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
16325         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
16326         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
16327         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_err(e_conv);
16328         return tag_ptr(ret_conv, true);
16329 }
16330
16331 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16332         LDKCResult_ChannelTransactionParametersDecodeErrorZ* o_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)untag_ptr(o);
16333         jboolean ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_is_ok(o_conv);
16334         return ret_conv;
16335 }
16336
16337 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16338         if (!ptr_is_owned(_res)) return;
16339         void* _res_ptr = untag_ptr(_res);
16340         CHECK_ACCESS(_res_ptr);
16341         LDKCResult_ChannelTransactionParametersDecodeErrorZ _res_conv = *(LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(_res_ptr);
16342         FREE(untag_ptr(_res));
16343         CResult_ChannelTransactionParametersDecodeErrorZ_free(_res_conv);
16344 }
16345
16346 static inline uint64_t CResult_ChannelTransactionParametersDecodeErrorZ_clone_ptr(LDKCResult_ChannelTransactionParametersDecodeErrorZ *NONNULL_PTR arg) {
16347         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
16348         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_clone(arg);
16349         return tag_ptr(ret_conv, true);
16350 }
16351 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16352         LDKCResult_ChannelTransactionParametersDecodeErrorZ* arg_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)untag_ptr(arg);
16353         int64_t ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_clone_ptr(arg_conv);
16354         return ret_conv;
16355 }
16356
16357 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16358         LDKCResult_ChannelTransactionParametersDecodeErrorZ* orig_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)untag_ptr(orig);
16359         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
16360         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_clone(orig_conv);
16361         return tag_ptr(ret_conv, true);
16362 }
16363
16364 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1SignatureZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
16365         LDKCVec_SignatureZ _res_constr;
16366         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
16367         if (_res_constr.datalen > 0)
16368                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
16369         else
16370                 _res_constr.data = NULL;
16371         for (size_t i = 0; i < _res_constr.datalen; i++) {
16372                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
16373                 LDKSignature _res_conv_8_ref;
16374                 CHECK((*env)->GetArrayLength(env, _res_conv_8) == 64);
16375                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, 64, _res_conv_8_ref.compact_form);
16376                 _res_constr.data[i] = _res_conv_8_ref;
16377         }
16378         CVec_SignatureZ_free(_res_constr);
16379 }
16380
16381 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16382         LDKHolderCommitmentTransaction o_conv;
16383         o_conv.inner = untag_ptr(o);
16384         o_conv.is_owned = ptr_is_owned(o);
16385         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16386         o_conv = HolderCommitmentTransaction_clone(&o_conv);
16387         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
16388         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_ok(o_conv);
16389         return tag_ptr(ret_conv, true);
16390 }
16391
16392 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16393         void* e_ptr = untag_ptr(e);
16394         CHECK_ACCESS(e_ptr);
16395         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
16396         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
16397         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
16398         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_err(e_conv);
16399         return tag_ptr(ret_conv, true);
16400 }
16401
16402 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16403         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* o_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)untag_ptr(o);
16404         jboolean ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_is_ok(o_conv);
16405         return ret_conv;
16406 }
16407
16408 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16409         if (!ptr_is_owned(_res)) return;
16410         void* _res_ptr = untag_ptr(_res);
16411         CHECK_ACCESS(_res_ptr);
16412         LDKCResult_HolderCommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(_res_ptr);
16413         FREE(untag_ptr(_res));
16414         CResult_HolderCommitmentTransactionDecodeErrorZ_free(_res_conv);
16415 }
16416
16417 static inline uint64_t CResult_HolderCommitmentTransactionDecodeErrorZ_clone_ptr(LDKCResult_HolderCommitmentTransactionDecodeErrorZ *NONNULL_PTR arg) {
16418         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
16419         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_clone(arg);
16420         return tag_ptr(ret_conv, true);
16421 }
16422 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16423         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* arg_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)untag_ptr(arg);
16424         int64_t ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_clone_ptr(arg_conv);
16425         return ret_conv;
16426 }
16427
16428 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16429         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)untag_ptr(orig);
16430         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
16431         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_clone(orig_conv);
16432         return tag_ptr(ret_conv, true);
16433 }
16434
16435 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16436         LDKBuiltCommitmentTransaction o_conv;
16437         o_conv.inner = untag_ptr(o);
16438         o_conv.is_owned = ptr_is_owned(o);
16439         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16440         o_conv = BuiltCommitmentTransaction_clone(&o_conv);
16441         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
16442         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_ok(o_conv);
16443         return tag_ptr(ret_conv, true);
16444 }
16445
16446 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16447         void* e_ptr = untag_ptr(e);
16448         CHECK_ACCESS(e_ptr);
16449         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
16450         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
16451         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
16452         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_err(e_conv);
16453         return tag_ptr(ret_conv, true);
16454 }
16455
16456 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16457         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* o_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)untag_ptr(o);
16458         jboolean ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_is_ok(o_conv);
16459         return ret_conv;
16460 }
16461
16462 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16463         if (!ptr_is_owned(_res)) return;
16464         void* _res_ptr = untag_ptr(_res);
16465         CHECK_ACCESS(_res_ptr);
16466         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(_res_ptr);
16467         FREE(untag_ptr(_res));
16468         CResult_BuiltCommitmentTransactionDecodeErrorZ_free(_res_conv);
16469 }
16470
16471 static inline uint64_t CResult_BuiltCommitmentTransactionDecodeErrorZ_clone_ptr(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ *NONNULL_PTR arg) {
16472         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
16473         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_clone(arg);
16474         return tag_ptr(ret_conv, true);
16475 }
16476 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16477         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* arg_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)untag_ptr(arg);
16478         int64_t ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_clone_ptr(arg_conv);
16479         return ret_conv;
16480 }
16481
16482 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16483         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)untag_ptr(orig);
16484         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
16485         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_clone(orig_conv);
16486         return tag_ptr(ret_conv, true);
16487 }
16488
16489 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedClosingTransactionNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16490         LDKTrustedClosingTransaction o_conv;
16491         o_conv.inner = untag_ptr(o);
16492         o_conv.is_owned = ptr_is_owned(o);
16493         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16494         // WARNING: we need a move here but no clone is available for LDKTrustedClosingTransaction
16495         
16496         LDKCResult_TrustedClosingTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedClosingTransactionNoneZ), "LDKCResult_TrustedClosingTransactionNoneZ");
16497         *ret_conv = CResult_TrustedClosingTransactionNoneZ_ok(o_conv);
16498         return tag_ptr(ret_conv, true);
16499 }
16500
16501 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedClosingTransactionNoneZ_1err(JNIEnv *env, jclass clz) {
16502         LDKCResult_TrustedClosingTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedClosingTransactionNoneZ), "LDKCResult_TrustedClosingTransactionNoneZ");
16503         *ret_conv = CResult_TrustedClosingTransactionNoneZ_err();
16504         return tag_ptr(ret_conv, true);
16505 }
16506
16507 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedClosingTransactionNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16508         LDKCResult_TrustedClosingTransactionNoneZ* o_conv = (LDKCResult_TrustedClosingTransactionNoneZ*)untag_ptr(o);
16509         jboolean ret_conv = CResult_TrustedClosingTransactionNoneZ_is_ok(o_conv);
16510         return ret_conv;
16511 }
16512
16513 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedClosingTransactionNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16514         if (!ptr_is_owned(_res)) return;
16515         void* _res_ptr = untag_ptr(_res);
16516         CHECK_ACCESS(_res_ptr);
16517         LDKCResult_TrustedClosingTransactionNoneZ _res_conv = *(LDKCResult_TrustedClosingTransactionNoneZ*)(_res_ptr);
16518         FREE(untag_ptr(_res));
16519         CResult_TrustedClosingTransactionNoneZ_free(_res_conv);
16520 }
16521
16522 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16523         LDKCommitmentTransaction o_conv;
16524         o_conv.inner = untag_ptr(o);
16525         o_conv.is_owned = ptr_is_owned(o);
16526         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16527         o_conv = CommitmentTransaction_clone(&o_conv);
16528         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
16529         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_ok(o_conv);
16530         return tag_ptr(ret_conv, true);
16531 }
16532
16533 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16534         void* e_ptr = untag_ptr(e);
16535         CHECK_ACCESS(e_ptr);
16536         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
16537         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
16538         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
16539         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_err(e_conv);
16540         return tag_ptr(ret_conv, true);
16541 }
16542
16543 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16544         LDKCResult_CommitmentTransactionDecodeErrorZ* o_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)untag_ptr(o);
16545         jboolean ret_conv = CResult_CommitmentTransactionDecodeErrorZ_is_ok(o_conv);
16546         return ret_conv;
16547 }
16548
16549 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16550         if (!ptr_is_owned(_res)) return;
16551         void* _res_ptr = untag_ptr(_res);
16552         CHECK_ACCESS(_res_ptr);
16553         LDKCResult_CommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_CommitmentTransactionDecodeErrorZ*)(_res_ptr);
16554         FREE(untag_ptr(_res));
16555         CResult_CommitmentTransactionDecodeErrorZ_free(_res_conv);
16556 }
16557
16558 static inline uint64_t CResult_CommitmentTransactionDecodeErrorZ_clone_ptr(LDKCResult_CommitmentTransactionDecodeErrorZ *NONNULL_PTR arg) {
16559         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
16560         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_clone(arg);
16561         return tag_ptr(ret_conv, true);
16562 }
16563 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16564         LDKCResult_CommitmentTransactionDecodeErrorZ* arg_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)untag_ptr(arg);
16565         int64_t ret_conv = CResult_CommitmentTransactionDecodeErrorZ_clone_ptr(arg_conv);
16566         return ret_conv;
16567 }
16568
16569 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16570         LDKCResult_CommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)untag_ptr(orig);
16571         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
16572         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_clone(orig_conv);
16573         return tag_ptr(ret_conv, true);
16574 }
16575
16576 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedCommitmentTransactionNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16577         LDKTrustedCommitmentTransaction o_conv;
16578         o_conv.inner = untag_ptr(o);
16579         o_conv.is_owned = ptr_is_owned(o);
16580         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16581         // WARNING: we need a move here but no clone is available for LDKTrustedCommitmentTransaction
16582         
16583         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
16584         *ret_conv = CResult_TrustedCommitmentTransactionNoneZ_ok(o_conv);
16585         return tag_ptr(ret_conv, true);
16586 }
16587
16588 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedCommitmentTransactionNoneZ_1err(JNIEnv *env, jclass clz) {
16589         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
16590         *ret_conv = CResult_TrustedCommitmentTransactionNoneZ_err();
16591         return tag_ptr(ret_conv, true);
16592 }
16593
16594 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedCommitmentTransactionNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16595         LDKCResult_TrustedCommitmentTransactionNoneZ* o_conv = (LDKCResult_TrustedCommitmentTransactionNoneZ*)untag_ptr(o);
16596         jboolean ret_conv = CResult_TrustedCommitmentTransactionNoneZ_is_ok(o_conv);
16597         return ret_conv;
16598 }
16599
16600 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedCommitmentTransactionNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16601         if (!ptr_is_owned(_res)) return;
16602         void* _res_ptr = untag_ptr(_res);
16603         CHECK_ACCESS(_res_ptr);
16604         LDKCResult_TrustedCommitmentTransactionNoneZ _res_conv = *(LDKCResult_TrustedCommitmentTransactionNoneZ*)(_res_ptr);
16605         FREE(untag_ptr(_res));
16606         CResult_TrustedCommitmentTransactionNoneZ_free(_res_conv);
16607 }
16608
16609 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1ok(JNIEnv *env, jclass clz, jobjectArray o) {
16610         LDKCVec_SignatureZ o_constr;
16611         o_constr.datalen = (*env)->GetArrayLength(env, o);
16612         if (o_constr.datalen > 0)
16613                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
16614         else
16615                 o_constr.data = NULL;
16616         for (size_t i = 0; i < o_constr.datalen; i++) {
16617                 int8_tArray o_conv_8 = (*env)->GetObjectArrayElement(env, o, i);
16618                 LDKSignature o_conv_8_ref;
16619                 CHECK((*env)->GetArrayLength(env, o_conv_8) == 64);
16620                 (*env)->GetByteArrayRegion(env, o_conv_8, 0, 64, o_conv_8_ref.compact_form);
16621                 o_constr.data[i] = o_conv_8_ref;
16622         }
16623         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
16624         *ret_conv = CResult_CVec_SignatureZNoneZ_ok(o_constr);
16625         return tag_ptr(ret_conv, true);
16626 }
16627
16628 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1err(JNIEnv *env, jclass clz) {
16629         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
16630         *ret_conv = CResult_CVec_SignatureZNoneZ_err();
16631         return tag_ptr(ret_conv, true);
16632 }
16633
16634 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16635         LDKCResult_CVec_SignatureZNoneZ* o_conv = (LDKCResult_CVec_SignatureZNoneZ*)untag_ptr(o);
16636         jboolean ret_conv = CResult_CVec_SignatureZNoneZ_is_ok(o_conv);
16637         return ret_conv;
16638 }
16639
16640 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16641         if (!ptr_is_owned(_res)) return;
16642         void* _res_ptr = untag_ptr(_res);
16643         CHECK_ACCESS(_res_ptr);
16644         LDKCResult_CVec_SignatureZNoneZ _res_conv = *(LDKCResult_CVec_SignatureZNoneZ*)(_res_ptr);
16645         FREE(untag_ptr(_res));
16646         CResult_CVec_SignatureZNoneZ_free(_res_conv);
16647 }
16648
16649 static inline uint64_t CResult_CVec_SignatureZNoneZ_clone_ptr(LDKCResult_CVec_SignatureZNoneZ *NONNULL_PTR arg) {
16650         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
16651         *ret_conv = CResult_CVec_SignatureZNoneZ_clone(arg);
16652         return tag_ptr(ret_conv, true);
16653 }
16654 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16655         LDKCResult_CVec_SignatureZNoneZ* arg_conv = (LDKCResult_CVec_SignatureZNoneZ*)untag_ptr(arg);
16656         int64_t ret_conv = CResult_CVec_SignatureZNoneZ_clone_ptr(arg_conv);
16657         return ret_conv;
16658 }
16659
16660 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16661         LDKCResult_CVec_SignatureZNoneZ* orig_conv = (LDKCResult_CVec_SignatureZNoneZ*)untag_ptr(orig);
16662         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
16663         *ret_conv = CResult_CVec_SignatureZNoneZ_clone(orig_conv);
16664         return tag_ptr(ret_conv, true);
16665 }
16666
16667 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16668         LDKShutdownScript o_conv;
16669         o_conv.inner = untag_ptr(o);
16670         o_conv.is_owned = ptr_is_owned(o);
16671         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16672         o_conv = ShutdownScript_clone(&o_conv);
16673         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
16674         *ret_conv = CResult_ShutdownScriptDecodeErrorZ_ok(o_conv);
16675         return tag_ptr(ret_conv, true);
16676 }
16677
16678 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16679         void* e_ptr = untag_ptr(e);
16680         CHECK_ACCESS(e_ptr);
16681         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
16682         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
16683         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
16684         *ret_conv = CResult_ShutdownScriptDecodeErrorZ_err(e_conv);
16685         return tag_ptr(ret_conv, true);
16686 }
16687
16688 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16689         LDKCResult_ShutdownScriptDecodeErrorZ* o_conv = (LDKCResult_ShutdownScriptDecodeErrorZ*)untag_ptr(o);
16690         jboolean ret_conv = CResult_ShutdownScriptDecodeErrorZ_is_ok(o_conv);
16691         return ret_conv;
16692 }
16693
16694 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16695         if (!ptr_is_owned(_res)) return;
16696         void* _res_ptr = untag_ptr(_res);
16697         CHECK_ACCESS(_res_ptr);
16698         LDKCResult_ShutdownScriptDecodeErrorZ _res_conv = *(LDKCResult_ShutdownScriptDecodeErrorZ*)(_res_ptr);
16699         FREE(untag_ptr(_res));
16700         CResult_ShutdownScriptDecodeErrorZ_free(_res_conv);
16701 }
16702
16703 static inline uint64_t CResult_ShutdownScriptDecodeErrorZ_clone_ptr(LDKCResult_ShutdownScriptDecodeErrorZ *NONNULL_PTR arg) {
16704         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
16705         *ret_conv = CResult_ShutdownScriptDecodeErrorZ_clone(arg);
16706         return tag_ptr(ret_conv, true);
16707 }
16708 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16709         LDKCResult_ShutdownScriptDecodeErrorZ* arg_conv = (LDKCResult_ShutdownScriptDecodeErrorZ*)untag_ptr(arg);
16710         int64_t ret_conv = CResult_ShutdownScriptDecodeErrorZ_clone_ptr(arg_conv);
16711         return ret_conv;
16712 }
16713
16714 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16715         LDKCResult_ShutdownScriptDecodeErrorZ* orig_conv = (LDKCResult_ShutdownScriptDecodeErrorZ*)untag_ptr(orig);
16716         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
16717         *ret_conv = CResult_ShutdownScriptDecodeErrorZ_clone(orig_conv);
16718         return tag_ptr(ret_conv, true);
16719 }
16720
16721 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptInvalidShutdownScriptZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16722         LDKShutdownScript o_conv;
16723         o_conv.inner = untag_ptr(o);
16724         o_conv.is_owned = ptr_is_owned(o);
16725         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16726         o_conv = ShutdownScript_clone(&o_conv);
16727         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
16728         *ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_ok(o_conv);
16729         return tag_ptr(ret_conv, true);
16730 }
16731
16732 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptInvalidShutdownScriptZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16733         LDKInvalidShutdownScript e_conv;
16734         e_conv.inner = untag_ptr(e);
16735         e_conv.is_owned = ptr_is_owned(e);
16736         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16737         e_conv = InvalidShutdownScript_clone(&e_conv);
16738         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
16739         *ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_err(e_conv);
16740         return tag_ptr(ret_conv, true);
16741 }
16742
16743 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptInvalidShutdownScriptZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16744         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* o_conv = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)untag_ptr(o);
16745         jboolean ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_is_ok(o_conv);
16746         return ret_conv;
16747 }
16748
16749 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptInvalidShutdownScriptZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16750         if (!ptr_is_owned(_res)) return;
16751         void* _res_ptr = untag_ptr(_res);
16752         CHECK_ACCESS(_res_ptr);
16753         LDKCResult_ShutdownScriptInvalidShutdownScriptZ _res_conv = *(LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(_res_ptr);
16754         FREE(untag_ptr(_res));
16755         CResult_ShutdownScriptInvalidShutdownScriptZ_free(_res_conv);
16756 }
16757
16758 static inline uint64_t CResult_ShutdownScriptInvalidShutdownScriptZ_clone_ptr(LDKCResult_ShutdownScriptInvalidShutdownScriptZ *NONNULL_PTR arg) {
16759         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
16760         *ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_clone(arg);
16761         return tag_ptr(ret_conv, true);
16762 }
16763 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptInvalidShutdownScriptZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16764         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* arg_conv = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)untag_ptr(arg);
16765         int64_t ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_clone_ptr(arg_conv);
16766         return ret_conv;
16767 }
16768
16769 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptInvalidShutdownScriptZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16770         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* orig_conv = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)untag_ptr(orig);
16771         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
16772         *ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_clone(orig_conv);
16773         return tag_ptr(ret_conv, true);
16774 }
16775
16776 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1PublicKeyZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
16777         LDKCVec_PublicKeyZ _res_constr;
16778         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
16779         if (_res_constr.datalen > 0)
16780                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKPublicKey), "LDKCVec_PublicKeyZ Elements");
16781         else
16782                 _res_constr.data = NULL;
16783         for (size_t i = 0; i < _res_constr.datalen; i++) {
16784                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
16785                 LDKPublicKey _res_conv_8_ref;
16786                 CHECK((*env)->GetArrayLength(env, _res_conv_8) == 33);
16787                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, 33, _res_conv_8_ref.compressed_form);
16788                 _res_constr.data[i] = _res_conv_8_ref;
16789         }
16790         CVec_PublicKeyZ_free(_res_constr);
16791 }
16792
16793 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedPathNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16794         LDKBlindedPath o_conv;
16795         o_conv.inner = untag_ptr(o);
16796         o_conv.is_owned = ptr_is_owned(o);
16797         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16798         o_conv = BlindedPath_clone(&o_conv);
16799         LDKCResult_BlindedPathNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedPathNoneZ), "LDKCResult_BlindedPathNoneZ");
16800         *ret_conv = CResult_BlindedPathNoneZ_ok(o_conv);
16801         return tag_ptr(ret_conv, true);
16802 }
16803
16804 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedPathNoneZ_1err(JNIEnv *env, jclass clz) {
16805         LDKCResult_BlindedPathNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedPathNoneZ), "LDKCResult_BlindedPathNoneZ");
16806         *ret_conv = CResult_BlindedPathNoneZ_err();
16807         return tag_ptr(ret_conv, true);
16808 }
16809
16810 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedPathNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16811         LDKCResult_BlindedPathNoneZ* o_conv = (LDKCResult_BlindedPathNoneZ*)untag_ptr(o);
16812         jboolean ret_conv = CResult_BlindedPathNoneZ_is_ok(o_conv);
16813         return ret_conv;
16814 }
16815
16816 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedPathNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16817         if (!ptr_is_owned(_res)) return;
16818         void* _res_ptr = untag_ptr(_res);
16819         CHECK_ACCESS(_res_ptr);
16820         LDKCResult_BlindedPathNoneZ _res_conv = *(LDKCResult_BlindedPathNoneZ*)(_res_ptr);
16821         FREE(untag_ptr(_res));
16822         CResult_BlindedPathNoneZ_free(_res_conv);
16823 }
16824
16825 static inline uint64_t CResult_BlindedPathNoneZ_clone_ptr(LDKCResult_BlindedPathNoneZ *NONNULL_PTR arg) {
16826         LDKCResult_BlindedPathNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedPathNoneZ), "LDKCResult_BlindedPathNoneZ");
16827         *ret_conv = CResult_BlindedPathNoneZ_clone(arg);
16828         return tag_ptr(ret_conv, true);
16829 }
16830 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedPathNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16831         LDKCResult_BlindedPathNoneZ* arg_conv = (LDKCResult_BlindedPathNoneZ*)untag_ptr(arg);
16832         int64_t ret_conv = CResult_BlindedPathNoneZ_clone_ptr(arg_conv);
16833         return ret_conv;
16834 }
16835
16836 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedPathNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16837         LDKCResult_BlindedPathNoneZ* orig_conv = (LDKCResult_BlindedPathNoneZ*)untag_ptr(orig);
16838         LDKCResult_BlindedPathNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedPathNoneZ), "LDKCResult_BlindedPathNoneZ");
16839         *ret_conv = CResult_BlindedPathNoneZ_clone(orig_conv);
16840         return tag_ptr(ret_conv, true);
16841 }
16842
16843 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedPathDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16844         LDKBlindedPath o_conv;
16845         o_conv.inner = untag_ptr(o);
16846         o_conv.is_owned = ptr_is_owned(o);
16847         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16848         o_conv = BlindedPath_clone(&o_conv);
16849         LDKCResult_BlindedPathDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedPathDecodeErrorZ), "LDKCResult_BlindedPathDecodeErrorZ");
16850         *ret_conv = CResult_BlindedPathDecodeErrorZ_ok(o_conv);
16851         return tag_ptr(ret_conv, true);
16852 }
16853
16854 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedPathDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16855         void* e_ptr = untag_ptr(e);
16856         CHECK_ACCESS(e_ptr);
16857         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
16858         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
16859         LDKCResult_BlindedPathDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedPathDecodeErrorZ), "LDKCResult_BlindedPathDecodeErrorZ");
16860         *ret_conv = CResult_BlindedPathDecodeErrorZ_err(e_conv);
16861         return tag_ptr(ret_conv, true);
16862 }
16863
16864 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedPathDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16865         LDKCResult_BlindedPathDecodeErrorZ* o_conv = (LDKCResult_BlindedPathDecodeErrorZ*)untag_ptr(o);
16866         jboolean ret_conv = CResult_BlindedPathDecodeErrorZ_is_ok(o_conv);
16867         return ret_conv;
16868 }
16869
16870 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedPathDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16871         if (!ptr_is_owned(_res)) return;
16872         void* _res_ptr = untag_ptr(_res);
16873         CHECK_ACCESS(_res_ptr);
16874         LDKCResult_BlindedPathDecodeErrorZ _res_conv = *(LDKCResult_BlindedPathDecodeErrorZ*)(_res_ptr);
16875         FREE(untag_ptr(_res));
16876         CResult_BlindedPathDecodeErrorZ_free(_res_conv);
16877 }
16878
16879 static inline uint64_t CResult_BlindedPathDecodeErrorZ_clone_ptr(LDKCResult_BlindedPathDecodeErrorZ *NONNULL_PTR arg) {
16880         LDKCResult_BlindedPathDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedPathDecodeErrorZ), "LDKCResult_BlindedPathDecodeErrorZ");
16881         *ret_conv = CResult_BlindedPathDecodeErrorZ_clone(arg);
16882         return tag_ptr(ret_conv, true);
16883 }
16884 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedPathDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16885         LDKCResult_BlindedPathDecodeErrorZ* arg_conv = (LDKCResult_BlindedPathDecodeErrorZ*)untag_ptr(arg);
16886         int64_t ret_conv = CResult_BlindedPathDecodeErrorZ_clone_ptr(arg_conv);
16887         return ret_conv;
16888 }
16889
16890 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedPathDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16891         LDKCResult_BlindedPathDecodeErrorZ* orig_conv = (LDKCResult_BlindedPathDecodeErrorZ*)untag_ptr(orig);
16892         LDKCResult_BlindedPathDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedPathDecodeErrorZ), "LDKCResult_BlindedPathDecodeErrorZ");
16893         *ret_conv = CResult_BlindedPathDecodeErrorZ_clone(orig_conv);
16894         return tag_ptr(ret_conv, true);
16895 }
16896
16897 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedHopDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16898         LDKBlindedHop o_conv;
16899         o_conv.inner = untag_ptr(o);
16900         o_conv.is_owned = ptr_is_owned(o);
16901         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16902         o_conv = BlindedHop_clone(&o_conv);
16903         LDKCResult_BlindedHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedHopDecodeErrorZ), "LDKCResult_BlindedHopDecodeErrorZ");
16904         *ret_conv = CResult_BlindedHopDecodeErrorZ_ok(o_conv);
16905         return tag_ptr(ret_conv, true);
16906 }
16907
16908 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedHopDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16909         void* e_ptr = untag_ptr(e);
16910         CHECK_ACCESS(e_ptr);
16911         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
16912         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
16913         LDKCResult_BlindedHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedHopDecodeErrorZ), "LDKCResult_BlindedHopDecodeErrorZ");
16914         *ret_conv = CResult_BlindedHopDecodeErrorZ_err(e_conv);
16915         return tag_ptr(ret_conv, true);
16916 }
16917
16918 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedHopDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16919         LDKCResult_BlindedHopDecodeErrorZ* o_conv = (LDKCResult_BlindedHopDecodeErrorZ*)untag_ptr(o);
16920         jboolean ret_conv = CResult_BlindedHopDecodeErrorZ_is_ok(o_conv);
16921         return ret_conv;
16922 }
16923
16924 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedHopDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16925         if (!ptr_is_owned(_res)) return;
16926         void* _res_ptr = untag_ptr(_res);
16927         CHECK_ACCESS(_res_ptr);
16928         LDKCResult_BlindedHopDecodeErrorZ _res_conv = *(LDKCResult_BlindedHopDecodeErrorZ*)(_res_ptr);
16929         FREE(untag_ptr(_res));
16930         CResult_BlindedHopDecodeErrorZ_free(_res_conv);
16931 }
16932
16933 static inline uint64_t CResult_BlindedHopDecodeErrorZ_clone_ptr(LDKCResult_BlindedHopDecodeErrorZ *NONNULL_PTR arg) {
16934         LDKCResult_BlindedHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedHopDecodeErrorZ), "LDKCResult_BlindedHopDecodeErrorZ");
16935         *ret_conv = CResult_BlindedHopDecodeErrorZ_clone(arg);
16936         return tag_ptr(ret_conv, true);
16937 }
16938 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedHopDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16939         LDKCResult_BlindedHopDecodeErrorZ* arg_conv = (LDKCResult_BlindedHopDecodeErrorZ*)untag_ptr(arg);
16940         int64_t ret_conv = CResult_BlindedHopDecodeErrorZ_clone_ptr(arg_conv);
16941         return ret_conv;
16942 }
16943
16944 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BlindedHopDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16945         LDKCResult_BlindedHopDecodeErrorZ* orig_conv = (LDKCResult_BlindedHopDecodeErrorZ*)untag_ptr(orig);
16946         LDKCResult_BlindedHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedHopDecodeErrorZ), "LDKCResult_BlindedHopDecodeErrorZ");
16947         *ret_conv = CResult_BlindedHopDecodeErrorZ_clone(orig_conv);
16948         return tag_ptr(ret_conv, true);
16949 }
16950
16951 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1WriteableScoreZ_1some(JNIEnv *env, jclass clz, int64_t o) {
16952         void* o_ptr = untag_ptr(o);
16953         CHECK_ACCESS(o_ptr);
16954         LDKWriteableScore o_conv = *(LDKWriteableScore*)(o_ptr);
16955         if (o_conv.free == LDKWriteableScore_JCalls_free) {
16956                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
16957                 LDKWriteableScore_JCalls_cloned(&o_conv);
16958         }
16959         LDKCOption_WriteableScoreZ *ret_copy = MALLOC(sizeof(LDKCOption_WriteableScoreZ), "LDKCOption_WriteableScoreZ");
16960         *ret_copy = COption_WriteableScoreZ_some(o_conv);
16961         int64_t ret_ref = tag_ptr(ret_copy, true);
16962         return ret_ref;
16963 }
16964
16965 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1WriteableScoreZ_1none(JNIEnv *env, jclass clz) {
16966         LDKCOption_WriteableScoreZ *ret_copy = MALLOC(sizeof(LDKCOption_WriteableScoreZ), "LDKCOption_WriteableScoreZ");
16967         *ret_copy = COption_WriteableScoreZ_none();
16968         int64_t ret_ref = tag_ptr(ret_copy, true);
16969         return ret_ref;
16970 }
16971
16972 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1WriteableScoreZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16973         if (!ptr_is_owned(_res)) return;
16974         void* _res_ptr = untag_ptr(_res);
16975         CHECK_ACCESS(_res_ptr);
16976         LDKCOption_WriteableScoreZ _res_conv = *(LDKCOption_WriteableScoreZ*)(_res_ptr);
16977         FREE(untag_ptr(_res));
16978         COption_WriteableScoreZ_free(_res_conv);
16979 }
16980
16981 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1ok(JNIEnv *env, jclass clz) {
16982         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
16983         *ret_conv = CResult_NoneErrorZ_ok();
16984         return tag_ptr(ret_conv, true);
16985 }
16986
16987 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
16988         LDKIOError e_conv = LDKIOError_from_java(env, e);
16989         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
16990         *ret_conv = CResult_NoneErrorZ_err(e_conv);
16991         return tag_ptr(ret_conv, true);
16992 }
16993
16994 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16995         LDKCResult_NoneErrorZ* o_conv = (LDKCResult_NoneErrorZ*)untag_ptr(o);
16996         jboolean ret_conv = CResult_NoneErrorZ_is_ok(o_conv);
16997         return ret_conv;
16998 }
16999
17000 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17001         if (!ptr_is_owned(_res)) return;
17002         void* _res_ptr = untag_ptr(_res);
17003         CHECK_ACCESS(_res_ptr);
17004         LDKCResult_NoneErrorZ _res_conv = *(LDKCResult_NoneErrorZ*)(_res_ptr);
17005         FREE(untag_ptr(_res));
17006         CResult_NoneErrorZ_free(_res_conv);
17007 }
17008
17009 static inline uint64_t CResult_NoneErrorZ_clone_ptr(LDKCResult_NoneErrorZ *NONNULL_PTR arg) {
17010         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
17011         *ret_conv = CResult_NoneErrorZ_clone(arg);
17012         return tag_ptr(ret_conv, true);
17013 }
17014 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17015         LDKCResult_NoneErrorZ* arg_conv = (LDKCResult_NoneErrorZ*)untag_ptr(arg);
17016         int64_t ret_conv = CResult_NoneErrorZ_clone_ptr(arg_conv);
17017         return ret_conv;
17018 }
17019
17020 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17021         LDKCResult_NoneErrorZ* orig_conv = (LDKCResult_NoneErrorZ*)untag_ptr(orig);
17022         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
17023         *ret_conv = CResult_NoneErrorZ_clone(orig_conv);
17024         return tag_ptr(ret_conv, true);
17025 }
17026
17027 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1ChannelDetailsZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
17028         LDKCVec_ChannelDetailsZ _res_constr;
17029         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
17030         if (_res_constr.datalen > 0)
17031                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
17032         else
17033                 _res_constr.data = NULL;
17034         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
17035         for (size_t q = 0; q < _res_constr.datalen; q++) {
17036                 int64_t _res_conv_16 = _res_vals[q];
17037                 LDKChannelDetails _res_conv_16_conv;
17038                 _res_conv_16_conv.inner = untag_ptr(_res_conv_16);
17039                 _res_conv_16_conv.is_owned = ptr_is_owned(_res_conv_16);
17040                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_16_conv);
17041                 _res_constr.data[q] = _res_conv_16_conv;
17042         }
17043         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
17044         CVec_ChannelDetailsZ_free(_res_constr);
17045 }
17046
17047 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17048         LDKRoute 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 = Route_clone(&o_conv);
17053         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
17054         *ret_conv = CResult_RouteLightningErrorZ_ok(o_conv);
17055         return tag_ptr(ret_conv, true);
17056 }
17057
17058 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17059         LDKLightningError e_conv;
17060         e_conv.inner = untag_ptr(e);
17061         e_conv.is_owned = ptr_is_owned(e);
17062         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17063         e_conv = LightningError_clone(&e_conv);
17064         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
17065         *ret_conv = CResult_RouteLightningErrorZ_err(e_conv);
17066         return tag_ptr(ret_conv, true);
17067 }
17068
17069 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17070         LDKCResult_RouteLightningErrorZ* o_conv = (LDKCResult_RouteLightningErrorZ*)untag_ptr(o);
17071         jboolean ret_conv = CResult_RouteLightningErrorZ_is_ok(o_conv);
17072         return ret_conv;
17073 }
17074
17075 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17076         if (!ptr_is_owned(_res)) return;
17077         void* _res_ptr = untag_ptr(_res);
17078         CHECK_ACCESS(_res_ptr);
17079         LDKCResult_RouteLightningErrorZ _res_conv = *(LDKCResult_RouteLightningErrorZ*)(_res_ptr);
17080         FREE(untag_ptr(_res));
17081         CResult_RouteLightningErrorZ_free(_res_conv);
17082 }
17083
17084 static inline uint64_t CResult_RouteLightningErrorZ_clone_ptr(LDKCResult_RouteLightningErrorZ *NONNULL_PTR arg) {
17085         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
17086         *ret_conv = CResult_RouteLightningErrorZ_clone(arg);
17087         return tag_ptr(ret_conv, true);
17088 }
17089 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17090         LDKCResult_RouteLightningErrorZ* arg_conv = (LDKCResult_RouteLightningErrorZ*)untag_ptr(arg);
17091         int64_t ret_conv = CResult_RouteLightningErrorZ_clone_ptr(arg_conv);
17092         return ret_conv;
17093 }
17094
17095 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17096         LDKCResult_RouteLightningErrorZ* orig_conv = (LDKCResult_RouteLightningErrorZ*)untag_ptr(orig);
17097         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
17098         *ret_conv = CResult_RouteLightningErrorZ_clone(orig_conv);
17099         return tag_ptr(ret_conv, true);
17100 }
17101
17102 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1RouteHopZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
17103         LDKCVec_RouteHopZ _res_constr;
17104         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
17105         if (_res_constr.datalen > 0)
17106                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
17107         else
17108                 _res_constr.data = NULL;
17109         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
17110         for (size_t k = 0; k < _res_constr.datalen; k++) {
17111                 int64_t _res_conv_10 = _res_vals[k];
17112                 LDKRouteHop _res_conv_10_conv;
17113                 _res_conv_10_conv.inner = untag_ptr(_res_conv_10);
17114                 _res_conv_10_conv.is_owned = ptr_is_owned(_res_conv_10);
17115                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_10_conv);
17116                 _res_constr.data[k] = _res_conv_10_conv;
17117         }
17118         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
17119         CVec_RouteHopZ_free(_res_constr);
17120 }
17121
17122 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u64Z_1some(JNIEnv *env, jclass clz, int64_t o) {
17123         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
17124         *ret_copy = COption_u64Z_some(o);
17125         int64_t ret_ref = tag_ptr(ret_copy, true);
17126         return ret_ref;
17127 }
17128
17129 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u64Z_1none(JNIEnv *env, jclass clz) {
17130         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
17131         *ret_copy = COption_u64Z_none();
17132         int64_t ret_ref = tag_ptr(ret_copy, true);
17133         return ret_ref;
17134 }
17135
17136 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1u64Z_1free(JNIEnv *env, jclass clz, int64_t _res) {
17137         if (!ptr_is_owned(_res)) return;
17138         void* _res_ptr = untag_ptr(_res);
17139         CHECK_ACCESS(_res_ptr);
17140         LDKCOption_u64Z _res_conv = *(LDKCOption_u64Z*)(_res_ptr);
17141         FREE(untag_ptr(_res));
17142         COption_u64Z_free(_res_conv);
17143 }
17144
17145 static inline uint64_t COption_u64Z_clone_ptr(LDKCOption_u64Z *NONNULL_PTR arg) {
17146         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
17147         *ret_copy = COption_u64Z_clone(arg);
17148         int64_t ret_ref = tag_ptr(ret_copy, true);
17149         return ret_ref;
17150 }
17151 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u64Z_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17152         LDKCOption_u64Z* arg_conv = (LDKCOption_u64Z*)untag_ptr(arg);
17153         int64_t ret_conv = COption_u64Z_clone_ptr(arg_conv);
17154         return ret_conv;
17155 }
17156
17157 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u64Z_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17158         LDKCOption_u64Z* orig_conv = (LDKCOption_u64Z*)untag_ptr(orig);
17159         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
17160         *ret_copy = COption_u64Z_clone(orig_conv);
17161         int64_t ret_ref = tag_ptr(ret_copy, true);
17162         return ret_ref;
17163 }
17164
17165 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InFlightHtlcsDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17166         LDKInFlightHtlcs o_conv;
17167         o_conv.inner = untag_ptr(o);
17168         o_conv.is_owned = ptr_is_owned(o);
17169         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17170         o_conv = InFlightHtlcs_clone(&o_conv);
17171         LDKCResult_InFlightHtlcsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InFlightHtlcsDecodeErrorZ), "LDKCResult_InFlightHtlcsDecodeErrorZ");
17172         *ret_conv = CResult_InFlightHtlcsDecodeErrorZ_ok(o_conv);
17173         return tag_ptr(ret_conv, true);
17174 }
17175
17176 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InFlightHtlcsDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17177         void* e_ptr = untag_ptr(e);
17178         CHECK_ACCESS(e_ptr);
17179         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
17180         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
17181         LDKCResult_InFlightHtlcsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InFlightHtlcsDecodeErrorZ), "LDKCResult_InFlightHtlcsDecodeErrorZ");
17182         *ret_conv = CResult_InFlightHtlcsDecodeErrorZ_err(e_conv);
17183         return tag_ptr(ret_conv, true);
17184 }
17185
17186 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1InFlightHtlcsDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17187         LDKCResult_InFlightHtlcsDecodeErrorZ* o_conv = (LDKCResult_InFlightHtlcsDecodeErrorZ*)untag_ptr(o);
17188         jboolean ret_conv = CResult_InFlightHtlcsDecodeErrorZ_is_ok(o_conv);
17189         return ret_conv;
17190 }
17191
17192 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InFlightHtlcsDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17193         if (!ptr_is_owned(_res)) return;
17194         void* _res_ptr = untag_ptr(_res);
17195         CHECK_ACCESS(_res_ptr);
17196         LDKCResult_InFlightHtlcsDecodeErrorZ _res_conv = *(LDKCResult_InFlightHtlcsDecodeErrorZ*)(_res_ptr);
17197         FREE(untag_ptr(_res));
17198         CResult_InFlightHtlcsDecodeErrorZ_free(_res_conv);
17199 }
17200
17201 static inline uint64_t CResult_InFlightHtlcsDecodeErrorZ_clone_ptr(LDKCResult_InFlightHtlcsDecodeErrorZ *NONNULL_PTR arg) {
17202         LDKCResult_InFlightHtlcsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InFlightHtlcsDecodeErrorZ), "LDKCResult_InFlightHtlcsDecodeErrorZ");
17203         *ret_conv = CResult_InFlightHtlcsDecodeErrorZ_clone(arg);
17204         return tag_ptr(ret_conv, true);
17205 }
17206 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InFlightHtlcsDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17207         LDKCResult_InFlightHtlcsDecodeErrorZ* arg_conv = (LDKCResult_InFlightHtlcsDecodeErrorZ*)untag_ptr(arg);
17208         int64_t ret_conv = CResult_InFlightHtlcsDecodeErrorZ_clone_ptr(arg_conv);
17209         return ret_conv;
17210 }
17211
17212 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InFlightHtlcsDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17213         LDKCResult_InFlightHtlcsDecodeErrorZ* orig_conv = (LDKCResult_InFlightHtlcsDecodeErrorZ*)untag_ptr(orig);
17214         LDKCResult_InFlightHtlcsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InFlightHtlcsDecodeErrorZ), "LDKCResult_InFlightHtlcsDecodeErrorZ");
17215         *ret_conv = CResult_InFlightHtlcsDecodeErrorZ_clone(orig_conv);
17216         return tag_ptr(ret_conv, true);
17217 }
17218
17219 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17220         LDKRouteHop o_conv;
17221         o_conv.inner = untag_ptr(o);
17222         o_conv.is_owned = ptr_is_owned(o);
17223         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17224         o_conv = RouteHop_clone(&o_conv);
17225         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
17226         *ret_conv = CResult_RouteHopDecodeErrorZ_ok(o_conv);
17227         return tag_ptr(ret_conv, true);
17228 }
17229
17230 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17231         void* e_ptr = untag_ptr(e);
17232         CHECK_ACCESS(e_ptr);
17233         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
17234         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
17235         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
17236         *ret_conv = CResult_RouteHopDecodeErrorZ_err(e_conv);
17237         return tag_ptr(ret_conv, true);
17238 }
17239
17240 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17241         LDKCResult_RouteHopDecodeErrorZ* o_conv = (LDKCResult_RouteHopDecodeErrorZ*)untag_ptr(o);
17242         jboolean ret_conv = CResult_RouteHopDecodeErrorZ_is_ok(o_conv);
17243         return ret_conv;
17244 }
17245
17246 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17247         if (!ptr_is_owned(_res)) return;
17248         void* _res_ptr = untag_ptr(_res);
17249         CHECK_ACCESS(_res_ptr);
17250         LDKCResult_RouteHopDecodeErrorZ _res_conv = *(LDKCResult_RouteHopDecodeErrorZ*)(_res_ptr);
17251         FREE(untag_ptr(_res));
17252         CResult_RouteHopDecodeErrorZ_free(_res_conv);
17253 }
17254
17255 static inline uint64_t CResult_RouteHopDecodeErrorZ_clone_ptr(LDKCResult_RouteHopDecodeErrorZ *NONNULL_PTR arg) {
17256         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
17257         *ret_conv = CResult_RouteHopDecodeErrorZ_clone(arg);
17258         return tag_ptr(ret_conv, true);
17259 }
17260 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17261         LDKCResult_RouteHopDecodeErrorZ* arg_conv = (LDKCResult_RouteHopDecodeErrorZ*)untag_ptr(arg);
17262         int64_t ret_conv = CResult_RouteHopDecodeErrorZ_clone_ptr(arg_conv);
17263         return ret_conv;
17264 }
17265
17266 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17267         LDKCResult_RouteHopDecodeErrorZ* orig_conv = (LDKCResult_RouteHopDecodeErrorZ*)untag_ptr(orig);
17268         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
17269         *ret_conv = CResult_RouteHopDecodeErrorZ_clone(orig_conv);
17270         return tag_ptr(ret_conv, true);
17271 }
17272
17273 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1CVec_1RouteHopZZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
17274         LDKCVec_CVec_RouteHopZZ _res_constr;
17275         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
17276         if (_res_constr.datalen > 0)
17277                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
17278         else
17279                 _res_constr.data = NULL;
17280         for (size_t m = 0; m < _res_constr.datalen; m++) {
17281                 int64_tArray _res_conv_12 = (*env)->GetObjectArrayElement(env, _res, m);
17282                 LDKCVec_RouteHopZ _res_conv_12_constr;
17283                 _res_conv_12_constr.datalen = (*env)->GetArrayLength(env, _res_conv_12);
17284                 if (_res_conv_12_constr.datalen > 0)
17285                         _res_conv_12_constr.data = MALLOC(_res_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
17286                 else
17287                         _res_conv_12_constr.data = NULL;
17288                 int64_t* _res_conv_12_vals = (*env)->GetLongArrayElements (env, _res_conv_12, NULL);
17289                 for (size_t k = 0; k < _res_conv_12_constr.datalen; k++) {
17290                         int64_t _res_conv_12_conv_10 = _res_conv_12_vals[k];
17291                         LDKRouteHop _res_conv_12_conv_10_conv;
17292                         _res_conv_12_conv_10_conv.inner = untag_ptr(_res_conv_12_conv_10);
17293                         _res_conv_12_conv_10_conv.is_owned = ptr_is_owned(_res_conv_12_conv_10);
17294                         CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_12_conv_10_conv);
17295                         _res_conv_12_constr.data[k] = _res_conv_12_conv_10_conv;
17296                 }
17297                 (*env)->ReleaseLongArrayElements(env, _res_conv_12, _res_conv_12_vals, 0);
17298                 _res_constr.data[m] = _res_conv_12_constr;
17299         }
17300         CVec_CVec_RouteHopZZ_free(_res_constr);
17301 }
17302
17303 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17304         LDKRoute o_conv;
17305         o_conv.inner = untag_ptr(o);
17306         o_conv.is_owned = ptr_is_owned(o);
17307         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17308         o_conv = Route_clone(&o_conv);
17309         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
17310         *ret_conv = CResult_RouteDecodeErrorZ_ok(o_conv);
17311         return tag_ptr(ret_conv, true);
17312 }
17313
17314 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17315         void* e_ptr = untag_ptr(e);
17316         CHECK_ACCESS(e_ptr);
17317         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
17318         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
17319         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
17320         *ret_conv = CResult_RouteDecodeErrorZ_err(e_conv);
17321         return tag_ptr(ret_conv, true);
17322 }
17323
17324 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17325         LDKCResult_RouteDecodeErrorZ* o_conv = (LDKCResult_RouteDecodeErrorZ*)untag_ptr(o);
17326         jboolean ret_conv = CResult_RouteDecodeErrorZ_is_ok(o_conv);
17327         return ret_conv;
17328 }
17329
17330 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17331         if (!ptr_is_owned(_res)) return;
17332         void* _res_ptr = untag_ptr(_res);
17333         CHECK_ACCESS(_res_ptr);
17334         LDKCResult_RouteDecodeErrorZ _res_conv = *(LDKCResult_RouteDecodeErrorZ*)(_res_ptr);
17335         FREE(untag_ptr(_res));
17336         CResult_RouteDecodeErrorZ_free(_res_conv);
17337 }
17338
17339 static inline uint64_t CResult_RouteDecodeErrorZ_clone_ptr(LDKCResult_RouteDecodeErrorZ *NONNULL_PTR arg) {
17340         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
17341         *ret_conv = CResult_RouteDecodeErrorZ_clone(arg);
17342         return tag_ptr(ret_conv, true);
17343 }
17344 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17345         LDKCResult_RouteDecodeErrorZ* arg_conv = (LDKCResult_RouteDecodeErrorZ*)untag_ptr(arg);
17346         int64_t ret_conv = CResult_RouteDecodeErrorZ_clone_ptr(arg_conv);
17347         return ret_conv;
17348 }
17349
17350 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17351         LDKCResult_RouteDecodeErrorZ* orig_conv = (LDKCResult_RouteDecodeErrorZ*)untag_ptr(orig);
17352         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
17353         *ret_conv = CResult_RouteDecodeErrorZ_clone(orig_conv);
17354         return tag_ptr(ret_conv, true);
17355 }
17356
17357 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteParametersDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17358         LDKRouteParameters o_conv;
17359         o_conv.inner = untag_ptr(o);
17360         o_conv.is_owned = ptr_is_owned(o);
17361         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17362         o_conv = RouteParameters_clone(&o_conv);
17363         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
17364         *ret_conv = CResult_RouteParametersDecodeErrorZ_ok(o_conv);
17365         return tag_ptr(ret_conv, true);
17366 }
17367
17368 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteParametersDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17369         void* e_ptr = untag_ptr(e);
17370         CHECK_ACCESS(e_ptr);
17371         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
17372         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
17373         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
17374         *ret_conv = CResult_RouteParametersDecodeErrorZ_err(e_conv);
17375         return tag_ptr(ret_conv, true);
17376 }
17377
17378 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1RouteParametersDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17379         LDKCResult_RouteParametersDecodeErrorZ* o_conv = (LDKCResult_RouteParametersDecodeErrorZ*)untag_ptr(o);
17380         jboolean ret_conv = CResult_RouteParametersDecodeErrorZ_is_ok(o_conv);
17381         return ret_conv;
17382 }
17383
17384 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteParametersDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17385         if (!ptr_is_owned(_res)) return;
17386         void* _res_ptr = untag_ptr(_res);
17387         CHECK_ACCESS(_res_ptr);
17388         LDKCResult_RouteParametersDecodeErrorZ _res_conv = *(LDKCResult_RouteParametersDecodeErrorZ*)(_res_ptr);
17389         FREE(untag_ptr(_res));
17390         CResult_RouteParametersDecodeErrorZ_free(_res_conv);
17391 }
17392
17393 static inline uint64_t CResult_RouteParametersDecodeErrorZ_clone_ptr(LDKCResult_RouteParametersDecodeErrorZ *NONNULL_PTR arg) {
17394         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
17395         *ret_conv = CResult_RouteParametersDecodeErrorZ_clone(arg);
17396         return tag_ptr(ret_conv, true);
17397 }
17398 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteParametersDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17399         LDKCResult_RouteParametersDecodeErrorZ* arg_conv = (LDKCResult_RouteParametersDecodeErrorZ*)untag_ptr(arg);
17400         int64_t ret_conv = CResult_RouteParametersDecodeErrorZ_clone_ptr(arg_conv);
17401         return ret_conv;
17402 }
17403
17404 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteParametersDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17405         LDKCResult_RouteParametersDecodeErrorZ* orig_conv = (LDKCResult_RouteParametersDecodeErrorZ*)untag_ptr(orig);
17406         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
17407         *ret_conv = CResult_RouteParametersDecodeErrorZ_clone(orig_conv);
17408         return tag_ptr(ret_conv, true);
17409 }
17410
17411 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1RouteHintZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
17412         LDKCVec_RouteHintZ _res_constr;
17413         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
17414         if (_res_constr.datalen > 0)
17415                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
17416         else
17417                 _res_constr.data = NULL;
17418         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
17419         for (size_t l = 0; l < _res_constr.datalen; l++) {
17420                 int64_t _res_conv_11 = _res_vals[l];
17421                 LDKRouteHint _res_conv_11_conv;
17422                 _res_conv_11_conv.inner = untag_ptr(_res_conv_11);
17423                 _res_conv_11_conv.is_owned = ptr_is_owned(_res_conv_11);
17424                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_11_conv);
17425                 _res_constr.data[l] = _res_conv_11_conv;
17426         }
17427         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
17428         CVec_RouteHintZ_free(_res_constr);
17429 }
17430
17431 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1u64Z_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
17432         LDKCVec_u64Z _res_constr;
17433         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
17434         if (_res_constr.datalen > 0)
17435                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
17436         else
17437                 _res_constr.data = NULL;
17438         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
17439         for (size_t g = 0; g < _res_constr.datalen; g++) {
17440                 int64_t _res_conv_6 = _res_vals[g];
17441                 _res_constr.data[g] = _res_conv_6;
17442         }
17443         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
17444         CVec_u64Z_free(_res_constr);
17445 }
17446
17447 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentParametersDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17448         LDKPaymentParameters o_conv;
17449         o_conv.inner = untag_ptr(o);
17450         o_conv.is_owned = ptr_is_owned(o);
17451         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17452         o_conv = PaymentParameters_clone(&o_conv);
17453         LDKCResult_PaymentParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentParametersDecodeErrorZ), "LDKCResult_PaymentParametersDecodeErrorZ");
17454         *ret_conv = CResult_PaymentParametersDecodeErrorZ_ok(o_conv);
17455         return tag_ptr(ret_conv, true);
17456 }
17457
17458 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentParametersDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17459         void* e_ptr = untag_ptr(e);
17460         CHECK_ACCESS(e_ptr);
17461         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
17462         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
17463         LDKCResult_PaymentParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentParametersDecodeErrorZ), "LDKCResult_PaymentParametersDecodeErrorZ");
17464         *ret_conv = CResult_PaymentParametersDecodeErrorZ_err(e_conv);
17465         return tag_ptr(ret_conv, true);
17466 }
17467
17468 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentParametersDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17469         LDKCResult_PaymentParametersDecodeErrorZ* o_conv = (LDKCResult_PaymentParametersDecodeErrorZ*)untag_ptr(o);
17470         jboolean ret_conv = CResult_PaymentParametersDecodeErrorZ_is_ok(o_conv);
17471         return ret_conv;
17472 }
17473
17474 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentParametersDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17475         if (!ptr_is_owned(_res)) return;
17476         void* _res_ptr = untag_ptr(_res);
17477         CHECK_ACCESS(_res_ptr);
17478         LDKCResult_PaymentParametersDecodeErrorZ _res_conv = *(LDKCResult_PaymentParametersDecodeErrorZ*)(_res_ptr);
17479         FREE(untag_ptr(_res));
17480         CResult_PaymentParametersDecodeErrorZ_free(_res_conv);
17481 }
17482
17483 static inline uint64_t CResult_PaymentParametersDecodeErrorZ_clone_ptr(LDKCResult_PaymentParametersDecodeErrorZ *NONNULL_PTR arg) {
17484         LDKCResult_PaymentParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentParametersDecodeErrorZ), "LDKCResult_PaymentParametersDecodeErrorZ");
17485         *ret_conv = CResult_PaymentParametersDecodeErrorZ_clone(arg);
17486         return tag_ptr(ret_conv, true);
17487 }
17488 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentParametersDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17489         LDKCResult_PaymentParametersDecodeErrorZ* arg_conv = (LDKCResult_PaymentParametersDecodeErrorZ*)untag_ptr(arg);
17490         int64_t ret_conv = CResult_PaymentParametersDecodeErrorZ_clone_ptr(arg_conv);
17491         return ret_conv;
17492 }
17493
17494 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentParametersDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17495         LDKCResult_PaymentParametersDecodeErrorZ* orig_conv = (LDKCResult_PaymentParametersDecodeErrorZ*)untag_ptr(orig);
17496         LDKCResult_PaymentParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentParametersDecodeErrorZ), "LDKCResult_PaymentParametersDecodeErrorZ");
17497         *ret_conv = CResult_PaymentParametersDecodeErrorZ_clone(orig_conv);
17498         return tag_ptr(ret_conv, true);
17499 }
17500
17501 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1RouteHintHopZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
17502         LDKCVec_RouteHintHopZ _res_constr;
17503         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
17504         if (_res_constr.datalen > 0)
17505                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRouteHintHop), "LDKCVec_RouteHintHopZ Elements");
17506         else
17507                 _res_constr.data = NULL;
17508         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
17509         for (size_t o = 0; o < _res_constr.datalen; o++) {
17510                 int64_t _res_conv_14 = _res_vals[o];
17511                 LDKRouteHintHop _res_conv_14_conv;
17512                 _res_conv_14_conv.inner = untag_ptr(_res_conv_14);
17513                 _res_conv_14_conv.is_owned = ptr_is_owned(_res_conv_14);
17514                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_14_conv);
17515                 _res_constr.data[o] = _res_conv_14_conv;
17516         }
17517         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
17518         CVec_RouteHintHopZ_free(_res_constr);
17519 }
17520
17521 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17522         LDKRouteHint o_conv;
17523         o_conv.inner = untag_ptr(o);
17524         o_conv.is_owned = ptr_is_owned(o);
17525         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17526         o_conv = RouteHint_clone(&o_conv);
17527         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
17528         *ret_conv = CResult_RouteHintDecodeErrorZ_ok(o_conv);
17529         return tag_ptr(ret_conv, true);
17530 }
17531
17532 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17533         void* e_ptr = untag_ptr(e);
17534         CHECK_ACCESS(e_ptr);
17535         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
17536         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
17537         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
17538         *ret_conv = CResult_RouteHintDecodeErrorZ_err(e_conv);
17539         return tag_ptr(ret_conv, true);
17540 }
17541
17542 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17543         LDKCResult_RouteHintDecodeErrorZ* o_conv = (LDKCResult_RouteHintDecodeErrorZ*)untag_ptr(o);
17544         jboolean ret_conv = CResult_RouteHintDecodeErrorZ_is_ok(o_conv);
17545         return ret_conv;
17546 }
17547
17548 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17549         if (!ptr_is_owned(_res)) return;
17550         void* _res_ptr = untag_ptr(_res);
17551         CHECK_ACCESS(_res_ptr);
17552         LDKCResult_RouteHintDecodeErrorZ _res_conv = *(LDKCResult_RouteHintDecodeErrorZ*)(_res_ptr);
17553         FREE(untag_ptr(_res));
17554         CResult_RouteHintDecodeErrorZ_free(_res_conv);
17555 }
17556
17557 static inline uint64_t CResult_RouteHintDecodeErrorZ_clone_ptr(LDKCResult_RouteHintDecodeErrorZ *NONNULL_PTR arg) {
17558         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
17559         *ret_conv = CResult_RouteHintDecodeErrorZ_clone(arg);
17560         return tag_ptr(ret_conv, true);
17561 }
17562 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17563         LDKCResult_RouteHintDecodeErrorZ* arg_conv = (LDKCResult_RouteHintDecodeErrorZ*)untag_ptr(arg);
17564         int64_t ret_conv = CResult_RouteHintDecodeErrorZ_clone_ptr(arg_conv);
17565         return ret_conv;
17566 }
17567
17568 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17569         LDKCResult_RouteHintDecodeErrorZ* orig_conv = (LDKCResult_RouteHintDecodeErrorZ*)untag_ptr(orig);
17570         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
17571         *ret_conv = CResult_RouteHintDecodeErrorZ_clone(orig_conv);
17572         return tag_ptr(ret_conv, true);
17573 }
17574
17575 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintHopDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17576         LDKRouteHintHop o_conv;
17577         o_conv.inner = untag_ptr(o);
17578         o_conv.is_owned = ptr_is_owned(o);
17579         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17580         o_conv = RouteHintHop_clone(&o_conv);
17581         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
17582         *ret_conv = CResult_RouteHintHopDecodeErrorZ_ok(o_conv);
17583         return tag_ptr(ret_conv, true);
17584 }
17585
17586 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintHopDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17587         void* e_ptr = untag_ptr(e);
17588         CHECK_ACCESS(e_ptr);
17589         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
17590         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
17591         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
17592         *ret_conv = CResult_RouteHintHopDecodeErrorZ_err(e_conv);
17593         return tag_ptr(ret_conv, true);
17594 }
17595
17596 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintHopDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17597         LDKCResult_RouteHintHopDecodeErrorZ* o_conv = (LDKCResult_RouteHintHopDecodeErrorZ*)untag_ptr(o);
17598         jboolean ret_conv = CResult_RouteHintHopDecodeErrorZ_is_ok(o_conv);
17599         return ret_conv;
17600 }
17601
17602 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintHopDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17603         if (!ptr_is_owned(_res)) return;
17604         void* _res_ptr = untag_ptr(_res);
17605         CHECK_ACCESS(_res_ptr);
17606         LDKCResult_RouteHintHopDecodeErrorZ _res_conv = *(LDKCResult_RouteHintHopDecodeErrorZ*)(_res_ptr);
17607         FREE(untag_ptr(_res));
17608         CResult_RouteHintHopDecodeErrorZ_free(_res_conv);
17609 }
17610
17611 static inline uint64_t CResult_RouteHintHopDecodeErrorZ_clone_ptr(LDKCResult_RouteHintHopDecodeErrorZ *NONNULL_PTR arg) {
17612         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
17613         *ret_conv = CResult_RouteHintHopDecodeErrorZ_clone(arg);
17614         return tag_ptr(ret_conv, true);
17615 }
17616 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintHopDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17617         LDKCResult_RouteHintHopDecodeErrorZ* arg_conv = (LDKCResult_RouteHintHopDecodeErrorZ*)untag_ptr(arg);
17618         int64_t ret_conv = CResult_RouteHintHopDecodeErrorZ_clone_ptr(arg_conv);
17619         return ret_conv;
17620 }
17621
17622 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintHopDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17623         LDKCResult_RouteHintHopDecodeErrorZ* orig_conv = (LDKCResult_RouteHintHopDecodeErrorZ*)untag_ptr(orig);
17624         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
17625         *ret_conv = CResult_RouteHintHopDecodeErrorZ_clone(orig_conv);
17626         return tag_ptr(ret_conv, true);
17627 }
17628
17629 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPurposeDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17630         void* o_ptr = untag_ptr(o);
17631         CHECK_ACCESS(o_ptr);
17632         LDKPaymentPurpose o_conv = *(LDKPaymentPurpose*)(o_ptr);
17633         o_conv = PaymentPurpose_clone((LDKPaymentPurpose*)untag_ptr(o));
17634         LDKCResult_PaymentPurposeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPurposeDecodeErrorZ), "LDKCResult_PaymentPurposeDecodeErrorZ");
17635         *ret_conv = CResult_PaymentPurposeDecodeErrorZ_ok(o_conv);
17636         return tag_ptr(ret_conv, true);
17637 }
17638
17639 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPurposeDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17640         void* e_ptr = untag_ptr(e);
17641         CHECK_ACCESS(e_ptr);
17642         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
17643         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
17644         LDKCResult_PaymentPurposeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPurposeDecodeErrorZ), "LDKCResult_PaymentPurposeDecodeErrorZ");
17645         *ret_conv = CResult_PaymentPurposeDecodeErrorZ_err(e_conv);
17646         return tag_ptr(ret_conv, true);
17647 }
17648
17649 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPurposeDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17650         LDKCResult_PaymentPurposeDecodeErrorZ* o_conv = (LDKCResult_PaymentPurposeDecodeErrorZ*)untag_ptr(o);
17651         jboolean ret_conv = CResult_PaymentPurposeDecodeErrorZ_is_ok(o_conv);
17652         return ret_conv;
17653 }
17654
17655 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPurposeDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17656         if (!ptr_is_owned(_res)) return;
17657         void* _res_ptr = untag_ptr(_res);
17658         CHECK_ACCESS(_res_ptr);
17659         LDKCResult_PaymentPurposeDecodeErrorZ _res_conv = *(LDKCResult_PaymentPurposeDecodeErrorZ*)(_res_ptr);
17660         FREE(untag_ptr(_res));
17661         CResult_PaymentPurposeDecodeErrorZ_free(_res_conv);
17662 }
17663
17664 static inline uint64_t CResult_PaymentPurposeDecodeErrorZ_clone_ptr(LDKCResult_PaymentPurposeDecodeErrorZ *NONNULL_PTR arg) {
17665         LDKCResult_PaymentPurposeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPurposeDecodeErrorZ), "LDKCResult_PaymentPurposeDecodeErrorZ");
17666         *ret_conv = CResult_PaymentPurposeDecodeErrorZ_clone(arg);
17667         return tag_ptr(ret_conv, true);
17668 }
17669 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPurposeDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17670         LDKCResult_PaymentPurposeDecodeErrorZ* arg_conv = (LDKCResult_PaymentPurposeDecodeErrorZ*)untag_ptr(arg);
17671         int64_t ret_conv = CResult_PaymentPurposeDecodeErrorZ_clone_ptr(arg_conv);
17672         return ret_conv;
17673 }
17674
17675 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPurposeDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17676         LDKCResult_PaymentPurposeDecodeErrorZ* orig_conv = (LDKCResult_PaymentPurposeDecodeErrorZ*)untag_ptr(orig);
17677         LDKCResult_PaymentPurposeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPurposeDecodeErrorZ), "LDKCResult_PaymentPurposeDecodeErrorZ");
17678         *ret_conv = CResult_PaymentPurposeDecodeErrorZ_clone(orig_conv);
17679         return tag_ptr(ret_conv, true);
17680 }
17681
17682 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1ClosureReasonZ_1some(JNIEnv *env, jclass clz, int64_t o) {
17683         void* o_ptr = untag_ptr(o);
17684         CHECK_ACCESS(o_ptr);
17685         LDKClosureReason o_conv = *(LDKClosureReason*)(o_ptr);
17686         o_conv = ClosureReason_clone((LDKClosureReason*)untag_ptr(o));
17687         LDKCOption_ClosureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_ClosureReasonZ), "LDKCOption_ClosureReasonZ");
17688         *ret_copy = COption_ClosureReasonZ_some(o_conv);
17689         int64_t ret_ref = tag_ptr(ret_copy, true);
17690         return ret_ref;
17691 }
17692
17693 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1ClosureReasonZ_1none(JNIEnv *env, jclass clz) {
17694         LDKCOption_ClosureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_ClosureReasonZ), "LDKCOption_ClosureReasonZ");
17695         *ret_copy = COption_ClosureReasonZ_none();
17696         int64_t ret_ref = tag_ptr(ret_copy, true);
17697         return ret_ref;
17698 }
17699
17700 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1ClosureReasonZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17701         if (!ptr_is_owned(_res)) return;
17702         void* _res_ptr = untag_ptr(_res);
17703         CHECK_ACCESS(_res_ptr);
17704         LDKCOption_ClosureReasonZ _res_conv = *(LDKCOption_ClosureReasonZ*)(_res_ptr);
17705         FREE(untag_ptr(_res));
17706         COption_ClosureReasonZ_free(_res_conv);
17707 }
17708
17709 static inline uint64_t COption_ClosureReasonZ_clone_ptr(LDKCOption_ClosureReasonZ *NONNULL_PTR arg) {
17710         LDKCOption_ClosureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_ClosureReasonZ), "LDKCOption_ClosureReasonZ");
17711         *ret_copy = COption_ClosureReasonZ_clone(arg);
17712         int64_t ret_ref = tag_ptr(ret_copy, true);
17713         return ret_ref;
17714 }
17715 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1ClosureReasonZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17716         LDKCOption_ClosureReasonZ* arg_conv = (LDKCOption_ClosureReasonZ*)untag_ptr(arg);
17717         int64_t ret_conv = COption_ClosureReasonZ_clone_ptr(arg_conv);
17718         return ret_conv;
17719 }
17720
17721 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1ClosureReasonZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17722         LDKCOption_ClosureReasonZ* orig_conv = (LDKCOption_ClosureReasonZ*)untag_ptr(orig);
17723         LDKCOption_ClosureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_ClosureReasonZ), "LDKCOption_ClosureReasonZ");
17724         *ret_copy = COption_ClosureReasonZ_clone(orig_conv);
17725         int64_t ret_ref = tag_ptr(ret_copy, true);
17726         return ret_ref;
17727 }
17728
17729 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1ClosureReasonZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17730         void* o_ptr = untag_ptr(o);
17731         CHECK_ACCESS(o_ptr);
17732         LDKCOption_ClosureReasonZ o_conv = *(LDKCOption_ClosureReasonZ*)(o_ptr);
17733         o_conv = COption_ClosureReasonZ_clone((LDKCOption_ClosureReasonZ*)untag_ptr(o));
17734         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
17735         *ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_ok(o_conv);
17736         return tag_ptr(ret_conv, true);
17737 }
17738
17739 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1ClosureReasonZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17740         void* e_ptr = untag_ptr(e);
17741         CHECK_ACCESS(e_ptr);
17742         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
17743         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
17744         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
17745         *ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_err(e_conv);
17746         return tag_ptr(ret_conv, true);
17747 }
17748
17749 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1ClosureReasonZDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17750         LDKCResult_COption_ClosureReasonZDecodeErrorZ* o_conv = (LDKCResult_COption_ClosureReasonZDecodeErrorZ*)untag_ptr(o);
17751         jboolean ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_is_ok(o_conv);
17752         return ret_conv;
17753 }
17754
17755 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1ClosureReasonZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17756         if (!ptr_is_owned(_res)) return;
17757         void* _res_ptr = untag_ptr(_res);
17758         CHECK_ACCESS(_res_ptr);
17759         LDKCResult_COption_ClosureReasonZDecodeErrorZ _res_conv = *(LDKCResult_COption_ClosureReasonZDecodeErrorZ*)(_res_ptr);
17760         FREE(untag_ptr(_res));
17761         CResult_COption_ClosureReasonZDecodeErrorZ_free(_res_conv);
17762 }
17763
17764 static inline uint64_t CResult_COption_ClosureReasonZDecodeErrorZ_clone_ptr(LDKCResult_COption_ClosureReasonZDecodeErrorZ *NONNULL_PTR arg) {
17765         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
17766         *ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_clone(arg);
17767         return tag_ptr(ret_conv, true);
17768 }
17769 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1ClosureReasonZDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17770         LDKCResult_COption_ClosureReasonZDecodeErrorZ* arg_conv = (LDKCResult_COption_ClosureReasonZDecodeErrorZ*)untag_ptr(arg);
17771         int64_t ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_clone_ptr(arg_conv);
17772         return ret_conv;
17773 }
17774
17775 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1ClosureReasonZDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17776         LDKCResult_COption_ClosureReasonZDecodeErrorZ* orig_conv = (LDKCResult_COption_ClosureReasonZDecodeErrorZ*)untag_ptr(orig);
17777         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
17778         *ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_clone(orig_conv);
17779         return tag_ptr(ret_conv, true);
17780 }
17781
17782 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1HTLCDestinationZ_1some(JNIEnv *env, jclass clz, int64_t o) {
17783         void* o_ptr = untag_ptr(o);
17784         CHECK_ACCESS(o_ptr);
17785         LDKHTLCDestination o_conv = *(LDKHTLCDestination*)(o_ptr);
17786         o_conv = HTLCDestination_clone((LDKHTLCDestination*)untag_ptr(o));
17787         LDKCOption_HTLCDestinationZ *ret_copy = MALLOC(sizeof(LDKCOption_HTLCDestinationZ), "LDKCOption_HTLCDestinationZ");
17788         *ret_copy = COption_HTLCDestinationZ_some(o_conv);
17789         int64_t ret_ref = tag_ptr(ret_copy, true);
17790         return ret_ref;
17791 }
17792
17793 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1HTLCDestinationZ_1none(JNIEnv *env, jclass clz) {
17794         LDKCOption_HTLCDestinationZ *ret_copy = MALLOC(sizeof(LDKCOption_HTLCDestinationZ), "LDKCOption_HTLCDestinationZ");
17795         *ret_copy = COption_HTLCDestinationZ_none();
17796         int64_t ret_ref = tag_ptr(ret_copy, true);
17797         return ret_ref;
17798 }
17799
17800 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1HTLCDestinationZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17801         if (!ptr_is_owned(_res)) return;
17802         void* _res_ptr = untag_ptr(_res);
17803         CHECK_ACCESS(_res_ptr);
17804         LDKCOption_HTLCDestinationZ _res_conv = *(LDKCOption_HTLCDestinationZ*)(_res_ptr);
17805         FREE(untag_ptr(_res));
17806         COption_HTLCDestinationZ_free(_res_conv);
17807 }
17808
17809 static inline uint64_t COption_HTLCDestinationZ_clone_ptr(LDKCOption_HTLCDestinationZ *NONNULL_PTR arg) {
17810         LDKCOption_HTLCDestinationZ *ret_copy = MALLOC(sizeof(LDKCOption_HTLCDestinationZ), "LDKCOption_HTLCDestinationZ");
17811         *ret_copy = COption_HTLCDestinationZ_clone(arg);
17812         int64_t ret_ref = tag_ptr(ret_copy, true);
17813         return ret_ref;
17814 }
17815 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1HTLCDestinationZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17816         LDKCOption_HTLCDestinationZ* arg_conv = (LDKCOption_HTLCDestinationZ*)untag_ptr(arg);
17817         int64_t ret_conv = COption_HTLCDestinationZ_clone_ptr(arg_conv);
17818         return ret_conv;
17819 }
17820
17821 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1HTLCDestinationZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17822         LDKCOption_HTLCDestinationZ* orig_conv = (LDKCOption_HTLCDestinationZ*)untag_ptr(orig);
17823         LDKCOption_HTLCDestinationZ *ret_copy = MALLOC(sizeof(LDKCOption_HTLCDestinationZ), "LDKCOption_HTLCDestinationZ");
17824         *ret_copy = COption_HTLCDestinationZ_clone(orig_conv);
17825         int64_t ret_ref = tag_ptr(ret_copy, true);
17826         return ret_ref;
17827 }
17828
17829 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1HTLCDestinationZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17830         void* o_ptr = untag_ptr(o);
17831         CHECK_ACCESS(o_ptr);
17832         LDKCOption_HTLCDestinationZ o_conv = *(LDKCOption_HTLCDestinationZ*)(o_ptr);
17833         o_conv = COption_HTLCDestinationZ_clone((LDKCOption_HTLCDestinationZ*)untag_ptr(o));
17834         LDKCResult_COption_HTLCDestinationZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_HTLCDestinationZDecodeErrorZ), "LDKCResult_COption_HTLCDestinationZDecodeErrorZ");
17835         *ret_conv = CResult_COption_HTLCDestinationZDecodeErrorZ_ok(o_conv);
17836         return tag_ptr(ret_conv, true);
17837 }
17838
17839 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1HTLCDestinationZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17840         void* e_ptr = untag_ptr(e);
17841         CHECK_ACCESS(e_ptr);
17842         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
17843         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
17844         LDKCResult_COption_HTLCDestinationZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_HTLCDestinationZDecodeErrorZ), "LDKCResult_COption_HTLCDestinationZDecodeErrorZ");
17845         *ret_conv = CResult_COption_HTLCDestinationZDecodeErrorZ_err(e_conv);
17846         return tag_ptr(ret_conv, true);
17847 }
17848
17849 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1HTLCDestinationZDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17850         LDKCResult_COption_HTLCDestinationZDecodeErrorZ* o_conv = (LDKCResult_COption_HTLCDestinationZDecodeErrorZ*)untag_ptr(o);
17851         jboolean ret_conv = CResult_COption_HTLCDestinationZDecodeErrorZ_is_ok(o_conv);
17852         return ret_conv;
17853 }
17854
17855 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1HTLCDestinationZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17856         if (!ptr_is_owned(_res)) return;
17857         void* _res_ptr = untag_ptr(_res);
17858         CHECK_ACCESS(_res_ptr);
17859         LDKCResult_COption_HTLCDestinationZDecodeErrorZ _res_conv = *(LDKCResult_COption_HTLCDestinationZDecodeErrorZ*)(_res_ptr);
17860         FREE(untag_ptr(_res));
17861         CResult_COption_HTLCDestinationZDecodeErrorZ_free(_res_conv);
17862 }
17863
17864 static inline uint64_t CResult_COption_HTLCDestinationZDecodeErrorZ_clone_ptr(LDKCResult_COption_HTLCDestinationZDecodeErrorZ *NONNULL_PTR arg) {
17865         LDKCResult_COption_HTLCDestinationZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_HTLCDestinationZDecodeErrorZ), "LDKCResult_COption_HTLCDestinationZDecodeErrorZ");
17866         *ret_conv = CResult_COption_HTLCDestinationZDecodeErrorZ_clone(arg);
17867         return tag_ptr(ret_conv, true);
17868 }
17869 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1HTLCDestinationZDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17870         LDKCResult_COption_HTLCDestinationZDecodeErrorZ* arg_conv = (LDKCResult_COption_HTLCDestinationZDecodeErrorZ*)untag_ptr(arg);
17871         int64_t ret_conv = CResult_COption_HTLCDestinationZDecodeErrorZ_clone_ptr(arg_conv);
17872         return ret_conv;
17873 }
17874
17875 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1HTLCDestinationZDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17876         LDKCResult_COption_HTLCDestinationZDecodeErrorZ* orig_conv = (LDKCResult_COption_HTLCDestinationZDecodeErrorZ*)untag_ptr(orig);
17877         LDKCResult_COption_HTLCDestinationZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_HTLCDestinationZDecodeErrorZ), "LDKCResult_COption_HTLCDestinationZDecodeErrorZ");
17878         *ret_conv = CResult_COption_HTLCDestinationZDecodeErrorZ_clone(orig_conv);
17879         return tag_ptr(ret_conv, true);
17880 }
17881
17882 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u128Z_1some(JNIEnv *env, jclass clz, int8_tArray o) {
17883         LDKU128 o_ref;
17884         CHECK((*env)->GetArrayLength(env, o) == 16);
17885         (*env)->GetByteArrayRegion(env, o, 0, 16, o_ref.le_bytes);
17886         LDKCOption_u128Z *ret_copy = MALLOC(sizeof(LDKCOption_u128Z), "LDKCOption_u128Z");
17887         *ret_copy = COption_u128Z_some(o_ref);
17888         int64_t ret_ref = tag_ptr(ret_copy, true);
17889         return ret_ref;
17890 }
17891
17892 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u128Z_1none(JNIEnv *env, jclass clz) {
17893         LDKCOption_u128Z *ret_copy = MALLOC(sizeof(LDKCOption_u128Z), "LDKCOption_u128Z");
17894         *ret_copy = COption_u128Z_none();
17895         int64_t ret_ref = tag_ptr(ret_copy, true);
17896         return ret_ref;
17897 }
17898
17899 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1u128Z_1free(JNIEnv *env, jclass clz, int64_t _res) {
17900         if (!ptr_is_owned(_res)) return;
17901         void* _res_ptr = untag_ptr(_res);
17902         CHECK_ACCESS(_res_ptr);
17903         LDKCOption_u128Z _res_conv = *(LDKCOption_u128Z*)(_res_ptr);
17904         FREE(untag_ptr(_res));
17905         COption_u128Z_free(_res_conv);
17906 }
17907
17908 static inline uint64_t COption_u128Z_clone_ptr(LDKCOption_u128Z *NONNULL_PTR arg) {
17909         LDKCOption_u128Z *ret_copy = MALLOC(sizeof(LDKCOption_u128Z), "LDKCOption_u128Z");
17910         *ret_copy = COption_u128Z_clone(arg);
17911         int64_t ret_ref = tag_ptr(ret_copy, true);
17912         return ret_ref;
17913 }
17914 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u128Z_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17915         LDKCOption_u128Z* arg_conv = (LDKCOption_u128Z*)untag_ptr(arg);
17916         int64_t ret_conv = COption_u128Z_clone_ptr(arg_conv);
17917         return ret_conv;
17918 }
17919
17920 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u128Z_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17921         LDKCOption_u128Z* orig_conv = (LDKCOption_u128Z*)untag_ptr(orig);
17922         LDKCOption_u128Z *ret_copy = MALLOC(sizeof(LDKCOption_u128Z), "LDKCOption_u128Z");
17923         *ret_copy = COption_u128Z_clone(orig_conv);
17924         int64_t ret_ref = tag_ptr(ret_copy, true);
17925         return ret_ref;
17926 }
17927
17928 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1NetworkUpdateZ_1some(JNIEnv *env, jclass clz, int64_t o) {
17929         void* o_ptr = untag_ptr(o);
17930         CHECK_ACCESS(o_ptr);
17931         LDKNetworkUpdate o_conv = *(LDKNetworkUpdate*)(o_ptr);
17932         o_conv = NetworkUpdate_clone((LDKNetworkUpdate*)untag_ptr(o));
17933         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
17934         *ret_copy = COption_NetworkUpdateZ_some(o_conv);
17935         int64_t ret_ref = tag_ptr(ret_copy, true);
17936         return ret_ref;
17937 }
17938
17939 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1NetworkUpdateZ_1none(JNIEnv *env, jclass clz) {
17940         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
17941         *ret_copy = COption_NetworkUpdateZ_none();
17942         int64_t ret_ref = tag_ptr(ret_copy, true);
17943         return ret_ref;
17944 }
17945
17946 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1NetworkUpdateZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17947         if (!ptr_is_owned(_res)) return;
17948         void* _res_ptr = untag_ptr(_res);
17949         CHECK_ACCESS(_res_ptr);
17950         LDKCOption_NetworkUpdateZ _res_conv = *(LDKCOption_NetworkUpdateZ*)(_res_ptr);
17951         FREE(untag_ptr(_res));
17952         COption_NetworkUpdateZ_free(_res_conv);
17953 }
17954
17955 static inline uint64_t COption_NetworkUpdateZ_clone_ptr(LDKCOption_NetworkUpdateZ *NONNULL_PTR arg) {
17956         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
17957         *ret_copy = COption_NetworkUpdateZ_clone(arg);
17958         int64_t ret_ref = tag_ptr(ret_copy, true);
17959         return ret_ref;
17960 }
17961 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1NetworkUpdateZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17962         LDKCOption_NetworkUpdateZ* arg_conv = (LDKCOption_NetworkUpdateZ*)untag_ptr(arg);
17963         int64_t ret_conv = COption_NetworkUpdateZ_clone_ptr(arg_conv);
17964         return ret_conv;
17965 }
17966
17967 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1NetworkUpdateZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17968         LDKCOption_NetworkUpdateZ* orig_conv = (LDKCOption_NetworkUpdateZ*)untag_ptr(orig);
17969         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
17970         *ret_copy = COption_NetworkUpdateZ_clone(orig_conv);
17971         int64_t ret_ref = tag_ptr(ret_copy, true);
17972         return ret_ref;
17973 }
17974
17975 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1SpendableOutputDescriptorZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
17976         LDKCVec_SpendableOutputDescriptorZ _res_constr;
17977         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
17978         if (_res_constr.datalen > 0)
17979                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
17980         else
17981                 _res_constr.data = NULL;
17982         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
17983         for (size_t b = 0; b < _res_constr.datalen; b++) {
17984                 int64_t _res_conv_27 = _res_vals[b];
17985                 void* _res_conv_27_ptr = untag_ptr(_res_conv_27);
17986                 CHECK_ACCESS(_res_conv_27_ptr);
17987                 LDKSpendableOutputDescriptor _res_conv_27_conv = *(LDKSpendableOutputDescriptor*)(_res_conv_27_ptr);
17988                 FREE(untag_ptr(_res_conv_27));
17989                 _res_constr.data[b] = _res_conv_27_conv;
17990         }
17991         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
17992         CVec_SpendableOutputDescriptorZ_free(_res_constr);
17993 }
17994
17995 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1EventZ_1some(JNIEnv *env, jclass clz, int64_t o) {
17996         void* o_ptr = untag_ptr(o);
17997         CHECK_ACCESS(o_ptr);
17998         LDKEvent o_conv = *(LDKEvent*)(o_ptr);
17999         o_conv = Event_clone((LDKEvent*)untag_ptr(o));
18000         LDKCOption_EventZ *ret_copy = MALLOC(sizeof(LDKCOption_EventZ), "LDKCOption_EventZ");
18001         *ret_copy = COption_EventZ_some(o_conv);
18002         int64_t ret_ref = tag_ptr(ret_copy, true);
18003         return ret_ref;
18004 }
18005
18006 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1EventZ_1none(JNIEnv *env, jclass clz) {
18007         LDKCOption_EventZ *ret_copy = MALLOC(sizeof(LDKCOption_EventZ), "LDKCOption_EventZ");
18008         *ret_copy = COption_EventZ_none();
18009         int64_t ret_ref = tag_ptr(ret_copy, true);
18010         return ret_ref;
18011 }
18012
18013 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1EventZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18014         if (!ptr_is_owned(_res)) return;
18015         void* _res_ptr = untag_ptr(_res);
18016         CHECK_ACCESS(_res_ptr);
18017         LDKCOption_EventZ _res_conv = *(LDKCOption_EventZ*)(_res_ptr);
18018         FREE(untag_ptr(_res));
18019         COption_EventZ_free(_res_conv);
18020 }
18021
18022 static inline uint64_t COption_EventZ_clone_ptr(LDKCOption_EventZ *NONNULL_PTR arg) {
18023         LDKCOption_EventZ *ret_copy = MALLOC(sizeof(LDKCOption_EventZ), "LDKCOption_EventZ");
18024         *ret_copy = COption_EventZ_clone(arg);
18025         int64_t ret_ref = tag_ptr(ret_copy, true);
18026         return ret_ref;
18027 }
18028 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1EventZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18029         LDKCOption_EventZ* arg_conv = (LDKCOption_EventZ*)untag_ptr(arg);
18030         int64_t ret_conv = COption_EventZ_clone_ptr(arg_conv);
18031         return ret_conv;
18032 }
18033
18034 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1EventZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18035         LDKCOption_EventZ* orig_conv = (LDKCOption_EventZ*)untag_ptr(orig);
18036         LDKCOption_EventZ *ret_copy = MALLOC(sizeof(LDKCOption_EventZ), "LDKCOption_EventZ");
18037         *ret_copy = COption_EventZ_clone(orig_conv);
18038         int64_t ret_ref = tag_ptr(ret_copy, true);
18039         return ret_ref;
18040 }
18041
18042 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1EventZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18043         void* o_ptr = untag_ptr(o);
18044         CHECK_ACCESS(o_ptr);
18045         LDKCOption_EventZ o_conv = *(LDKCOption_EventZ*)(o_ptr);
18046         o_conv = COption_EventZ_clone((LDKCOption_EventZ*)untag_ptr(o));
18047         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
18048         *ret_conv = CResult_COption_EventZDecodeErrorZ_ok(o_conv);
18049         return tag_ptr(ret_conv, true);
18050 }
18051
18052 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1EventZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18053         void* e_ptr = untag_ptr(e);
18054         CHECK_ACCESS(e_ptr);
18055         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
18056         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
18057         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
18058         *ret_conv = CResult_COption_EventZDecodeErrorZ_err(e_conv);
18059         return tag_ptr(ret_conv, true);
18060 }
18061
18062 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1EventZDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18063         LDKCResult_COption_EventZDecodeErrorZ* o_conv = (LDKCResult_COption_EventZDecodeErrorZ*)untag_ptr(o);
18064         jboolean ret_conv = CResult_COption_EventZDecodeErrorZ_is_ok(o_conv);
18065         return ret_conv;
18066 }
18067
18068 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1EventZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18069         if (!ptr_is_owned(_res)) return;
18070         void* _res_ptr = untag_ptr(_res);
18071         CHECK_ACCESS(_res_ptr);
18072         LDKCResult_COption_EventZDecodeErrorZ _res_conv = *(LDKCResult_COption_EventZDecodeErrorZ*)(_res_ptr);
18073         FREE(untag_ptr(_res));
18074         CResult_COption_EventZDecodeErrorZ_free(_res_conv);
18075 }
18076
18077 static inline uint64_t CResult_COption_EventZDecodeErrorZ_clone_ptr(LDKCResult_COption_EventZDecodeErrorZ *NONNULL_PTR arg) {
18078         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
18079         *ret_conv = CResult_COption_EventZDecodeErrorZ_clone(arg);
18080         return tag_ptr(ret_conv, true);
18081 }
18082 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1EventZDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18083         LDKCResult_COption_EventZDecodeErrorZ* arg_conv = (LDKCResult_COption_EventZDecodeErrorZ*)untag_ptr(arg);
18084         int64_t ret_conv = CResult_COption_EventZDecodeErrorZ_clone_ptr(arg_conv);
18085         return ret_conv;
18086 }
18087
18088 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1EventZDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18089         LDKCResult_COption_EventZDecodeErrorZ* orig_conv = (LDKCResult_COption_EventZDecodeErrorZ*)untag_ptr(orig);
18090         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
18091         *ret_conv = CResult_COption_EventZDecodeErrorZ_clone(orig_conv);
18092         return tag_ptr(ret_conv, true);
18093 }
18094
18095 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1MessageSendEventZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
18096         LDKCVec_MessageSendEventZ _res_constr;
18097         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
18098         if (_res_constr.datalen > 0)
18099                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKMessageSendEvent), "LDKCVec_MessageSendEventZ Elements");
18100         else
18101                 _res_constr.data = NULL;
18102         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
18103         for (size_t s = 0; s < _res_constr.datalen; s++) {
18104                 int64_t _res_conv_18 = _res_vals[s];
18105                 void* _res_conv_18_ptr = untag_ptr(_res_conv_18);
18106                 CHECK_ACCESS(_res_conv_18_ptr);
18107                 LDKMessageSendEvent _res_conv_18_conv = *(LDKMessageSendEvent*)(_res_conv_18_ptr);
18108                 FREE(untag_ptr(_res_conv_18));
18109                 _res_constr.data[s] = _res_conv_18_conv;
18110         }
18111         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
18112         CVec_MessageSendEventZ_free(_res_constr);
18113 }
18114
18115 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18116         void* o_ptr = untag_ptr(o);
18117         CHECK_ACCESS(o_ptr);
18118         LDKTxOut o_conv = *(LDKTxOut*)(o_ptr);
18119         o_conv = TxOut_clone((LDKTxOut*)untag_ptr(o));
18120         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
18121         *ret_conv = CResult_TxOutAccessErrorZ_ok(o_conv);
18122         return tag_ptr(ret_conv, true);
18123 }
18124
18125 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
18126         LDKAccessError e_conv = LDKAccessError_from_java(env, e);
18127         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
18128         *ret_conv = CResult_TxOutAccessErrorZ_err(e_conv);
18129         return tag_ptr(ret_conv, true);
18130 }
18131
18132 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18133         LDKCResult_TxOutAccessErrorZ* o_conv = (LDKCResult_TxOutAccessErrorZ*)untag_ptr(o);
18134         jboolean ret_conv = CResult_TxOutAccessErrorZ_is_ok(o_conv);
18135         return ret_conv;
18136 }
18137
18138 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18139         if (!ptr_is_owned(_res)) return;
18140         void* _res_ptr = untag_ptr(_res);
18141         CHECK_ACCESS(_res_ptr);
18142         LDKCResult_TxOutAccessErrorZ _res_conv = *(LDKCResult_TxOutAccessErrorZ*)(_res_ptr);
18143         FREE(untag_ptr(_res));
18144         CResult_TxOutAccessErrorZ_free(_res_conv);
18145 }
18146
18147 static inline uint64_t CResult_TxOutAccessErrorZ_clone_ptr(LDKCResult_TxOutAccessErrorZ *NONNULL_PTR arg) {
18148         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
18149         *ret_conv = CResult_TxOutAccessErrorZ_clone(arg);
18150         return tag_ptr(ret_conv, true);
18151 }
18152 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18153         LDKCResult_TxOutAccessErrorZ* arg_conv = (LDKCResult_TxOutAccessErrorZ*)untag_ptr(arg);
18154         int64_t ret_conv = CResult_TxOutAccessErrorZ_clone_ptr(arg_conv);
18155         return ret_conv;
18156 }
18157
18158 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18159         LDKCResult_TxOutAccessErrorZ* orig_conv = (LDKCResult_TxOutAccessErrorZ*)untag_ptr(orig);
18160         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
18161         *ret_conv = CResult_TxOutAccessErrorZ_clone(orig_conv);
18162         return tag_ptr(ret_conv, true);
18163 }
18164
18165 static inline uint64_t C2Tuple_usizeTransactionZ_clone_ptr(LDKC2Tuple_usizeTransactionZ *NONNULL_PTR arg) {
18166         LDKC2Tuple_usizeTransactionZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
18167         *ret_conv = C2Tuple_usizeTransactionZ_clone(arg);
18168         return tag_ptr(ret_conv, true);
18169 }
18170 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18171         LDKC2Tuple_usizeTransactionZ* arg_conv = (LDKC2Tuple_usizeTransactionZ*)untag_ptr(arg);
18172         int64_t ret_conv = C2Tuple_usizeTransactionZ_clone_ptr(arg_conv);
18173         return ret_conv;
18174 }
18175
18176 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18177         LDKC2Tuple_usizeTransactionZ* orig_conv = (LDKC2Tuple_usizeTransactionZ*)untag_ptr(orig);
18178         LDKC2Tuple_usizeTransactionZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
18179         *ret_conv = C2Tuple_usizeTransactionZ_clone(orig_conv);
18180         return tag_ptr(ret_conv, true);
18181 }
18182
18183 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_1new(JNIEnv *env, jclass clz, int64_t a, int8_tArray b) {
18184         LDKTransaction b_ref;
18185         b_ref.datalen = (*env)->GetArrayLength(env, b);
18186         b_ref.data = MALLOC(b_ref.datalen, "LDKTransaction Bytes");
18187         (*env)->GetByteArrayRegion(env, b, 0, b_ref.datalen, b_ref.data);
18188         b_ref.data_is_owned = true;
18189         LDKC2Tuple_usizeTransactionZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
18190         *ret_conv = C2Tuple_usizeTransactionZ_new(a, b_ref);
18191         return tag_ptr(ret_conv, true);
18192 }
18193
18194 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18195         if (!ptr_is_owned(_res)) return;
18196         void* _res_ptr = untag_ptr(_res);
18197         CHECK_ACCESS(_res_ptr);
18198         LDKC2Tuple_usizeTransactionZ _res_conv = *(LDKC2Tuple_usizeTransactionZ*)(_res_ptr);
18199         FREE(untag_ptr(_res));
18200         C2Tuple_usizeTransactionZ_free(_res_conv);
18201 }
18202
18203 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1usizeTransactionZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
18204         LDKCVec_C2Tuple_usizeTransactionZZ _res_constr;
18205         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
18206         if (_res_constr.datalen > 0)
18207                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
18208         else
18209                 _res_constr.data = NULL;
18210         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
18211         for (size_t c = 0; c < _res_constr.datalen; c++) {
18212                 int64_t _res_conv_28 = _res_vals[c];
18213                 void* _res_conv_28_ptr = untag_ptr(_res_conv_28);
18214                 CHECK_ACCESS(_res_conv_28_ptr);
18215                 LDKC2Tuple_usizeTransactionZ _res_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(_res_conv_28_ptr);
18216                 FREE(untag_ptr(_res_conv_28));
18217                 _res_constr.data[c] = _res_conv_28_conv;
18218         }
18219         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
18220         CVec_C2Tuple_usizeTransactionZZ_free(_res_constr);
18221 }
18222
18223 static inline uint64_t C2Tuple_TxidBlockHashZ_clone_ptr(LDKC2Tuple_TxidBlockHashZ *NONNULL_PTR arg) {
18224         LDKC2Tuple_TxidBlockHashZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidBlockHashZ), "LDKC2Tuple_TxidBlockHashZ");
18225         *ret_conv = C2Tuple_TxidBlockHashZ_clone(arg);
18226         return tag_ptr(ret_conv, true);
18227 }
18228 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidBlockHashZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18229         LDKC2Tuple_TxidBlockHashZ* arg_conv = (LDKC2Tuple_TxidBlockHashZ*)untag_ptr(arg);
18230         int64_t ret_conv = C2Tuple_TxidBlockHashZ_clone_ptr(arg_conv);
18231         return ret_conv;
18232 }
18233
18234 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidBlockHashZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18235         LDKC2Tuple_TxidBlockHashZ* orig_conv = (LDKC2Tuple_TxidBlockHashZ*)untag_ptr(orig);
18236         LDKC2Tuple_TxidBlockHashZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidBlockHashZ), "LDKC2Tuple_TxidBlockHashZ");
18237         *ret_conv = C2Tuple_TxidBlockHashZ_clone(orig_conv);
18238         return tag_ptr(ret_conv, true);
18239 }
18240
18241 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidBlockHashZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int8_tArray b) {
18242         LDKThirtyTwoBytes a_ref;
18243         CHECK((*env)->GetArrayLength(env, a) == 32);
18244         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
18245         LDKThirtyTwoBytes b_ref;
18246         CHECK((*env)->GetArrayLength(env, b) == 32);
18247         (*env)->GetByteArrayRegion(env, b, 0, 32, b_ref.data);
18248         LDKC2Tuple_TxidBlockHashZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidBlockHashZ), "LDKC2Tuple_TxidBlockHashZ");
18249         *ret_conv = C2Tuple_TxidBlockHashZ_new(a_ref, b_ref);
18250         return tag_ptr(ret_conv, true);
18251 }
18252
18253 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidBlockHashZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18254         if (!ptr_is_owned(_res)) return;
18255         void* _res_ptr = untag_ptr(_res);
18256         CHECK_ACCESS(_res_ptr);
18257         LDKC2Tuple_TxidBlockHashZ _res_conv = *(LDKC2Tuple_TxidBlockHashZ*)(_res_ptr);
18258         FREE(untag_ptr(_res));
18259         C2Tuple_TxidBlockHashZ_free(_res_conv);
18260 }
18261
18262 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1TxidBlockHashZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
18263         LDKCVec_C2Tuple_TxidBlockHashZZ _res_constr;
18264         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
18265         if (_res_constr.datalen > 0)
18266                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_TxidBlockHashZ), "LDKCVec_C2Tuple_TxidBlockHashZZ Elements");
18267         else
18268                 _res_constr.data = NULL;
18269         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
18270         for (size_t z = 0; z < _res_constr.datalen; z++) {
18271                 int64_t _res_conv_25 = _res_vals[z];
18272                 void* _res_conv_25_ptr = untag_ptr(_res_conv_25);
18273                 CHECK_ACCESS(_res_conv_25_ptr);
18274                 LDKC2Tuple_TxidBlockHashZ _res_conv_25_conv = *(LDKC2Tuple_TxidBlockHashZ*)(_res_conv_25_ptr);
18275                 FREE(untag_ptr(_res_conv_25));
18276                 _res_constr.data[z] = _res_conv_25_conv;
18277         }
18278         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
18279         CVec_C2Tuple_TxidBlockHashZZ_free(_res_constr);
18280 }
18281
18282 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1MonitorEventZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
18283         LDKCVec_MonitorEventZ _res_constr;
18284         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
18285         if (_res_constr.datalen > 0)
18286                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKMonitorEvent), "LDKCVec_MonitorEventZ Elements");
18287         else
18288                 _res_constr.data = NULL;
18289         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
18290         for (size_t o = 0; o < _res_constr.datalen; o++) {
18291                 int64_t _res_conv_14 = _res_vals[o];
18292                 void* _res_conv_14_ptr = untag_ptr(_res_conv_14);
18293                 CHECK_ACCESS(_res_conv_14_ptr);
18294                 LDKMonitorEvent _res_conv_14_conv = *(LDKMonitorEvent*)(_res_conv_14_ptr);
18295                 FREE(untag_ptr(_res_conv_14));
18296                 _res_constr.data[o] = _res_conv_14_conv;
18297         }
18298         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
18299         CVec_MonitorEventZ_free(_res_constr);
18300 }
18301
18302 static inline uint64_t C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_clone_ptr(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ *NONNULL_PTR arg) {
18303         LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ), "LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ");
18304         *ret_conv = C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_clone(arg);
18305         return tag_ptr(ret_conv, true);
18306 }
18307 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1OutPointCVec_1MonitorEventZPublicKeyZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18308         LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ* arg_conv = (LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ*)untag_ptr(arg);
18309         int64_t ret_conv = C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_clone_ptr(arg_conv);
18310         return ret_conv;
18311 }
18312
18313 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1OutPointCVec_1MonitorEventZPublicKeyZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18314         LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ* orig_conv = (LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ*)untag_ptr(orig);
18315         LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ), "LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ");
18316         *ret_conv = C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_clone(orig_conv);
18317         return tag_ptr(ret_conv, true);
18318 }
18319
18320 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) {
18321         LDKOutPoint a_conv;
18322         a_conv.inner = untag_ptr(a);
18323         a_conv.is_owned = ptr_is_owned(a);
18324         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
18325         a_conv = OutPoint_clone(&a_conv);
18326         LDKCVec_MonitorEventZ b_constr;
18327         b_constr.datalen = (*env)->GetArrayLength(env, b);
18328         if (b_constr.datalen > 0)
18329                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKMonitorEvent), "LDKCVec_MonitorEventZ Elements");
18330         else
18331                 b_constr.data = NULL;
18332         int64_t* b_vals = (*env)->GetLongArrayElements (env, b, NULL);
18333         for (size_t o = 0; o < b_constr.datalen; o++) {
18334                 int64_t b_conv_14 = b_vals[o];
18335                 void* b_conv_14_ptr = untag_ptr(b_conv_14);
18336                 CHECK_ACCESS(b_conv_14_ptr);
18337                 LDKMonitorEvent b_conv_14_conv = *(LDKMonitorEvent*)(b_conv_14_ptr);
18338                 b_conv_14_conv = MonitorEvent_clone((LDKMonitorEvent*)untag_ptr(b_conv_14));
18339                 b_constr.data[o] = b_conv_14_conv;
18340         }
18341         (*env)->ReleaseLongArrayElements(env, b, b_vals, 0);
18342         LDKPublicKey c_ref;
18343         CHECK((*env)->GetArrayLength(env, c) == 33);
18344         (*env)->GetByteArrayRegion(env, c, 0, 33, c_ref.compressed_form);
18345         LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ), "LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ");
18346         *ret_conv = C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_new(a_conv, b_constr, c_ref);
18347         return tag_ptr(ret_conv, true);
18348 }
18349
18350 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C3Tuple_1OutPointCVec_1MonitorEventZPublicKeyZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18351         if (!ptr_is_owned(_res)) return;
18352         void* _res_ptr = untag_ptr(_res);
18353         CHECK_ACCESS(_res_ptr);
18354         LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ _res_conv = *(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ*)(_res_ptr);
18355         FREE(untag_ptr(_res));
18356         C3Tuple_OutPointCVec_MonitorEventZPublicKeyZ_free(_res_conv);
18357 }
18358
18359 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C3Tuple_1OutPointCVec_1MonitorEventZPublicKeyZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
18360         LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ _res_constr;
18361         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
18362         if (_res_constr.datalen > 0)
18363                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ), "LDKCVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ Elements");
18364         else
18365                 _res_constr.data = NULL;
18366         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
18367         for (size_t x = 0; x < _res_constr.datalen; x++) {
18368                 int64_t _res_conv_49 = _res_vals[x];
18369                 void* _res_conv_49_ptr = untag_ptr(_res_conv_49);
18370                 CHECK_ACCESS(_res_conv_49_ptr);
18371                 LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ _res_conv_49_conv = *(LDKC3Tuple_OutPointCVec_MonitorEventZPublicKeyZ*)(_res_conv_49_ptr);
18372                 FREE(untag_ptr(_res_conv_49));
18373                 _res_constr.data[x] = _res_conv_49_conv;
18374         }
18375         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
18376         CVec_C3Tuple_OutPointCVec_MonitorEventZPublicKeyZZ_free(_res_constr);
18377 }
18378
18379 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FixedPenaltyScorerDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18380         LDKFixedPenaltyScorer o_conv;
18381         o_conv.inner = untag_ptr(o);
18382         o_conv.is_owned = ptr_is_owned(o);
18383         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18384         o_conv = FixedPenaltyScorer_clone(&o_conv);
18385         LDKCResult_FixedPenaltyScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FixedPenaltyScorerDecodeErrorZ), "LDKCResult_FixedPenaltyScorerDecodeErrorZ");
18386         *ret_conv = CResult_FixedPenaltyScorerDecodeErrorZ_ok(o_conv);
18387         return tag_ptr(ret_conv, true);
18388 }
18389
18390 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FixedPenaltyScorerDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18391         void* e_ptr = untag_ptr(e);
18392         CHECK_ACCESS(e_ptr);
18393         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
18394         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
18395         LDKCResult_FixedPenaltyScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FixedPenaltyScorerDecodeErrorZ), "LDKCResult_FixedPenaltyScorerDecodeErrorZ");
18396         *ret_conv = CResult_FixedPenaltyScorerDecodeErrorZ_err(e_conv);
18397         return tag_ptr(ret_conv, true);
18398 }
18399
18400 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1FixedPenaltyScorerDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18401         LDKCResult_FixedPenaltyScorerDecodeErrorZ* o_conv = (LDKCResult_FixedPenaltyScorerDecodeErrorZ*)untag_ptr(o);
18402         jboolean ret_conv = CResult_FixedPenaltyScorerDecodeErrorZ_is_ok(o_conv);
18403         return ret_conv;
18404 }
18405
18406 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1FixedPenaltyScorerDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18407         if (!ptr_is_owned(_res)) return;
18408         void* _res_ptr = untag_ptr(_res);
18409         CHECK_ACCESS(_res_ptr);
18410         LDKCResult_FixedPenaltyScorerDecodeErrorZ _res_conv = *(LDKCResult_FixedPenaltyScorerDecodeErrorZ*)(_res_ptr);
18411         FREE(untag_ptr(_res));
18412         CResult_FixedPenaltyScorerDecodeErrorZ_free(_res_conv);
18413 }
18414
18415 static inline uint64_t CResult_FixedPenaltyScorerDecodeErrorZ_clone_ptr(LDKCResult_FixedPenaltyScorerDecodeErrorZ *NONNULL_PTR arg) {
18416         LDKCResult_FixedPenaltyScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FixedPenaltyScorerDecodeErrorZ), "LDKCResult_FixedPenaltyScorerDecodeErrorZ");
18417         *ret_conv = CResult_FixedPenaltyScorerDecodeErrorZ_clone(arg);
18418         return tag_ptr(ret_conv, true);
18419 }
18420 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FixedPenaltyScorerDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18421         LDKCResult_FixedPenaltyScorerDecodeErrorZ* arg_conv = (LDKCResult_FixedPenaltyScorerDecodeErrorZ*)untag_ptr(arg);
18422         int64_t ret_conv = CResult_FixedPenaltyScorerDecodeErrorZ_clone_ptr(arg_conv);
18423         return ret_conv;
18424 }
18425
18426 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FixedPenaltyScorerDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18427         LDKCResult_FixedPenaltyScorerDecodeErrorZ* orig_conv = (LDKCResult_FixedPenaltyScorerDecodeErrorZ*)untag_ptr(orig);
18428         LDKCResult_FixedPenaltyScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FixedPenaltyScorerDecodeErrorZ), "LDKCResult_FixedPenaltyScorerDecodeErrorZ");
18429         *ret_conv = CResult_FixedPenaltyScorerDecodeErrorZ_clone(orig_conv);
18430         return tag_ptr(ret_conv, true);
18431 }
18432
18433 static inline uint64_t C2Tuple_u64u64Z_clone_ptr(LDKC2Tuple_u64u64Z *NONNULL_PTR arg) {
18434         LDKC2Tuple_u64u64Z* ret_conv = MALLOC(sizeof(LDKC2Tuple_u64u64Z), "LDKC2Tuple_u64u64Z");
18435         *ret_conv = C2Tuple_u64u64Z_clone(arg);
18436         return tag_ptr(ret_conv, true);
18437 }
18438 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u64u64Z_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18439         LDKC2Tuple_u64u64Z* arg_conv = (LDKC2Tuple_u64u64Z*)untag_ptr(arg);
18440         int64_t ret_conv = C2Tuple_u64u64Z_clone_ptr(arg_conv);
18441         return ret_conv;
18442 }
18443
18444 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u64u64Z_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18445         LDKC2Tuple_u64u64Z* orig_conv = (LDKC2Tuple_u64u64Z*)untag_ptr(orig);
18446         LDKC2Tuple_u64u64Z* ret_conv = MALLOC(sizeof(LDKC2Tuple_u64u64Z), "LDKC2Tuple_u64u64Z");
18447         *ret_conv = C2Tuple_u64u64Z_clone(orig_conv);
18448         return tag_ptr(ret_conv, true);
18449 }
18450
18451 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u64u64Z_1new(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
18452         LDKC2Tuple_u64u64Z* ret_conv = MALLOC(sizeof(LDKC2Tuple_u64u64Z), "LDKC2Tuple_u64u64Z");
18453         *ret_conv = C2Tuple_u64u64Z_new(a, b);
18454         return tag_ptr(ret_conv, true);
18455 }
18456
18457 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u64u64Z_1free(JNIEnv *env, jclass clz, int64_t _res) {
18458         if (!ptr_is_owned(_res)) return;
18459         void* _res_ptr = untag_ptr(_res);
18460         CHECK_ACCESS(_res_ptr);
18461         LDKC2Tuple_u64u64Z _res_conv = *(LDKC2Tuple_u64u64Z*)(_res_ptr);
18462         FREE(untag_ptr(_res));
18463         C2Tuple_u64u64Z_free(_res_conv);
18464 }
18465
18466 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1u64u64ZZ_1some(JNIEnv *env, jclass clz, int64_t o) {
18467         void* o_ptr = untag_ptr(o);
18468         CHECK_ACCESS(o_ptr);
18469         LDKC2Tuple_u64u64Z o_conv = *(LDKC2Tuple_u64u64Z*)(o_ptr);
18470         o_conv = C2Tuple_u64u64Z_clone((LDKC2Tuple_u64u64Z*)untag_ptr(o));
18471         LDKCOption_C2Tuple_u64u64ZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_u64u64ZZ), "LDKCOption_C2Tuple_u64u64ZZ");
18472         *ret_copy = COption_C2Tuple_u64u64ZZ_some(o_conv);
18473         int64_t ret_ref = tag_ptr(ret_copy, true);
18474         return ret_ref;
18475 }
18476
18477 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1u64u64ZZ_1none(JNIEnv *env, jclass clz) {
18478         LDKCOption_C2Tuple_u64u64ZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_u64u64ZZ), "LDKCOption_C2Tuple_u64u64ZZ");
18479         *ret_copy = COption_C2Tuple_u64u64ZZ_none();
18480         int64_t ret_ref = tag_ptr(ret_copy, true);
18481         return ret_ref;
18482 }
18483
18484 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1u64u64ZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18485         if (!ptr_is_owned(_res)) return;
18486         void* _res_ptr = untag_ptr(_res);
18487         CHECK_ACCESS(_res_ptr);
18488         LDKCOption_C2Tuple_u64u64ZZ _res_conv = *(LDKCOption_C2Tuple_u64u64ZZ*)(_res_ptr);
18489         FREE(untag_ptr(_res));
18490         COption_C2Tuple_u64u64ZZ_free(_res_conv);
18491 }
18492
18493 static inline uint64_t COption_C2Tuple_u64u64ZZ_clone_ptr(LDKCOption_C2Tuple_u64u64ZZ *NONNULL_PTR arg) {
18494         LDKCOption_C2Tuple_u64u64ZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_u64u64ZZ), "LDKCOption_C2Tuple_u64u64ZZ");
18495         *ret_copy = COption_C2Tuple_u64u64ZZ_clone(arg);
18496         int64_t ret_ref = tag_ptr(ret_copy, true);
18497         return ret_ref;
18498 }
18499 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1u64u64ZZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18500         LDKCOption_C2Tuple_u64u64ZZ* arg_conv = (LDKCOption_C2Tuple_u64u64ZZ*)untag_ptr(arg);
18501         int64_t ret_conv = COption_C2Tuple_u64u64ZZ_clone_ptr(arg_conv);
18502         return ret_conv;
18503 }
18504
18505 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1u64u64ZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18506         LDKCOption_C2Tuple_u64u64ZZ* orig_conv = (LDKCOption_C2Tuple_u64u64ZZ*)untag_ptr(orig);
18507         LDKCOption_C2Tuple_u64u64ZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_u64u64ZZ), "LDKCOption_C2Tuple_u64u64ZZ");
18508         *ret_copy = COption_C2Tuple_u64u64ZZ_clone(orig_conv);
18509         int64_t ret_ref = tag_ptr(ret_copy, true);
18510         return ret_ref;
18511 }
18512
18513 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1NodeIdZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
18514         LDKCVec_NodeIdZ _res_constr;
18515         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
18516         if (_res_constr.datalen > 0)
18517                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKNodeId), "LDKCVec_NodeIdZ Elements");
18518         else
18519                 _res_constr.data = NULL;
18520         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
18521         for (size_t i = 0; i < _res_constr.datalen; i++) {
18522                 int64_t _res_conv_8 = _res_vals[i];
18523                 LDKNodeId _res_conv_8_conv;
18524                 _res_conv_8_conv.inner = untag_ptr(_res_conv_8);
18525                 _res_conv_8_conv.is_owned = ptr_is_owned(_res_conv_8);
18526                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_8_conv);
18527                 _res_constr.data[i] = _res_conv_8_conv;
18528         }
18529         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
18530         CVec_NodeIdZ_free(_res_constr);
18531 }
18532
18533 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ProbabilisticScorerDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18534         LDKProbabilisticScorer o_conv;
18535         o_conv.inner = untag_ptr(o);
18536         o_conv.is_owned = ptr_is_owned(o);
18537         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18538         // WARNING: we need a move here but no clone is available for LDKProbabilisticScorer
18539         
18540         LDKCResult_ProbabilisticScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ProbabilisticScorerDecodeErrorZ), "LDKCResult_ProbabilisticScorerDecodeErrorZ");
18541         *ret_conv = CResult_ProbabilisticScorerDecodeErrorZ_ok(o_conv);
18542         return tag_ptr(ret_conv, true);
18543 }
18544
18545 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ProbabilisticScorerDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18546         void* e_ptr = untag_ptr(e);
18547         CHECK_ACCESS(e_ptr);
18548         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
18549         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
18550         LDKCResult_ProbabilisticScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ProbabilisticScorerDecodeErrorZ), "LDKCResult_ProbabilisticScorerDecodeErrorZ");
18551         *ret_conv = CResult_ProbabilisticScorerDecodeErrorZ_err(e_conv);
18552         return tag_ptr(ret_conv, true);
18553 }
18554
18555 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ProbabilisticScorerDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18556         LDKCResult_ProbabilisticScorerDecodeErrorZ* o_conv = (LDKCResult_ProbabilisticScorerDecodeErrorZ*)untag_ptr(o);
18557         jboolean ret_conv = CResult_ProbabilisticScorerDecodeErrorZ_is_ok(o_conv);
18558         return ret_conv;
18559 }
18560
18561 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ProbabilisticScorerDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18562         if (!ptr_is_owned(_res)) return;
18563         void* _res_ptr = untag_ptr(_res);
18564         CHECK_ACCESS(_res_ptr);
18565         LDKCResult_ProbabilisticScorerDecodeErrorZ _res_conv = *(LDKCResult_ProbabilisticScorerDecodeErrorZ*)(_res_ptr);
18566         FREE(untag_ptr(_res));
18567         CResult_ProbabilisticScorerDecodeErrorZ_free(_res_conv);
18568 }
18569
18570 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18571         LDKInitFeatures o_conv;
18572         o_conv.inner = untag_ptr(o);
18573         o_conv.is_owned = ptr_is_owned(o);
18574         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18575         o_conv = InitFeatures_clone(&o_conv);
18576         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
18577         *ret_conv = CResult_InitFeaturesDecodeErrorZ_ok(o_conv);
18578         return tag_ptr(ret_conv, true);
18579 }
18580
18581 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18582         void* e_ptr = untag_ptr(e);
18583         CHECK_ACCESS(e_ptr);
18584         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
18585         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
18586         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
18587         *ret_conv = CResult_InitFeaturesDecodeErrorZ_err(e_conv);
18588         return tag_ptr(ret_conv, true);
18589 }
18590
18591 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18592         LDKCResult_InitFeaturesDecodeErrorZ* o_conv = (LDKCResult_InitFeaturesDecodeErrorZ*)untag_ptr(o);
18593         jboolean ret_conv = CResult_InitFeaturesDecodeErrorZ_is_ok(o_conv);
18594         return ret_conv;
18595 }
18596
18597 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18598         if (!ptr_is_owned(_res)) return;
18599         void* _res_ptr = untag_ptr(_res);
18600         CHECK_ACCESS(_res_ptr);
18601         LDKCResult_InitFeaturesDecodeErrorZ _res_conv = *(LDKCResult_InitFeaturesDecodeErrorZ*)(_res_ptr);
18602         FREE(untag_ptr(_res));
18603         CResult_InitFeaturesDecodeErrorZ_free(_res_conv);
18604 }
18605
18606 static inline uint64_t CResult_InitFeaturesDecodeErrorZ_clone_ptr(LDKCResult_InitFeaturesDecodeErrorZ *NONNULL_PTR arg) {
18607         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
18608         *ret_conv = CResult_InitFeaturesDecodeErrorZ_clone(arg);
18609         return tag_ptr(ret_conv, true);
18610 }
18611 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18612         LDKCResult_InitFeaturesDecodeErrorZ* arg_conv = (LDKCResult_InitFeaturesDecodeErrorZ*)untag_ptr(arg);
18613         int64_t ret_conv = CResult_InitFeaturesDecodeErrorZ_clone_ptr(arg_conv);
18614         return ret_conv;
18615 }
18616
18617 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18618         LDKCResult_InitFeaturesDecodeErrorZ* orig_conv = (LDKCResult_InitFeaturesDecodeErrorZ*)untag_ptr(orig);
18619         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
18620         *ret_conv = CResult_InitFeaturesDecodeErrorZ_clone(orig_conv);
18621         return tag_ptr(ret_conv, true);
18622 }
18623
18624 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18625         LDKChannelFeatures o_conv;
18626         o_conv.inner = untag_ptr(o);
18627         o_conv.is_owned = ptr_is_owned(o);
18628         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18629         o_conv = ChannelFeatures_clone(&o_conv);
18630         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
18631         *ret_conv = CResult_ChannelFeaturesDecodeErrorZ_ok(o_conv);
18632         return tag_ptr(ret_conv, true);
18633 }
18634
18635 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18636         void* e_ptr = untag_ptr(e);
18637         CHECK_ACCESS(e_ptr);
18638         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
18639         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
18640         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
18641         *ret_conv = CResult_ChannelFeaturesDecodeErrorZ_err(e_conv);
18642         return tag_ptr(ret_conv, true);
18643 }
18644
18645 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18646         LDKCResult_ChannelFeaturesDecodeErrorZ* o_conv = (LDKCResult_ChannelFeaturesDecodeErrorZ*)untag_ptr(o);
18647         jboolean ret_conv = CResult_ChannelFeaturesDecodeErrorZ_is_ok(o_conv);
18648         return ret_conv;
18649 }
18650
18651 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18652         if (!ptr_is_owned(_res)) return;
18653         void* _res_ptr = untag_ptr(_res);
18654         CHECK_ACCESS(_res_ptr);
18655         LDKCResult_ChannelFeaturesDecodeErrorZ _res_conv = *(LDKCResult_ChannelFeaturesDecodeErrorZ*)(_res_ptr);
18656         FREE(untag_ptr(_res));
18657         CResult_ChannelFeaturesDecodeErrorZ_free(_res_conv);
18658 }
18659
18660 static inline uint64_t CResult_ChannelFeaturesDecodeErrorZ_clone_ptr(LDKCResult_ChannelFeaturesDecodeErrorZ *NONNULL_PTR arg) {
18661         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
18662         *ret_conv = CResult_ChannelFeaturesDecodeErrorZ_clone(arg);
18663         return tag_ptr(ret_conv, true);
18664 }
18665 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18666         LDKCResult_ChannelFeaturesDecodeErrorZ* arg_conv = (LDKCResult_ChannelFeaturesDecodeErrorZ*)untag_ptr(arg);
18667         int64_t ret_conv = CResult_ChannelFeaturesDecodeErrorZ_clone_ptr(arg_conv);
18668         return ret_conv;
18669 }
18670
18671 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18672         LDKCResult_ChannelFeaturesDecodeErrorZ* orig_conv = (LDKCResult_ChannelFeaturesDecodeErrorZ*)untag_ptr(orig);
18673         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
18674         *ret_conv = CResult_ChannelFeaturesDecodeErrorZ_clone(orig_conv);
18675         return tag_ptr(ret_conv, true);
18676 }
18677
18678 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18679         LDKNodeFeatures o_conv;
18680         o_conv.inner = untag_ptr(o);
18681         o_conv.is_owned = ptr_is_owned(o);
18682         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18683         o_conv = NodeFeatures_clone(&o_conv);
18684         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
18685         *ret_conv = CResult_NodeFeaturesDecodeErrorZ_ok(o_conv);
18686         return tag_ptr(ret_conv, true);
18687 }
18688
18689 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18690         void* e_ptr = untag_ptr(e);
18691         CHECK_ACCESS(e_ptr);
18692         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
18693         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
18694         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
18695         *ret_conv = CResult_NodeFeaturesDecodeErrorZ_err(e_conv);
18696         return tag_ptr(ret_conv, true);
18697 }
18698
18699 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18700         LDKCResult_NodeFeaturesDecodeErrorZ* o_conv = (LDKCResult_NodeFeaturesDecodeErrorZ*)untag_ptr(o);
18701         jboolean ret_conv = CResult_NodeFeaturesDecodeErrorZ_is_ok(o_conv);
18702         return ret_conv;
18703 }
18704
18705 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18706         if (!ptr_is_owned(_res)) return;
18707         void* _res_ptr = untag_ptr(_res);
18708         CHECK_ACCESS(_res_ptr);
18709         LDKCResult_NodeFeaturesDecodeErrorZ _res_conv = *(LDKCResult_NodeFeaturesDecodeErrorZ*)(_res_ptr);
18710         FREE(untag_ptr(_res));
18711         CResult_NodeFeaturesDecodeErrorZ_free(_res_conv);
18712 }
18713
18714 static inline uint64_t CResult_NodeFeaturesDecodeErrorZ_clone_ptr(LDKCResult_NodeFeaturesDecodeErrorZ *NONNULL_PTR arg) {
18715         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
18716         *ret_conv = CResult_NodeFeaturesDecodeErrorZ_clone(arg);
18717         return tag_ptr(ret_conv, true);
18718 }
18719 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18720         LDKCResult_NodeFeaturesDecodeErrorZ* arg_conv = (LDKCResult_NodeFeaturesDecodeErrorZ*)untag_ptr(arg);
18721         int64_t ret_conv = CResult_NodeFeaturesDecodeErrorZ_clone_ptr(arg_conv);
18722         return ret_conv;
18723 }
18724
18725 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18726         LDKCResult_NodeFeaturesDecodeErrorZ* orig_conv = (LDKCResult_NodeFeaturesDecodeErrorZ*)untag_ptr(orig);
18727         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
18728         *ret_conv = CResult_NodeFeaturesDecodeErrorZ_clone(orig_conv);
18729         return tag_ptr(ret_conv, true);
18730 }
18731
18732 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18733         LDKInvoiceFeatures o_conv;
18734         o_conv.inner = untag_ptr(o);
18735         o_conv.is_owned = ptr_is_owned(o);
18736         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18737         o_conv = InvoiceFeatures_clone(&o_conv);
18738         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
18739         *ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_ok(o_conv);
18740         return tag_ptr(ret_conv, true);
18741 }
18742
18743 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18744         void* e_ptr = untag_ptr(e);
18745         CHECK_ACCESS(e_ptr);
18746         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
18747         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
18748         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
18749         *ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_err(e_conv);
18750         return tag_ptr(ret_conv, true);
18751 }
18752
18753 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18754         LDKCResult_InvoiceFeaturesDecodeErrorZ* o_conv = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)untag_ptr(o);
18755         jboolean ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_is_ok(o_conv);
18756         return ret_conv;
18757 }
18758
18759 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18760         if (!ptr_is_owned(_res)) return;
18761         void* _res_ptr = untag_ptr(_res);
18762         CHECK_ACCESS(_res_ptr);
18763         LDKCResult_InvoiceFeaturesDecodeErrorZ _res_conv = *(LDKCResult_InvoiceFeaturesDecodeErrorZ*)(_res_ptr);
18764         FREE(untag_ptr(_res));
18765         CResult_InvoiceFeaturesDecodeErrorZ_free(_res_conv);
18766 }
18767
18768 static inline uint64_t CResult_InvoiceFeaturesDecodeErrorZ_clone_ptr(LDKCResult_InvoiceFeaturesDecodeErrorZ *NONNULL_PTR arg) {
18769         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
18770         *ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_clone(arg);
18771         return tag_ptr(ret_conv, true);
18772 }
18773 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18774         LDKCResult_InvoiceFeaturesDecodeErrorZ* arg_conv = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)untag_ptr(arg);
18775         int64_t ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_clone_ptr(arg_conv);
18776         return ret_conv;
18777 }
18778
18779 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18780         LDKCResult_InvoiceFeaturesDecodeErrorZ* orig_conv = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)untag_ptr(orig);
18781         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
18782         *ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_clone(orig_conv);
18783         return tag_ptr(ret_conv, true);
18784 }
18785
18786 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTypeFeaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18787         LDKChannelTypeFeatures o_conv;
18788         o_conv.inner = untag_ptr(o);
18789         o_conv.is_owned = ptr_is_owned(o);
18790         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18791         o_conv = ChannelTypeFeatures_clone(&o_conv);
18792         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTypeFeaturesDecodeErrorZ), "LDKCResult_ChannelTypeFeaturesDecodeErrorZ");
18793         *ret_conv = CResult_ChannelTypeFeaturesDecodeErrorZ_ok(o_conv);
18794         return tag_ptr(ret_conv, true);
18795 }
18796
18797 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTypeFeaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18798         void* e_ptr = untag_ptr(e);
18799         CHECK_ACCESS(e_ptr);
18800         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
18801         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
18802         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTypeFeaturesDecodeErrorZ), "LDKCResult_ChannelTypeFeaturesDecodeErrorZ");
18803         *ret_conv = CResult_ChannelTypeFeaturesDecodeErrorZ_err(e_conv);
18804         return tag_ptr(ret_conv, true);
18805 }
18806
18807 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTypeFeaturesDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18808         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* o_conv = (LDKCResult_ChannelTypeFeaturesDecodeErrorZ*)untag_ptr(o);
18809         jboolean ret_conv = CResult_ChannelTypeFeaturesDecodeErrorZ_is_ok(o_conv);
18810         return ret_conv;
18811 }
18812
18813 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTypeFeaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18814         if (!ptr_is_owned(_res)) return;
18815         void* _res_ptr = untag_ptr(_res);
18816         CHECK_ACCESS(_res_ptr);
18817         LDKCResult_ChannelTypeFeaturesDecodeErrorZ _res_conv = *(LDKCResult_ChannelTypeFeaturesDecodeErrorZ*)(_res_ptr);
18818         FREE(untag_ptr(_res));
18819         CResult_ChannelTypeFeaturesDecodeErrorZ_free(_res_conv);
18820 }
18821
18822 static inline uint64_t CResult_ChannelTypeFeaturesDecodeErrorZ_clone_ptr(LDKCResult_ChannelTypeFeaturesDecodeErrorZ *NONNULL_PTR arg) {
18823         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTypeFeaturesDecodeErrorZ), "LDKCResult_ChannelTypeFeaturesDecodeErrorZ");
18824         *ret_conv = CResult_ChannelTypeFeaturesDecodeErrorZ_clone(arg);
18825         return tag_ptr(ret_conv, true);
18826 }
18827 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTypeFeaturesDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18828         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* arg_conv = (LDKCResult_ChannelTypeFeaturesDecodeErrorZ*)untag_ptr(arg);
18829         int64_t ret_conv = CResult_ChannelTypeFeaturesDecodeErrorZ_clone_ptr(arg_conv);
18830         return ret_conv;
18831 }
18832
18833 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTypeFeaturesDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18834         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* orig_conv = (LDKCResult_ChannelTypeFeaturesDecodeErrorZ*)untag_ptr(orig);
18835         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTypeFeaturesDecodeErrorZ), "LDKCResult_ChannelTypeFeaturesDecodeErrorZ");
18836         *ret_conv = CResult_ChannelTypeFeaturesDecodeErrorZ_clone(orig_conv);
18837         return tag_ptr(ret_conv, true);
18838 }
18839
18840 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OfferFeaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18841         LDKOfferFeatures o_conv;
18842         o_conv.inner = untag_ptr(o);
18843         o_conv.is_owned = ptr_is_owned(o);
18844         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18845         o_conv = OfferFeatures_clone(&o_conv);
18846         LDKCResult_OfferFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OfferFeaturesDecodeErrorZ), "LDKCResult_OfferFeaturesDecodeErrorZ");
18847         *ret_conv = CResult_OfferFeaturesDecodeErrorZ_ok(o_conv);
18848         return tag_ptr(ret_conv, true);
18849 }
18850
18851 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OfferFeaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18852         void* e_ptr = untag_ptr(e);
18853         CHECK_ACCESS(e_ptr);
18854         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
18855         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
18856         LDKCResult_OfferFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OfferFeaturesDecodeErrorZ), "LDKCResult_OfferFeaturesDecodeErrorZ");
18857         *ret_conv = CResult_OfferFeaturesDecodeErrorZ_err(e_conv);
18858         return tag_ptr(ret_conv, true);
18859 }
18860
18861 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1OfferFeaturesDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18862         LDKCResult_OfferFeaturesDecodeErrorZ* o_conv = (LDKCResult_OfferFeaturesDecodeErrorZ*)untag_ptr(o);
18863         jboolean ret_conv = CResult_OfferFeaturesDecodeErrorZ_is_ok(o_conv);
18864         return ret_conv;
18865 }
18866
18867 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1OfferFeaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18868         if (!ptr_is_owned(_res)) return;
18869         void* _res_ptr = untag_ptr(_res);
18870         CHECK_ACCESS(_res_ptr);
18871         LDKCResult_OfferFeaturesDecodeErrorZ _res_conv = *(LDKCResult_OfferFeaturesDecodeErrorZ*)(_res_ptr);
18872         FREE(untag_ptr(_res));
18873         CResult_OfferFeaturesDecodeErrorZ_free(_res_conv);
18874 }
18875
18876 static inline uint64_t CResult_OfferFeaturesDecodeErrorZ_clone_ptr(LDKCResult_OfferFeaturesDecodeErrorZ *NONNULL_PTR arg) {
18877         LDKCResult_OfferFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OfferFeaturesDecodeErrorZ), "LDKCResult_OfferFeaturesDecodeErrorZ");
18878         *ret_conv = CResult_OfferFeaturesDecodeErrorZ_clone(arg);
18879         return tag_ptr(ret_conv, true);
18880 }
18881 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OfferFeaturesDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18882         LDKCResult_OfferFeaturesDecodeErrorZ* arg_conv = (LDKCResult_OfferFeaturesDecodeErrorZ*)untag_ptr(arg);
18883         int64_t ret_conv = CResult_OfferFeaturesDecodeErrorZ_clone_ptr(arg_conv);
18884         return ret_conv;
18885 }
18886
18887 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OfferFeaturesDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18888         LDKCResult_OfferFeaturesDecodeErrorZ* orig_conv = (LDKCResult_OfferFeaturesDecodeErrorZ*)untag_ptr(orig);
18889         LDKCResult_OfferFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OfferFeaturesDecodeErrorZ), "LDKCResult_OfferFeaturesDecodeErrorZ");
18890         *ret_conv = CResult_OfferFeaturesDecodeErrorZ_clone(orig_conv);
18891         return tag_ptr(ret_conv, true);
18892 }
18893
18894 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceRequestFeaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18895         LDKInvoiceRequestFeatures o_conv;
18896         o_conv.inner = untag_ptr(o);
18897         o_conv.is_owned = ptr_is_owned(o);
18898         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18899         o_conv = InvoiceRequestFeatures_clone(&o_conv);
18900         LDKCResult_InvoiceRequestFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceRequestFeaturesDecodeErrorZ), "LDKCResult_InvoiceRequestFeaturesDecodeErrorZ");
18901         *ret_conv = CResult_InvoiceRequestFeaturesDecodeErrorZ_ok(o_conv);
18902         return tag_ptr(ret_conv, true);
18903 }
18904
18905 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceRequestFeaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18906         void* e_ptr = untag_ptr(e);
18907         CHECK_ACCESS(e_ptr);
18908         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
18909         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
18910         LDKCResult_InvoiceRequestFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceRequestFeaturesDecodeErrorZ), "LDKCResult_InvoiceRequestFeaturesDecodeErrorZ");
18911         *ret_conv = CResult_InvoiceRequestFeaturesDecodeErrorZ_err(e_conv);
18912         return tag_ptr(ret_conv, true);
18913 }
18914
18915 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceRequestFeaturesDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18916         LDKCResult_InvoiceRequestFeaturesDecodeErrorZ* o_conv = (LDKCResult_InvoiceRequestFeaturesDecodeErrorZ*)untag_ptr(o);
18917         jboolean ret_conv = CResult_InvoiceRequestFeaturesDecodeErrorZ_is_ok(o_conv);
18918         return ret_conv;
18919 }
18920
18921 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceRequestFeaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18922         if (!ptr_is_owned(_res)) return;
18923         void* _res_ptr = untag_ptr(_res);
18924         CHECK_ACCESS(_res_ptr);
18925         LDKCResult_InvoiceRequestFeaturesDecodeErrorZ _res_conv = *(LDKCResult_InvoiceRequestFeaturesDecodeErrorZ*)(_res_ptr);
18926         FREE(untag_ptr(_res));
18927         CResult_InvoiceRequestFeaturesDecodeErrorZ_free(_res_conv);
18928 }
18929
18930 static inline uint64_t CResult_InvoiceRequestFeaturesDecodeErrorZ_clone_ptr(LDKCResult_InvoiceRequestFeaturesDecodeErrorZ *NONNULL_PTR arg) {
18931         LDKCResult_InvoiceRequestFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceRequestFeaturesDecodeErrorZ), "LDKCResult_InvoiceRequestFeaturesDecodeErrorZ");
18932         *ret_conv = CResult_InvoiceRequestFeaturesDecodeErrorZ_clone(arg);
18933         return tag_ptr(ret_conv, true);
18934 }
18935 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceRequestFeaturesDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18936         LDKCResult_InvoiceRequestFeaturesDecodeErrorZ* arg_conv = (LDKCResult_InvoiceRequestFeaturesDecodeErrorZ*)untag_ptr(arg);
18937         int64_t ret_conv = CResult_InvoiceRequestFeaturesDecodeErrorZ_clone_ptr(arg_conv);
18938         return ret_conv;
18939 }
18940
18941 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceRequestFeaturesDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18942         LDKCResult_InvoiceRequestFeaturesDecodeErrorZ* orig_conv = (LDKCResult_InvoiceRequestFeaturesDecodeErrorZ*)untag_ptr(orig);
18943         LDKCResult_InvoiceRequestFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceRequestFeaturesDecodeErrorZ), "LDKCResult_InvoiceRequestFeaturesDecodeErrorZ");
18944         *ret_conv = CResult_InvoiceRequestFeaturesDecodeErrorZ_clone(orig_conv);
18945         return tag_ptr(ret_conv, true);
18946 }
18947
18948 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeIdDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18949         LDKNodeId o_conv;
18950         o_conv.inner = untag_ptr(o);
18951         o_conv.is_owned = ptr_is_owned(o);
18952         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18953         o_conv = NodeId_clone(&o_conv);
18954         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
18955         *ret_conv = CResult_NodeIdDecodeErrorZ_ok(o_conv);
18956         return tag_ptr(ret_conv, true);
18957 }
18958
18959 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeIdDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18960         void* e_ptr = untag_ptr(e);
18961         CHECK_ACCESS(e_ptr);
18962         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
18963         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
18964         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
18965         *ret_conv = CResult_NodeIdDecodeErrorZ_err(e_conv);
18966         return tag_ptr(ret_conv, true);
18967 }
18968
18969 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NodeIdDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18970         LDKCResult_NodeIdDecodeErrorZ* o_conv = (LDKCResult_NodeIdDecodeErrorZ*)untag_ptr(o);
18971         jboolean ret_conv = CResult_NodeIdDecodeErrorZ_is_ok(o_conv);
18972         return ret_conv;
18973 }
18974
18975 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeIdDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18976         if (!ptr_is_owned(_res)) return;
18977         void* _res_ptr = untag_ptr(_res);
18978         CHECK_ACCESS(_res_ptr);
18979         LDKCResult_NodeIdDecodeErrorZ _res_conv = *(LDKCResult_NodeIdDecodeErrorZ*)(_res_ptr);
18980         FREE(untag_ptr(_res));
18981         CResult_NodeIdDecodeErrorZ_free(_res_conv);
18982 }
18983
18984 static inline uint64_t CResult_NodeIdDecodeErrorZ_clone_ptr(LDKCResult_NodeIdDecodeErrorZ *NONNULL_PTR arg) {
18985         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
18986         *ret_conv = CResult_NodeIdDecodeErrorZ_clone(arg);
18987         return tag_ptr(ret_conv, true);
18988 }
18989 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeIdDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18990         LDKCResult_NodeIdDecodeErrorZ* arg_conv = (LDKCResult_NodeIdDecodeErrorZ*)untag_ptr(arg);
18991         int64_t ret_conv = CResult_NodeIdDecodeErrorZ_clone_ptr(arg_conv);
18992         return ret_conv;
18993 }
18994
18995 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeIdDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18996         LDKCResult_NodeIdDecodeErrorZ* orig_conv = (LDKCResult_NodeIdDecodeErrorZ*)untag_ptr(orig);
18997         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
18998         *ret_conv = CResult_NodeIdDecodeErrorZ_clone(orig_conv);
18999         return tag_ptr(ret_conv, true);
19000 }
19001
19002 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1NetworkUpdateZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
19003         void* o_ptr = untag_ptr(o);
19004         CHECK_ACCESS(o_ptr);
19005         LDKCOption_NetworkUpdateZ o_conv = *(LDKCOption_NetworkUpdateZ*)(o_ptr);
19006         o_conv = COption_NetworkUpdateZ_clone((LDKCOption_NetworkUpdateZ*)untag_ptr(o));
19007         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
19008         *ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_ok(o_conv);
19009         return tag_ptr(ret_conv, true);
19010 }
19011
19012 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1NetworkUpdateZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
19013         void* e_ptr = untag_ptr(e);
19014         CHECK_ACCESS(e_ptr);
19015         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
19016         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
19017         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
19018         *ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_err(e_conv);
19019         return tag_ptr(ret_conv, true);
19020 }
19021
19022 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1NetworkUpdateZDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19023         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* o_conv = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)untag_ptr(o);
19024         jboolean ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_is_ok(o_conv);
19025         return ret_conv;
19026 }
19027
19028 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1NetworkUpdateZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19029         if (!ptr_is_owned(_res)) return;
19030         void* _res_ptr = untag_ptr(_res);
19031         CHECK_ACCESS(_res_ptr);
19032         LDKCResult_COption_NetworkUpdateZDecodeErrorZ _res_conv = *(LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)(_res_ptr);
19033         FREE(untag_ptr(_res));
19034         CResult_COption_NetworkUpdateZDecodeErrorZ_free(_res_conv);
19035 }
19036
19037 static inline uint64_t CResult_COption_NetworkUpdateZDecodeErrorZ_clone_ptr(LDKCResult_COption_NetworkUpdateZDecodeErrorZ *NONNULL_PTR arg) {
19038         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
19039         *ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_clone(arg);
19040         return tag_ptr(ret_conv, true);
19041 }
19042 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1NetworkUpdateZDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19043         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* arg_conv = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)untag_ptr(arg);
19044         int64_t ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_clone_ptr(arg_conv);
19045         return ret_conv;
19046 }
19047
19048 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1NetworkUpdateZDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19049         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* orig_conv = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)untag_ptr(orig);
19050         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
19051         *ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_clone(orig_conv);
19052         return tag_ptr(ret_conv, true);
19053 }
19054
19055 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1AccessZ_1some(JNIEnv *env, jclass clz, int64_t o) {
19056         void* o_ptr = untag_ptr(o);
19057         CHECK_ACCESS(o_ptr);
19058         LDKAccess o_conv = *(LDKAccess*)(o_ptr);
19059         if (o_conv.free == LDKAccess_JCalls_free) {
19060                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
19061                 LDKAccess_JCalls_cloned(&o_conv);
19062         }
19063         LDKCOption_AccessZ *ret_copy = MALLOC(sizeof(LDKCOption_AccessZ), "LDKCOption_AccessZ");
19064         *ret_copy = COption_AccessZ_some(o_conv);
19065         int64_t ret_ref = tag_ptr(ret_copy, true);
19066         return ret_ref;
19067 }
19068
19069 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1AccessZ_1none(JNIEnv *env, jclass clz) {
19070         LDKCOption_AccessZ *ret_copy = MALLOC(sizeof(LDKCOption_AccessZ), "LDKCOption_AccessZ");
19071         *ret_copy = COption_AccessZ_none();
19072         int64_t ret_ref = tag_ptr(ret_copy, true);
19073         return ret_ref;
19074 }
19075
19076 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1AccessZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19077         if (!ptr_is_owned(_res)) return;
19078         void* _res_ptr = untag_ptr(_res);
19079         CHECK_ACCESS(_res_ptr);
19080         LDKCOption_AccessZ _res_conv = *(LDKCOption_AccessZ*)(_res_ptr);
19081         FREE(untag_ptr(_res));
19082         COption_AccessZ_free(_res_conv);
19083 }
19084
19085 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1ok(JNIEnv *env, jclass clz, jboolean o) {
19086         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
19087         *ret_conv = CResult_boolLightningErrorZ_ok(o);
19088         return tag_ptr(ret_conv, true);
19089 }
19090
19091 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
19092         LDKLightningError e_conv;
19093         e_conv.inner = untag_ptr(e);
19094         e_conv.is_owned = ptr_is_owned(e);
19095         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19096         e_conv = LightningError_clone(&e_conv);
19097         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
19098         *ret_conv = CResult_boolLightningErrorZ_err(e_conv);
19099         return tag_ptr(ret_conv, true);
19100 }
19101
19102 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19103         LDKCResult_boolLightningErrorZ* o_conv = (LDKCResult_boolLightningErrorZ*)untag_ptr(o);
19104         jboolean ret_conv = CResult_boolLightningErrorZ_is_ok(o_conv);
19105         return ret_conv;
19106 }
19107
19108 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19109         if (!ptr_is_owned(_res)) return;
19110         void* _res_ptr = untag_ptr(_res);
19111         CHECK_ACCESS(_res_ptr);
19112         LDKCResult_boolLightningErrorZ _res_conv = *(LDKCResult_boolLightningErrorZ*)(_res_ptr);
19113         FREE(untag_ptr(_res));
19114         CResult_boolLightningErrorZ_free(_res_conv);
19115 }
19116
19117 static inline uint64_t CResult_boolLightningErrorZ_clone_ptr(LDKCResult_boolLightningErrorZ *NONNULL_PTR arg) {
19118         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
19119         *ret_conv = CResult_boolLightningErrorZ_clone(arg);
19120         return tag_ptr(ret_conv, true);
19121 }
19122 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19123         LDKCResult_boolLightningErrorZ* arg_conv = (LDKCResult_boolLightningErrorZ*)untag_ptr(arg);
19124         int64_t ret_conv = CResult_boolLightningErrorZ_clone_ptr(arg_conv);
19125         return ret_conv;
19126 }
19127
19128 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19129         LDKCResult_boolLightningErrorZ* orig_conv = (LDKCResult_boolLightningErrorZ*)untag_ptr(orig);
19130         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
19131         *ret_conv = CResult_boolLightningErrorZ_clone(orig_conv);
19132         return tag_ptr(ret_conv, true);
19133 }
19134
19135 static inline uint64_t C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone_ptr(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *NONNULL_PTR arg) {
19136         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
19137         *ret_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(arg);
19138         return tag_ptr(ret_conv, true);
19139 }
19140 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19141         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* arg_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)untag_ptr(arg);
19142         int64_t ret_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone_ptr(arg_conv);
19143         return ret_conv;
19144 }
19145
19146 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19147         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* orig_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)untag_ptr(orig);
19148         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
19149         *ret_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(orig_conv);
19150         return tag_ptr(ret_conv, true);
19151 }
19152
19153 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) {
19154         LDKChannelAnnouncement a_conv;
19155         a_conv.inner = untag_ptr(a);
19156         a_conv.is_owned = ptr_is_owned(a);
19157         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
19158         a_conv = ChannelAnnouncement_clone(&a_conv);
19159         LDKChannelUpdate b_conv;
19160         b_conv.inner = untag_ptr(b);
19161         b_conv.is_owned = ptr_is_owned(b);
19162         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
19163         b_conv = ChannelUpdate_clone(&b_conv);
19164         LDKChannelUpdate c_conv;
19165         c_conv.inner = untag_ptr(c);
19166         c_conv.is_owned = ptr_is_owned(c);
19167         CHECK_INNER_FIELD_ACCESS_OR_NULL(c_conv);
19168         c_conv = ChannelUpdate_clone(&c_conv);
19169         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
19170         *ret_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_new(a_conv, b_conv, c_conv);
19171         return tag_ptr(ret_conv, true);
19172 }
19173
19174 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19175         if (!ptr_is_owned(_res)) return;
19176         void* _res_ptr = untag_ptr(_res);
19177         CHECK_ACCESS(_res_ptr);
19178         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ _res_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(_res_ptr);
19179         FREE(untag_ptr(_res));
19180         C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_free(_res_conv);
19181 }
19182
19183 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZZ_1some(JNIEnv *env, jclass clz, int64_t o) {
19184         void* o_ptr = untag_ptr(o);
19185         CHECK_ACCESS(o_ptr);
19186         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ o_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(o_ptr);
19187         o_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone((LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)untag_ptr(o));
19188         LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ *ret_copy = MALLOC(sizeof(LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ), "LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ");
19189         *ret_copy = COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_some(o_conv);
19190         int64_t ret_ref = tag_ptr(ret_copy, true);
19191         return ret_ref;
19192 }
19193
19194 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZZ_1none(JNIEnv *env, jclass clz) {
19195         LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ *ret_copy = MALLOC(sizeof(LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ), "LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ");
19196         *ret_copy = COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_none();
19197         int64_t ret_ref = tag_ptr(ret_copy, true);
19198         return ret_ref;
19199 }
19200
19201 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19202         if (!ptr_is_owned(_res)) return;
19203         void* _res_ptr = untag_ptr(_res);
19204         CHECK_ACCESS(_res_ptr);
19205         LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ _res_conv = *(LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ*)(_res_ptr);
19206         FREE(untag_ptr(_res));
19207         COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_free(_res_conv);
19208 }
19209
19210 static inline uint64_t COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_clone_ptr(LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ *NONNULL_PTR arg) {
19211         LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ *ret_copy = MALLOC(sizeof(LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ), "LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ");
19212         *ret_copy = COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_clone(arg);
19213         int64_t ret_ref = tag_ptr(ret_copy, true);
19214         return ret_ref;
19215 }
19216 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19217         LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ* arg_conv = (LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ*)untag_ptr(arg);
19218         int64_t ret_conv = COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_clone_ptr(arg_conv);
19219         return ret_conv;
19220 }
19221
19222 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19223         LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ* orig_conv = (LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ*)untag_ptr(orig);
19224         LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ *ret_copy = MALLOC(sizeof(LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ), "LDKCOption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ");
19225         *ret_copy = COption_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_clone(orig_conv);
19226         int64_t ret_ref = tag_ptr(ret_copy, true);
19227         return ret_ref;
19228 }
19229
19230 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1ok(JNIEnv *env, jclass clz) {
19231         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
19232         *ret_conv = CResult_NoneLightningErrorZ_ok();
19233         return tag_ptr(ret_conv, true);
19234 }
19235
19236 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
19237         LDKLightningError e_conv;
19238         e_conv.inner = untag_ptr(e);
19239         e_conv.is_owned = ptr_is_owned(e);
19240         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
19241         e_conv = LightningError_clone(&e_conv);
19242         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
19243         *ret_conv = CResult_NoneLightningErrorZ_err(e_conv);
19244         return tag_ptr(ret_conv, true);
19245 }
19246
19247 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19248         LDKCResult_NoneLightningErrorZ* o_conv = (LDKCResult_NoneLightningErrorZ*)untag_ptr(o);
19249         jboolean ret_conv = CResult_NoneLightningErrorZ_is_ok(o_conv);
19250         return ret_conv;
19251 }
19252
19253 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19254         if (!ptr_is_owned(_res)) return;
19255         void* _res_ptr = untag_ptr(_res);
19256         CHECK_ACCESS(_res_ptr);
19257         LDKCResult_NoneLightningErrorZ _res_conv = *(LDKCResult_NoneLightningErrorZ*)(_res_ptr);
19258         FREE(untag_ptr(_res));
19259         CResult_NoneLightningErrorZ_free(_res_conv);
19260 }
19261
19262 static inline uint64_t CResult_NoneLightningErrorZ_clone_ptr(LDKCResult_NoneLightningErrorZ *NONNULL_PTR arg) {
19263         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
19264         *ret_conv = CResult_NoneLightningErrorZ_clone(arg);
19265         return tag_ptr(ret_conv, true);
19266 }
19267 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19268         LDKCResult_NoneLightningErrorZ* arg_conv = (LDKCResult_NoneLightningErrorZ*)untag_ptr(arg);
19269         int64_t ret_conv = CResult_NoneLightningErrorZ_clone_ptr(arg_conv);
19270         return ret_conv;
19271 }
19272
19273 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19274         LDKCResult_NoneLightningErrorZ* orig_conv = (LDKCResult_NoneLightningErrorZ*)untag_ptr(orig);
19275         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
19276         *ret_conv = CResult_NoneLightningErrorZ_clone(orig_conv);
19277         return tag_ptr(ret_conv, true);
19278 }
19279
19280 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateInfoDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
19281         LDKChannelUpdateInfo o_conv;
19282         o_conv.inner = untag_ptr(o);
19283         o_conv.is_owned = ptr_is_owned(o);
19284         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19285         o_conv = ChannelUpdateInfo_clone(&o_conv);
19286         LDKCResult_ChannelUpdateInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateInfoDecodeErrorZ), "LDKCResult_ChannelUpdateInfoDecodeErrorZ");
19287         *ret_conv = CResult_ChannelUpdateInfoDecodeErrorZ_ok(o_conv);
19288         return tag_ptr(ret_conv, true);
19289 }
19290
19291 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateInfoDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
19292         void* e_ptr = untag_ptr(e);
19293         CHECK_ACCESS(e_ptr);
19294         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
19295         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
19296         LDKCResult_ChannelUpdateInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateInfoDecodeErrorZ), "LDKCResult_ChannelUpdateInfoDecodeErrorZ");
19297         *ret_conv = CResult_ChannelUpdateInfoDecodeErrorZ_err(e_conv);
19298         return tag_ptr(ret_conv, true);
19299 }
19300
19301 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateInfoDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19302         LDKCResult_ChannelUpdateInfoDecodeErrorZ* o_conv = (LDKCResult_ChannelUpdateInfoDecodeErrorZ*)untag_ptr(o);
19303         jboolean ret_conv = CResult_ChannelUpdateInfoDecodeErrorZ_is_ok(o_conv);
19304         return ret_conv;
19305 }
19306
19307 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateInfoDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19308         if (!ptr_is_owned(_res)) return;
19309         void* _res_ptr = untag_ptr(_res);
19310         CHECK_ACCESS(_res_ptr);
19311         LDKCResult_ChannelUpdateInfoDecodeErrorZ _res_conv = *(LDKCResult_ChannelUpdateInfoDecodeErrorZ*)(_res_ptr);
19312         FREE(untag_ptr(_res));
19313         CResult_ChannelUpdateInfoDecodeErrorZ_free(_res_conv);
19314 }
19315
19316 static inline uint64_t CResult_ChannelUpdateInfoDecodeErrorZ_clone_ptr(LDKCResult_ChannelUpdateInfoDecodeErrorZ *NONNULL_PTR arg) {
19317         LDKCResult_ChannelUpdateInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateInfoDecodeErrorZ), "LDKCResult_ChannelUpdateInfoDecodeErrorZ");
19318         *ret_conv = CResult_ChannelUpdateInfoDecodeErrorZ_clone(arg);
19319         return tag_ptr(ret_conv, true);
19320 }
19321 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateInfoDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19322         LDKCResult_ChannelUpdateInfoDecodeErrorZ* arg_conv = (LDKCResult_ChannelUpdateInfoDecodeErrorZ*)untag_ptr(arg);
19323         int64_t ret_conv = CResult_ChannelUpdateInfoDecodeErrorZ_clone_ptr(arg_conv);
19324         return ret_conv;
19325 }
19326
19327 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateInfoDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19328         LDKCResult_ChannelUpdateInfoDecodeErrorZ* orig_conv = (LDKCResult_ChannelUpdateInfoDecodeErrorZ*)untag_ptr(orig);
19329         LDKCResult_ChannelUpdateInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateInfoDecodeErrorZ), "LDKCResult_ChannelUpdateInfoDecodeErrorZ");
19330         *ret_conv = CResult_ChannelUpdateInfoDecodeErrorZ_clone(orig_conv);
19331         return tag_ptr(ret_conv, true);
19332 }
19333
19334 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
19335         LDKChannelInfo o_conv;
19336         o_conv.inner = untag_ptr(o);
19337         o_conv.is_owned = ptr_is_owned(o);
19338         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19339         o_conv = ChannelInfo_clone(&o_conv);
19340         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
19341         *ret_conv = CResult_ChannelInfoDecodeErrorZ_ok(o_conv);
19342         return tag_ptr(ret_conv, true);
19343 }
19344
19345 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
19346         void* e_ptr = untag_ptr(e);
19347         CHECK_ACCESS(e_ptr);
19348         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
19349         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
19350         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
19351         *ret_conv = CResult_ChannelInfoDecodeErrorZ_err(e_conv);
19352         return tag_ptr(ret_conv, true);
19353 }
19354
19355 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19356         LDKCResult_ChannelInfoDecodeErrorZ* o_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)untag_ptr(o);
19357         jboolean ret_conv = CResult_ChannelInfoDecodeErrorZ_is_ok(o_conv);
19358         return ret_conv;
19359 }
19360
19361 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19362         if (!ptr_is_owned(_res)) return;
19363         void* _res_ptr = untag_ptr(_res);
19364         CHECK_ACCESS(_res_ptr);
19365         LDKCResult_ChannelInfoDecodeErrorZ _res_conv = *(LDKCResult_ChannelInfoDecodeErrorZ*)(_res_ptr);
19366         FREE(untag_ptr(_res));
19367         CResult_ChannelInfoDecodeErrorZ_free(_res_conv);
19368 }
19369
19370 static inline uint64_t CResult_ChannelInfoDecodeErrorZ_clone_ptr(LDKCResult_ChannelInfoDecodeErrorZ *NONNULL_PTR arg) {
19371         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
19372         *ret_conv = CResult_ChannelInfoDecodeErrorZ_clone(arg);
19373         return tag_ptr(ret_conv, true);
19374 }
19375 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19376         LDKCResult_ChannelInfoDecodeErrorZ* arg_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)untag_ptr(arg);
19377         int64_t ret_conv = CResult_ChannelInfoDecodeErrorZ_clone_ptr(arg_conv);
19378         return ret_conv;
19379 }
19380
19381 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19382         LDKCResult_ChannelInfoDecodeErrorZ* orig_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)untag_ptr(orig);
19383         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
19384         *ret_conv = CResult_ChannelInfoDecodeErrorZ_clone(orig_conv);
19385         return tag_ptr(ret_conv, true);
19386 }
19387
19388 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
19389         LDKRoutingFees o_conv;
19390         o_conv.inner = untag_ptr(o);
19391         o_conv.is_owned = ptr_is_owned(o);
19392         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19393         o_conv = RoutingFees_clone(&o_conv);
19394         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
19395         *ret_conv = CResult_RoutingFeesDecodeErrorZ_ok(o_conv);
19396         return tag_ptr(ret_conv, true);
19397 }
19398
19399 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
19400         void* e_ptr = untag_ptr(e);
19401         CHECK_ACCESS(e_ptr);
19402         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
19403         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
19404         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
19405         *ret_conv = CResult_RoutingFeesDecodeErrorZ_err(e_conv);
19406         return tag_ptr(ret_conv, true);
19407 }
19408
19409 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19410         LDKCResult_RoutingFeesDecodeErrorZ* o_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)untag_ptr(o);
19411         jboolean ret_conv = CResult_RoutingFeesDecodeErrorZ_is_ok(o_conv);
19412         return ret_conv;
19413 }
19414
19415 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19416         if (!ptr_is_owned(_res)) return;
19417         void* _res_ptr = untag_ptr(_res);
19418         CHECK_ACCESS(_res_ptr);
19419         LDKCResult_RoutingFeesDecodeErrorZ _res_conv = *(LDKCResult_RoutingFeesDecodeErrorZ*)(_res_ptr);
19420         FREE(untag_ptr(_res));
19421         CResult_RoutingFeesDecodeErrorZ_free(_res_conv);
19422 }
19423
19424 static inline uint64_t CResult_RoutingFeesDecodeErrorZ_clone_ptr(LDKCResult_RoutingFeesDecodeErrorZ *NONNULL_PTR arg) {
19425         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
19426         *ret_conv = CResult_RoutingFeesDecodeErrorZ_clone(arg);
19427         return tag_ptr(ret_conv, true);
19428 }
19429 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19430         LDKCResult_RoutingFeesDecodeErrorZ* arg_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)untag_ptr(arg);
19431         int64_t ret_conv = CResult_RoutingFeesDecodeErrorZ_clone_ptr(arg_conv);
19432         return ret_conv;
19433 }
19434
19435 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19436         LDKCResult_RoutingFeesDecodeErrorZ* orig_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)untag_ptr(orig);
19437         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
19438         *ret_conv = CResult_RoutingFeesDecodeErrorZ_clone(orig_conv);
19439         return tag_ptr(ret_conv, true);
19440 }
19441
19442 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1NetAddressZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
19443         LDKCVec_NetAddressZ _res_constr;
19444         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
19445         if (_res_constr.datalen > 0)
19446                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
19447         else
19448                 _res_constr.data = NULL;
19449         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
19450         for (size_t m = 0; m < _res_constr.datalen; m++) {
19451                 int64_t _res_conv_12 = _res_vals[m];
19452                 void* _res_conv_12_ptr = untag_ptr(_res_conv_12);
19453                 CHECK_ACCESS(_res_conv_12_ptr);
19454                 LDKNetAddress _res_conv_12_conv = *(LDKNetAddress*)(_res_conv_12_ptr);
19455                 FREE(untag_ptr(_res_conv_12));
19456                 _res_constr.data[m] = _res_conv_12_conv;
19457         }
19458         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
19459         CVec_NetAddressZ_free(_res_constr);
19460 }
19461
19462 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
19463         LDKNodeAnnouncementInfo o_conv;
19464         o_conv.inner = untag_ptr(o);
19465         o_conv.is_owned = ptr_is_owned(o);
19466         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19467         o_conv = NodeAnnouncementInfo_clone(&o_conv);
19468         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
19469         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_ok(o_conv);
19470         return tag_ptr(ret_conv, true);
19471 }
19472
19473 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
19474         void* e_ptr = untag_ptr(e);
19475         CHECK_ACCESS(e_ptr);
19476         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
19477         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
19478         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
19479         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_err(e_conv);
19480         return tag_ptr(ret_conv, true);
19481 }
19482
19483 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19484         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* o_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)untag_ptr(o);
19485         jboolean ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_is_ok(o_conv);
19486         return ret_conv;
19487 }
19488
19489 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19490         if (!ptr_is_owned(_res)) return;
19491         void* _res_ptr = untag_ptr(_res);
19492         CHECK_ACCESS(_res_ptr);
19493         LDKCResult_NodeAnnouncementInfoDecodeErrorZ _res_conv = *(LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(_res_ptr);
19494         FREE(untag_ptr(_res));
19495         CResult_NodeAnnouncementInfoDecodeErrorZ_free(_res_conv);
19496 }
19497
19498 static inline uint64_t CResult_NodeAnnouncementInfoDecodeErrorZ_clone_ptr(LDKCResult_NodeAnnouncementInfoDecodeErrorZ *NONNULL_PTR arg) {
19499         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
19500         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_clone(arg);
19501         return tag_ptr(ret_conv, true);
19502 }
19503 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19504         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* arg_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)untag_ptr(arg);
19505         int64_t ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_clone_ptr(arg_conv);
19506         return ret_conv;
19507 }
19508
19509 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19510         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* orig_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)untag_ptr(orig);
19511         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
19512         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_clone(orig_conv);
19513         return tag_ptr(ret_conv, true);
19514 }
19515
19516 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAliasDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
19517         LDKNodeAlias o_conv;
19518         o_conv.inner = untag_ptr(o);
19519         o_conv.is_owned = ptr_is_owned(o);
19520         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19521         o_conv = NodeAlias_clone(&o_conv);
19522         LDKCResult_NodeAliasDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAliasDecodeErrorZ), "LDKCResult_NodeAliasDecodeErrorZ");
19523         *ret_conv = CResult_NodeAliasDecodeErrorZ_ok(o_conv);
19524         return tag_ptr(ret_conv, true);
19525 }
19526
19527 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAliasDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
19528         void* e_ptr = untag_ptr(e);
19529         CHECK_ACCESS(e_ptr);
19530         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
19531         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
19532         LDKCResult_NodeAliasDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAliasDecodeErrorZ), "LDKCResult_NodeAliasDecodeErrorZ");
19533         *ret_conv = CResult_NodeAliasDecodeErrorZ_err(e_conv);
19534         return tag_ptr(ret_conv, true);
19535 }
19536
19537 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAliasDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19538         LDKCResult_NodeAliasDecodeErrorZ* o_conv = (LDKCResult_NodeAliasDecodeErrorZ*)untag_ptr(o);
19539         jboolean ret_conv = CResult_NodeAliasDecodeErrorZ_is_ok(o_conv);
19540         return ret_conv;
19541 }
19542
19543 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAliasDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19544         if (!ptr_is_owned(_res)) return;
19545         void* _res_ptr = untag_ptr(_res);
19546         CHECK_ACCESS(_res_ptr);
19547         LDKCResult_NodeAliasDecodeErrorZ _res_conv = *(LDKCResult_NodeAliasDecodeErrorZ*)(_res_ptr);
19548         FREE(untag_ptr(_res));
19549         CResult_NodeAliasDecodeErrorZ_free(_res_conv);
19550 }
19551
19552 static inline uint64_t CResult_NodeAliasDecodeErrorZ_clone_ptr(LDKCResult_NodeAliasDecodeErrorZ *NONNULL_PTR arg) {
19553         LDKCResult_NodeAliasDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAliasDecodeErrorZ), "LDKCResult_NodeAliasDecodeErrorZ");
19554         *ret_conv = CResult_NodeAliasDecodeErrorZ_clone(arg);
19555         return tag_ptr(ret_conv, true);
19556 }
19557 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAliasDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19558         LDKCResult_NodeAliasDecodeErrorZ* arg_conv = (LDKCResult_NodeAliasDecodeErrorZ*)untag_ptr(arg);
19559         int64_t ret_conv = CResult_NodeAliasDecodeErrorZ_clone_ptr(arg_conv);
19560         return ret_conv;
19561 }
19562
19563 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAliasDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19564         LDKCResult_NodeAliasDecodeErrorZ* orig_conv = (LDKCResult_NodeAliasDecodeErrorZ*)untag_ptr(orig);
19565         LDKCResult_NodeAliasDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAliasDecodeErrorZ), "LDKCResult_NodeAliasDecodeErrorZ");
19566         *ret_conv = CResult_NodeAliasDecodeErrorZ_clone(orig_conv);
19567         return tag_ptr(ret_conv, true);
19568 }
19569
19570 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
19571         LDKNodeInfo o_conv;
19572         o_conv.inner = untag_ptr(o);
19573         o_conv.is_owned = ptr_is_owned(o);
19574         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19575         o_conv = NodeInfo_clone(&o_conv);
19576         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
19577         *ret_conv = CResult_NodeInfoDecodeErrorZ_ok(o_conv);
19578         return tag_ptr(ret_conv, true);
19579 }
19580
19581 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
19582         void* e_ptr = untag_ptr(e);
19583         CHECK_ACCESS(e_ptr);
19584         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
19585         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
19586         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
19587         *ret_conv = CResult_NodeInfoDecodeErrorZ_err(e_conv);
19588         return tag_ptr(ret_conv, true);
19589 }
19590
19591 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19592         LDKCResult_NodeInfoDecodeErrorZ* o_conv = (LDKCResult_NodeInfoDecodeErrorZ*)untag_ptr(o);
19593         jboolean ret_conv = CResult_NodeInfoDecodeErrorZ_is_ok(o_conv);
19594         return ret_conv;
19595 }
19596
19597 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_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         LDKCResult_NodeInfoDecodeErrorZ _res_conv = *(LDKCResult_NodeInfoDecodeErrorZ*)(_res_ptr);
19602         FREE(untag_ptr(_res));
19603         CResult_NodeInfoDecodeErrorZ_free(_res_conv);
19604 }
19605
19606 static inline uint64_t CResult_NodeInfoDecodeErrorZ_clone_ptr(LDKCResult_NodeInfoDecodeErrorZ *NONNULL_PTR arg) {
19607         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
19608         *ret_conv = CResult_NodeInfoDecodeErrorZ_clone(arg);
19609         return tag_ptr(ret_conv, true);
19610 }
19611 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19612         LDKCResult_NodeInfoDecodeErrorZ* arg_conv = (LDKCResult_NodeInfoDecodeErrorZ*)untag_ptr(arg);
19613         int64_t ret_conv = CResult_NodeInfoDecodeErrorZ_clone_ptr(arg_conv);
19614         return ret_conv;
19615 }
19616
19617 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19618         LDKCResult_NodeInfoDecodeErrorZ* orig_conv = (LDKCResult_NodeInfoDecodeErrorZ*)untag_ptr(orig);
19619         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
19620         *ret_conv = CResult_NodeInfoDecodeErrorZ_clone(orig_conv);
19621         return tag_ptr(ret_conv, true);
19622 }
19623
19624 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
19625         LDKNetworkGraph o_conv;
19626         o_conv.inner = untag_ptr(o);
19627         o_conv.is_owned = ptr_is_owned(o);
19628         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19629         // WARNING: we need a move here but no clone is available for LDKNetworkGraph
19630         
19631         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
19632         *ret_conv = CResult_NetworkGraphDecodeErrorZ_ok(o_conv);
19633         return tag_ptr(ret_conv, true);
19634 }
19635
19636 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
19637         void* e_ptr = untag_ptr(e);
19638         CHECK_ACCESS(e_ptr);
19639         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
19640         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
19641         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
19642         *ret_conv = CResult_NetworkGraphDecodeErrorZ_err(e_conv);
19643         return tag_ptr(ret_conv, true);
19644 }
19645
19646 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19647         LDKCResult_NetworkGraphDecodeErrorZ* o_conv = (LDKCResult_NetworkGraphDecodeErrorZ*)untag_ptr(o);
19648         jboolean ret_conv = CResult_NetworkGraphDecodeErrorZ_is_ok(o_conv);
19649         return ret_conv;
19650 }
19651
19652 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19653         if (!ptr_is_owned(_res)) return;
19654         void* _res_ptr = untag_ptr(_res);
19655         CHECK_ACCESS(_res_ptr);
19656         LDKCResult_NetworkGraphDecodeErrorZ _res_conv = *(LDKCResult_NetworkGraphDecodeErrorZ*)(_res_ptr);
19657         FREE(untag_ptr(_res));
19658         CResult_NetworkGraphDecodeErrorZ_free(_res_conv);
19659 }
19660
19661 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1CVec_1NetAddressZZ_1some(JNIEnv *env, jclass clz, int64_tArray o) {
19662         LDKCVec_NetAddressZ o_constr;
19663         o_constr.datalen = (*env)->GetArrayLength(env, o);
19664         if (o_constr.datalen > 0)
19665                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
19666         else
19667                 o_constr.data = NULL;
19668         int64_t* o_vals = (*env)->GetLongArrayElements (env, o, NULL);
19669         for (size_t m = 0; m < o_constr.datalen; m++) {
19670                 int64_t o_conv_12 = o_vals[m];
19671                 void* o_conv_12_ptr = untag_ptr(o_conv_12);
19672                 CHECK_ACCESS(o_conv_12_ptr);
19673                 LDKNetAddress o_conv_12_conv = *(LDKNetAddress*)(o_conv_12_ptr);
19674                 o_conv_12_conv = NetAddress_clone((LDKNetAddress*)untag_ptr(o_conv_12));
19675                 o_constr.data[m] = o_conv_12_conv;
19676         }
19677         (*env)->ReleaseLongArrayElements(env, o, o_vals, 0);
19678         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
19679         *ret_copy = COption_CVec_NetAddressZZ_some(o_constr);
19680         int64_t ret_ref = tag_ptr(ret_copy, true);
19681         return ret_ref;
19682 }
19683
19684 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1CVec_1NetAddressZZ_1none(JNIEnv *env, jclass clz) {
19685         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
19686         *ret_copy = COption_CVec_NetAddressZZ_none();
19687         int64_t ret_ref = tag_ptr(ret_copy, true);
19688         return ret_ref;
19689 }
19690
19691 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1CVec_1NetAddressZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19692         if (!ptr_is_owned(_res)) return;
19693         void* _res_ptr = untag_ptr(_res);
19694         CHECK_ACCESS(_res_ptr);
19695         LDKCOption_CVec_NetAddressZZ _res_conv = *(LDKCOption_CVec_NetAddressZZ*)(_res_ptr);
19696         FREE(untag_ptr(_res));
19697         COption_CVec_NetAddressZZ_free(_res_conv);
19698 }
19699
19700 static inline uint64_t COption_CVec_NetAddressZZ_clone_ptr(LDKCOption_CVec_NetAddressZZ *NONNULL_PTR arg) {
19701         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
19702         *ret_copy = COption_CVec_NetAddressZZ_clone(arg);
19703         int64_t ret_ref = tag_ptr(ret_copy, true);
19704         return ret_ref;
19705 }
19706 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1CVec_1NetAddressZZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19707         LDKCOption_CVec_NetAddressZZ* arg_conv = (LDKCOption_CVec_NetAddressZZ*)untag_ptr(arg);
19708         int64_t ret_conv = COption_CVec_NetAddressZZ_clone_ptr(arg_conv);
19709         return ret_conv;
19710 }
19711
19712 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1CVec_1NetAddressZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19713         LDKCOption_CVec_NetAddressZZ* orig_conv = (LDKCOption_CVec_NetAddressZZ*)untag_ptr(orig);
19714         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
19715         *ret_copy = COption_CVec_NetAddressZZ_clone(orig_conv);
19716         int64_t ret_ref = tag_ptr(ret_copy, true);
19717         return ret_ref;
19718 }
19719
19720 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
19721         LDKDelayedPaymentOutputDescriptor o_conv;
19722         o_conv.inner = untag_ptr(o);
19723         o_conv.is_owned = ptr_is_owned(o);
19724         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19725         o_conv = DelayedPaymentOutputDescriptor_clone(&o_conv);
19726         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
19727         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_ok(o_conv);
19728         return tag_ptr(ret_conv, true);
19729 }
19730
19731 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
19732         void* e_ptr = untag_ptr(e);
19733         CHECK_ACCESS(e_ptr);
19734         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
19735         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
19736         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
19737         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_err(e_conv);
19738         return tag_ptr(ret_conv, true);
19739 }
19740
19741 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19742         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* o_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)untag_ptr(o);
19743         jboolean ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_is_ok(o_conv);
19744         return ret_conv;
19745 }
19746
19747 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19748         if (!ptr_is_owned(_res)) return;
19749         void* _res_ptr = untag_ptr(_res);
19750         CHECK_ACCESS(_res_ptr);
19751         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(_res_ptr);
19752         FREE(untag_ptr(_res));
19753         CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_free(_res_conv);
19754 }
19755
19756 static inline uint64_t CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone_ptr(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR arg) {
19757         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
19758         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone(arg);
19759         return tag_ptr(ret_conv, true);
19760 }
19761 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19762         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* arg_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)untag_ptr(arg);
19763         int64_t ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone_ptr(arg_conv);
19764         return ret_conv;
19765 }
19766
19767 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19768         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* orig_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)untag_ptr(orig);
19769         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
19770         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone(orig_conv);
19771         return tag_ptr(ret_conv, true);
19772 }
19773
19774 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
19775         LDKStaticPaymentOutputDescriptor o_conv;
19776         o_conv.inner = untag_ptr(o);
19777         o_conv.is_owned = ptr_is_owned(o);
19778         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19779         o_conv = StaticPaymentOutputDescriptor_clone(&o_conv);
19780         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
19781         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_ok(o_conv);
19782         return tag_ptr(ret_conv, true);
19783 }
19784
19785 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
19786         void* e_ptr = untag_ptr(e);
19787         CHECK_ACCESS(e_ptr);
19788         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
19789         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
19790         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
19791         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_err(e_conv);
19792         return tag_ptr(ret_conv, true);
19793 }
19794
19795 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19796         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* o_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)untag_ptr(o);
19797         jboolean ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_is_ok(o_conv);
19798         return ret_conv;
19799 }
19800
19801 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19802         if (!ptr_is_owned(_res)) return;
19803         void* _res_ptr = untag_ptr(_res);
19804         CHECK_ACCESS(_res_ptr);
19805         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(_res_ptr);
19806         FREE(untag_ptr(_res));
19807         CResult_StaticPaymentOutputDescriptorDecodeErrorZ_free(_res_conv);
19808 }
19809
19810 static inline uint64_t CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone_ptr(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR arg) {
19811         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
19812         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone(arg);
19813         return tag_ptr(ret_conv, true);
19814 }
19815 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19816         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* arg_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)untag_ptr(arg);
19817         int64_t ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone_ptr(arg_conv);
19818         return ret_conv;
19819 }
19820
19821 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19822         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* orig_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)untag_ptr(orig);
19823         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
19824         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone(orig_conv);
19825         return tag_ptr(ret_conv, true);
19826 }
19827
19828 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
19829         void* o_ptr = untag_ptr(o);
19830         CHECK_ACCESS(o_ptr);
19831         LDKSpendableOutputDescriptor o_conv = *(LDKSpendableOutputDescriptor*)(o_ptr);
19832         o_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)untag_ptr(o));
19833         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
19834         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_ok(o_conv);
19835         return tag_ptr(ret_conv, true);
19836 }
19837
19838 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
19839         void* e_ptr = untag_ptr(e);
19840         CHECK_ACCESS(e_ptr);
19841         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
19842         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
19843         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
19844         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_err(e_conv);
19845         return tag_ptr(ret_conv, true);
19846 }
19847
19848 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19849         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* o_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)untag_ptr(o);
19850         jboolean ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_is_ok(o_conv);
19851         return ret_conv;
19852 }
19853
19854 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19855         if (!ptr_is_owned(_res)) return;
19856         void* _res_ptr = untag_ptr(_res);
19857         CHECK_ACCESS(_res_ptr);
19858         LDKCResult_SpendableOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(_res_ptr);
19859         FREE(untag_ptr(_res));
19860         CResult_SpendableOutputDescriptorDecodeErrorZ_free(_res_conv);
19861 }
19862
19863 static inline uint64_t CResult_SpendableOutputDescriptorDecodeErrorZ_clone_ptr(LDKCResult_SpendableOutputDescriptorDecodeErrorZ *NONNULL_PTR arg) {
19864         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
19865         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_clone(arg);
19866         return tag_ptr(ret_conv, true);
19867 }
19868 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19869         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* arg_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)untag_ptr(arg);
19870         int64_t ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_clone_ptr(arg_conv);
19871         return ret_conv;
19872 }
19873
19874 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19875         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* orig_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)untag_ptr(orig);
19876         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
19877         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_clone(orig_conv);
19878         return tag_ptr(ret_conv, true);
19879 }
19880
19881 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1PaymentPreimageZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
19882         LDKCVec_PaymentPreimageZ _res_constr;
19883         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
19884         if (_res_constr.datalen > 0)
19885                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_PaymentPreimageZ Elements");
19886         else
19887                 _res_constr.data = NULL;
19888         for (size_t i = 0; i < _res_constr.datalen; i++) {
19889                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
19890                 LDKThirtyTwoBytes _res_conv_8_ref;
19891                 CHECK((*env)->GetArrayLength(env, _res_conv_8) == 32);
19892                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, 32, _res_conv_8_ref.data);
19893                 _res_constr.data[i] = _res_conv_8_ref;
19894         }
19895         CVec_PaymentPreimageZ_free(_res_constr);
19896 }
19897
19898 static inline uint64_t C2Tuple_SignatureCVec_SignatureZZ_clone_ptr(LDKC2Tuple_SignatureCVec_SignatureZZ *NONNULL_PTR arg) {
19899         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
19900         *ret_conv = C2Tuple_SignatureCVec_SignatureZZ_clone(arg);
19901         return tag_ptr(ret_conv, true);
19902 }
19903 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19904         LDKC2Tuple_SignatureCVec_SignatureZZ* arg_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)untag_ptr(arg);
19905         int64_t ret_conv = C2Tuple_SignatureCVec_SignatureZZ_clone_ptr(arg_conv);
19906         return ret_conv;
19907 }
19908
19909 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19910         LDKC2Tuple_SignatureCVec_SignatureZZ* orig_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)untag_ptr(orig);
19911         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
19912         *ret_conv = C2Tuple_SignatureCVec_SignatureZZ_clone(orig_conv);
19913         return tag_ptr(ret_conv, true);
19914 }
19915
19916 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1new(JNIEnv *env, jclass clz, int8_tArray a, jobjectArray b) {
19917         LDKSignature a_ref;
19918         CHECK((*env)->GetArrayLength(env, a) == 64);
19919         (*env)->GetByteArrayRegion(env, a, 0, 64, a_ref.compact_form);
19920         LDKCVec_SignatureZ b_constr;
19921         b_constr.datalen = (*env)->GetArrayLength(env, b);
19922         if (b_constr.datalen > 0)
19923                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
19924         else
19925                 b_constr.data = NULL;
19926         for (size_t i = 0; i < b_constr.datalen; i++) {
19927                 int8_tArray b_conv_8 = (*env)->GetObjectArrayElement(env, b, i);
19928                 LDKSignature b_conv_8_ref;
19929                 CHECK((*env)->GetArrayLength(env, b_conv_8) == 64);
19930                 (*env)->GetByteArrayRegion(env, b_conv_8, 0, 64, b_conv_8_ref.compact_form);
19931                 b_constr.data[i] = b_conv_8_ref;
19932         }
19933         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
19934         *ret_conv = C2Tuple_SignatureCVec_SignatureZZ_new(a_ref, b_constr);
19935         return tag_ptr(ret_conv, true);
19936 }
19937
19938 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19939         if (!ptr_is_owned(_res)) return;
19940         void* _res_ptr = untag_ptr(_res);
19941         CHECK_ACCESS(_res_ptr);
19942         LDKC2Tuple_SignatureCVec_SignatureZZ _res_conv = *(LDKC2Tuple_SignatureCVec_SignatureZZ*)(_res_ptr);
19943         FREE(untag_ptr(_res));
19944         C2Tuple_SignatureCVec_SignatureZZ_free(_res_conv);
19945 }
19946
19947 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
19948         void* o_ptr = untag_ptr(o);
19949         CHECK_ACCESS(o_ptr);
19950         LDKC2Tuple_SignatureCVec_SignatureZZ o_conv = *(LDKC2Tuple_SignatureCVec_SignatureZZ*)(o_ptr);
19951         o_conv = C2Tuple_SignatureCVec_SignatureZZ_clone((LDKC2Tuple_SignatureCVec_SignatureZZ*)untag_ptr(o));
19952         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
19953         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_ok(o_conv);
19954         return tag_ptr(ret_conv, true);
19955 }
19956
19957 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1err(JNIEnv *env, jclass clz) {
19958         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
19959         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_err();
19960         return tag_ptr(ret_conv, true);
19961 }
19962
19963 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19964         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* o_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)untag_ptr(o);
19965         jboolean ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_is_ok(o_conv);
19966         return ret_conv;
19967 }
19968
19969 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19970         if (!ptr_is_owned(_res)) return;
19971         void* _res_ptr = untag_ptr(_res);
19972         CHECK_ACCESS(_res_ptr);
19973         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ _res_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(_res_ptr);
19974         FREE(untag_ptr(_res));
19975         CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_free(_res_conv);
19976 }
19977
19978 static inline uint64_t CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone_ptr(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *NONNULL_PTR arg) {
19979         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
19980         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone(arg);
19981         return tag_ptr(ret_conv, true);
19982 }
19983 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19984         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* arg_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)untag_ptr(arg);
19985         int64_t ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone_ptr(arg_conv);
19986         return ret_conv;
19987 }
19988
19989 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19990         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* orig_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)untag_ptr(orig);
19991         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
19992         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone(orig_conv);
19993         return tag_ptr(ret_conv, true);
19994 }
19995
19996 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
19997         LDKSignature o_ref;
19998         CHECK((*env)->GetArrayLength(env, o) == 64);
19999         (*env)->GetByteArrayRegion(env, o, 0, 64, o_ref.compact_form);
20000         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
20001         *ret_conv = CResult_SignatureNoneZ_ok(o_ref);
20002         return tag_ptr(ret_conv, true);
20003 }
20004
20005 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1err(JNIEnv *env, jclass clz) {
20006         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
20007         *ret_conv = CResult_SignatureNoneZ_err();
20008         return tag_ptr(ret_conv, true);
20009 }
20010
20011 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20012         LDKCResult_SignatureNoneZ* o_conv = (LDKCResult_SignatureNoneZ*)untag_ptr(o);
20013         jboolean ret_conv = CResult_SignatureNoneZ_is_ok(o_conv);
20014         return ret_conv;
20015 }
20016
20017 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20018         if (!ptr_is_owned(_res)) return;
20019         void* _res_ptr = untag_ptr(_res);
20020         CHECK_ACCESS(_res_ptr);
20021         LDKCResult_SignatureNoneZ _res_conv = *(LDKCResult_SignatureNoneZ*)(_res_ptr);
20022         FREE(untag_ptr(_res));
20023         CResult_SignatureNoneZ_free(_res_conv);
20024 }
20025
20026 static inline uint64_t CResult_SignatureNoneZ_clone_ptr(LDKCResult_SignatureNoneZ *NONNULL_PTR arg) {
20027         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
20028         *ret_conv = CResult_SignatureNoneZ_clone(arg);
20029         return tag_ptr(ret_conv, true);
20030 }
20031 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20032         LDKCResult_SignatureNoneZ* arg_conv = (LDKCResult_SignatureNoneZ*)untag_ptr(arg);
20033         int64_t ret_conv = CResult_SignatureNoneZ_clone_ptr(arg_conv);
20034         return ret_conv;
20035 }
20036
20037 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20038         LDKCResult_SignatureNoneZ* orig_conv = (LDKCResult_SignatureNoneZ*)untag_ptr(orig);
20039         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
20040         *ret_conv = CResult_SignatureNoneZ_clone(orig_conv);
20041         return tag_ptr(ret_conv, true);
20042 }
20043
20044 static inline uint64_t C2Tuple_SignatureSignatureZ_clone_ptr(LDKC2Tuple_SignatureSignatureZ *NONNULL_PTR arg) {
20045         LDKC2Tuple_SignatureSignatureZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureSignatureZ), "LDKC2Tuple_SignatureSignatureZ");
20046         *ret_conv = C2Tuple_SignatureSignatureZ_clone(arg);
20047         return tag_ptr(ret_conv, true);
20048 }
20049 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureSignatureZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20050         LDKC2Tuple_SignatureSignatureZ* arg_conv = (LDKC2Tuple_SignatureSignatureZ*)untag_ptr(arg);
20051         int64_t ret_conv = C2Tuple_SignatureSignatureZ_clone_ptr(arg_conv);
20052         return ret_conv;
20053 }
20054
20055 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureSignatureZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20056         LDKC2Tuple_SignatureSignatureZ* orig_conv = (LDKC2Tuple_SignatureSignatureZ*)untag_ptr(orig);
20057         LDKC2Tuple_SignatureSignatureZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureSignatureZ), "LDKC2Tuple_SignatureSignatureZ");
20058         *ret_conv = C2Tuple_SignatureSignatureZ_clone(orig_conv);
20059         return tag_ptr(ret_conv, true);
20060 }
20061
20062 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureSignatureZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int8_tArray b) {
20063         LDKSignature a_ref;
20064         CHECK((*env)->GetArrayLength(env, a) == 64);
20065         (*env)->GetByteArrayRegion(env, a, 0, 64, a_ref.compact_form);
20066         LDKSignature b_ref;
20067         CHECK((*env)->GetArrayLength(env, b) == 64);
20068         (*env)->GetByteArrayRegion(env, b, 0, 64, b_ref.compact_form);
20069         LDKC2Tuple_SignatureSignatureZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureSignatureZ), "LDKC2Tuple_SignatureSignatureZ");
20070         *ret_conv = C2Tuple_SignatureSignatureZ_new(a_ref, b_ref);
20071         return tag_ptr(ret_conv, true);
20072 }
20073
20074 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureSignatureZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20075         if (!ptr_is_owned(_res)) return;
20076         void* _res_ptr = untag_ptr(_res);
20077         CHECK_ACCESS(_res_ptr);
20078         LDKC2Tuple_SignatureSignatureZ _res_conv = *(LDKC2Tuple_SignatureSignatureZ*)(_res_ptr);
20079         FREE(untag_ptr(_res));
20080         C2Tuple_SignatureSignatureZ_free(_res_conv);
20081 }
20082
20083 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureSignatureZNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
20084         void* o_ptr = untag_ptr(o);
20085         CHECK_ACCESS(o_ptr);
20086         LDKC2Tuple_SignatureSignatureZ o_conv = *(LDKC2Tuple_SignatureSignatureZ*)(o_ptr);
20087         o_conv = C2Tuple_SignatureSignatureZ_clone((LDKC2Tuple_SignatureSignatureZ*)untag_ptr(o));
20088         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureSignatureZNoneZ), "LDKCResult_C2Tuple_SignatureSignatureZNoneZ");
20089         *ret_conv = CResult_C2Tuple_SignatureSignatureZNoneZ_ok(o_conv);
20090         return tag_ptr(ret_conv, true);
20091 }
20092
20093 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureSignatureZNoneZ_1err(JNIEnv *env, jclass clz) {
20094         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureSignatureZNoneZ), "LDKCResult_C2Tuple_SignatureSignatureZNoneZ");
20095         *ret_conv = CResult_C2Tuple_SignatureSignatureZNoneZ_err();
20096         return tag_ptr(ret_conv, true);
20097 }
20098
20099 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureSignatureZNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20100         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* o_conv = (LDKCResult_C2Tuple_SignatureSignatureZNoneZ*)untag_ptr(o);
20101         jboolean ret_conv = CResult_C2Tuple_SignatureSignatureZNoneZ_is_ok(o_conv);
20102         return ret_conv;
20103 }
20104
20105 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureSignatureZNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20106         if (!ptr_is_owned(_res)) return;
20107         void* _res_ptr = untag_ptr(_res);
20108         CHECK_ACCESS(_res_ptr);
20109         LDKCResult_C2Tuple_SignatureSignatureZNoneZ _res_conv = *(LDKCResult_C2Tuple_SignatureSignatureZNoneZ*)(_res_ptr);
20110         FREE(untag_ptr(_res));
20111         CResult_C2Tuple_SignatureSignatureZNoneZ_free(_res_conv);
20112 }
20113
20114 static inline uint64_t CResult_C2Tuple_SignatureSignatureZNoneZ_clone_ptr(LDKCResult_C2Tuple_SignatureSignatureZNoneZ *NONNULL_PTR arg) {
20115         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureSignatureZNoneZ), "LDKCResult_C2Tuple_SignatureSignatureZNoneZ");
20116         *ret_conv = CResult_C2Tuple_SignatureSignatureZNoneZ_clone(arg);
20117         return tag_ptr(ret_conv, true);
20118 }
20119 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureSignatureZNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20120         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* arg_conv = (LDKCResult_C2Tuple_SignatureSignatureZNoneZ*)untag_ptr(arg);
20121         int64_t ret_conv = CResult_C2Tuple_SignatureSignatureZNoneZ_clone_ptr(arg_conv);
20122         return ret_conv;
20123 }
20124
20125 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureSignatureZNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20126         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* orig_conv = (LDKCResult_C2Tuple_SignatureSignatureZNoneZ*)untag_ptr(orig);
20127         LDKCResult_C2Tuple_SignatureSignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureSignatureZNoneZ), "LDKCResult_C2Tuple_SignatureSignatureZNoneZ");
20128         *ret_conv = CResult_C2Tuple_SignatureSignatureZNoneZ_clone(orig_conv);
20129         return tag_ptr(ret_conv, true);
20130 }
20131
20132 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyNoneZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
20133         LDKSecretKey o_ref;
20134         CHECK((*env)->GetArrayLength(env, o) == 32);
20135         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.bytes);
20136         LDKCResult_SecretKeyNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyNoneZ), "LDKCResult_SecretKeyNoneZ");
20137         *ret_conv = CResult_SecretKeyNoneZ_ok(o_ref);
20138         return tag_ptr(ret_conv, true);
20139 }
20140
20141 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyNoneZ_1err(JNIEnv *env, jclass clz) {
20142         LDKCResult_SecretKeyNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyNoneZ), "LDKCResult_SecretKeyNoneZ");
20143         *ret_conv = CResult_SecretKeyNoneZ_err();
20144         return tag_ptr(ret_conv, true);
20145 }
20146
20147 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20148         LDKCResult_SecretKeyNoneZ* o_conv = (LDKCResult_SecretKeyNoneZ*)untag_ptr(o);
20149         jboolean ret_conv = CResult_SecretKeyNoneZ_is_ok(o_conv);
20150         return ret_conv;
20151 }
20152
20153 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20154         if (!ptr_is_owned(_res)) return;
20155         void* _res_ptr = untag_ptr(_res);
20156         CHECK_ACCESS(_res_ptr);
20157         LDKCResult_SecretKeyNoneZ _res_conv = *(LDKCResult_SecretKeyNoneZ*)(_res_ptr);
20158         FREE(untag_ptr(_res));
20159         CResult_SecretKeyNoneZ_free(_res_conv);
20160 }
20161
20162 static inline uint64_t CResult_SecretKeyNoneZ_clone_ptr(LDKCResult_SecretKeyNoneZ *NONNULL_PTR arg) {
20163         LDKCResult_SecretKeyNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyNoneZ), "LDKCResult_SecretKeyNoneZ");
20164         *ret_conv = CResult_SecretKeyNoneZ_clone(arg);
20165         return tag_ptr(ret_conv, true);
20166 }
20167 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20168         LDKCResult_SecretKeyNoneZ* arg_conv = (LDKCResult_SecretKeyNoneZ*)untag_ptr(arg);
20169         int64_t ret_conv = CResult_SecretKeyNoneZ_clone_ptr(arg_conv);
20170         return ret_conv;
20171 }
20172
20173 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20174         LDKCResult_SecretKeyNoneZ* orig_conv = (LDKCResult_SecretKeyNoneZ*)untag_ptr(orig);
20175         LDKCResult_SecretKeyNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyNoneZ), "LDKCResult_SecretKeyNoneZ");
20176         *ret_conv = CResult_SecretKeyNoneZ_clone(orig_conv);
20177         return tag_ptr(ret_conv, true);
20178 }
20179
20180 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyNoneZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
20181         LDKPublicKey o_ref;
20182         CHECK((*env)->GetArrayLength(env, o) == 33);
20183         (*env)->GetByteArrayRegion(env, o, 0, 33, o_ref.compressed_form);
20184         LDKCResult_PublicKeyNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyNoneZ), "LDKCResult_PublicKeyNoneZ");
20185         *ret_conv = CResult_PublicKeyNoneZ_ok(o_ref);
20186         return tag_ptr(ret_conv, true);
20187 }
20188
20189 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyNoneZ_1err(JNIEnv *env, jclass clz) {
20190         LDKCResult_PublicKeyNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyNoneZ), "LDKCResult_PublicKeyNoneZ");
20191         *ret_conv = CResult_PublicKeyNoneZ_err();
20192         return tag_ptr(ret_conv, true);
20193 }
20194
20195 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20196         LDKCResult_PublicKeyNoneZ* o_conv = (LDKCResult_PublicKeyNoneZ*)untag_ptr(o);
20197         jboolean ret_conv = CResult_PublicKeyNoneZ_is_ok(o_conv);
20198         return ret_conv;
20199 }
20200
20201 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20202         if (!ptr_is_owned(_res)) return;
20203         void* _res_ptr = untag_ptr(_res);
20204         CHECK_ACCESS(_res_ptr);
20205         LDKCResult_PublicKeyNoneZ _res_conv = *(LDKCResult_PublicKeyNoneZ*)(_res_ptr);
20206         FREE(untag_ptr(_res));
20207         CResult_PublicKeyNoneZ_free(_res_conv);
20208 }
20209
20210 static inline uint64_t CResult_PublicKeyNoneZ_clone_ptr(LDKCResult_PublicKeyNoneZ *NONNULL_PTR arg) {
20211         LDKCResult_PublicKeyNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyNoneZ), "LDKCResult_PublicKeyNoneZ");
20212         *ret_conv = CResult_PublicKeyNoneZ_clone(arg);
20213         return tag_ptr(ret_conv, true);
20214 }
20215 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20216         LDKCResult_PublicKeyNoneZ* arg_conv = (LDKCResult_PublicKeyNoneZ*)untag_ptr(arg);
20217         int64_t ret_conv = CResult_PublicKeyNoneZ_clone_ptr(arg_conv);
20218         return ret_conv;
20219 }
20220
20221 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20222         LDKCResult_PublicKeyNoneZ* orig_conv = (LDKCResult_PublicKeyNoneZ*)untag_ptr(orig);
20223         LDKCResult_PublicKeyNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyNoneZ), "LDKCResult_PublicKeyNoneZ");
20224         *ret_conv = CResult_PublicKeyNoneZ_clone(orig_conv);
20225         return tag_ptr(ret_conv, true);
20226 }
20227
20228 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1ScalarZ_1some(JNIEnv *env, jclass clz, int64_t o) {
20229         void* o_ptr = untag_ptr(o);
20230         CHECK_ACCESS(o_ptr);
20231         LDKBigEndianScalar o_conv = *(LDKBigEndianScalar*)(o_ptr);
20232         // WARNING: we may need a move here but no clone is available for LDKBigEndianScalar
20233         LDKCOption_ScalarZ *ret_copy = MALLOC(sizeof(LDKCOption_ScalarZ), "LDKCOption_ScalarZ");
20234         *ret_copy = COption_ScalarZ_some(o_conv);
20235         int64_t ret_ref = tag_ptr(ret_copy, true);
20236         return ret_ref;
20237 }
20238
20239 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1ScalarZ_1none(JNIEnv *env, jclass clz) {
20240         LDKCOption_ScalarZ *ret_copy = MALLOC(sizeof(LDKCOption_ScalarZ), "LDKCOption_ScalarZ");
20241         *ret_copy = COption_ScalarZ_none();
20242         int64_t ret_ref = tag_ptr(ret_copy, true);
20243         return ret_ref;
20244 }
20245
20246 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1ScalarZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20247         if (!ptr_is_owned(_res)) return;
20248         void* _res_ptr = untag_ptr(_res);
20249         CHECK_ACCESS(_res_ptr);
20250         LDKCOption_ScalarZ _res_conv = *(LDKCOption_ScalarZ*)(_res_ptr);
20251         FREE(untag_ptr(_res));
20252         COption_ScalarZ_free(_res_conv);
20253 }
20254
20255 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SharedSecretNoneZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
20256         LDKThirtyTwoBytes o_ref;
20257         CHECK((*env)->GetArrayLength(env, o) == 32);
20258         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.data);
20259         LDKCResult_SharedSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SharedSecretNoneZ), "LDKCResult_SharedSecretNoneZ");
20260         *ret_conv = CResult_SharedSecretNoneZ_ok(o_ref);
20261         return tag_ptr(ret_conv, true);
20262 }
20263
20264 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SharedSecretNoneZ_1err(JNIEnv *env, jclass clz) {
20265         LDKCResult_SharedSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SharedSecretNoneZ), "LDKCResult_SharedSecretNoneZ");
20266         *ret_conv = CResult_SharedSecretNoneZ_err();
20267         return tag_ptr(ret_conv, true);
20268 }
20269
20270 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1SharedSecretNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20271         LDKCResult_SharedSecretNoneZ* o_conv = (LDKCResult_SharedSecretNoneZ*)untag_ptr(o);
20272         jboolean ret_conv = CResult_SharedSecretNoneZ_is_ok(o_conv);
20273         return ret_conv;
20274 }
20275
20276 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SharedSecretNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20277         if (!ptr_is_owned(_res)) return;
20278         void* _res_ptr = untag_ptr(_res);
20279         CHECK_ACCESS(_res_ptr);
20280         LDKCResult_SharedSecretNoneZ _res_conv = *(LDKCResult_SharedSecretNoneZ*)(_res_ptr);
20281         FREE(untag_ptr(_res));
20282         CResult_SharedSecretNoneZ_free(_res_conv);
20283 }
20284
20285 static inline uint64_t CResult_SharedSecretNoneZ_clone_ptr(LDKCResult_SharedSecretNoneZ *NONNULL_PTR arg) {
20286         LDKCResult_SharedSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SharedSecretNoneZ), "LDKCResult_SharedSecretNoneZ");
20287         *ret_conv = CResult_SharedSecretNoneZ_clone(arg);
20288         return tag_ptr(ret_conv, true);
20289 }
20290 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SharedSecretNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20291         LDKCResult_SharedSecretNoneZ* arg_conv = (LDKCResult_SharedSecretNoneZ*)untag_ptr(arg);
20292         int64_t ret_conv = CResult_SharedSecretNoneZ_clone_ptr(arg_conv);
20293         return ret_conv;
20294 }
20295
20296 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SharedSecretNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20297         LDKCResult_SharedSecretNoneZ* orig_conv = (LDKCResult_SharedSecretNoneZ*)untag_ptr(orig);
20298         LDKCResult_SharedSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SharedSecretNoneZ), "LDKCResult_SharedSecretNoneZ");
20299         *ret_conv = CResult_SharedSecretNoneZ_clone(orig_conv);
20300         return tag_ptr(ret_conv, true);
20301 }
20302
20303 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
20304         void* o_ptr = untag_ptr(o);
20305         CHECK_ACCESS(o_ptr);
20306         LDKSign o_conv = *(LDKSign*)(o_ptr);
20307         if (o_conv.free == LDKSign_JCalls_free) {
20308                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
20309                 LDKSign_JCalls_cloned(&o_conv);
20310         }
20311         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
20312         *ret_conv = CResult_SignDecodeErrorZ_ok(o_conv);
20313         return tag_ptr(ret_conv, true);
20314 }
20315
20316 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20317         void* e_ptr = untag_ptr(e);
20318         CHECK_ACCESS(e_ptr);
20319         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
20320         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
20321         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
20322         *ret_conv = CResult_SignDecodeErrorZ_err(e_conv);
20323         return tag_ptr(ret_conv, true);
20324 }
20325
20326 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20327         LDKCResult_SignDecodeErrorZ* o_conv = (LDKCResult_SignDecodeErrorZ*)untag_ptr(o);
20328         jboolean ret_conv = CResult_SignDecodeErrorZ_is_ok(o_conv);
20329         return ret_conv;
20330 }
20331
20332 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20333         if (!ptr_is_owned(_res)) return;
20334         void* _res_ptr = untag_ptr(_res);
20335         CHECK_ACCESS(_res_ptr);
20336         LDKCResult_SignDecodeErrorZ _res_conv = *(LDKCResult_SignDecodeErrorZ*)(_res_ptr);
20337         FREE(untag_ptr(_res));
20338         CResult_SignDecodeErrorZ_free(_res_conv);
20339 }
20340
20341 static inline uint64_t CResult_SignDecodeErrorZ_clone_ptr(LDKCResult_SignDecodeErrorZ *NONNULL_PTR arg) {
20342         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
20343         *ret_conv = CResult_SignDecodeErrorZ_clone(arg);
20344         return tag_ptr(ret_conv, true);
20345 }
20346 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20347         LDKCResult_SignDecodeErrorZ* arg_conv = (LDKCResult_SignDecodeErrorZ*)untag_ptr(arg);
20348         int64_t ret_conv = CResult_SignDecodeErrorZ_clone_ptr(arg_conv);
20349         return ret_conv;
20350 }
20351
20352 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20353         LDKCResult_SignDecodeErrorZ* orig_conv = (LDKCResult_SignDecodeErrorZ*)untag_ptr(orig);
20354         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
20355         *ret_conv = CResult_SignDecodeErrorZ_clone(orig_conv);
20356         return tag_ptr(ret_conv, true);
20357 }
20358
20359 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1U5Z_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
20360         LDKCVec_U5Z _res_constr;
20361         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
20362         if (_res_constr.datalen > 0)
20363                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKU5), "LDKCVec_U5Z Elements");
20364         else
20365                 _res_constr.data = NULL;
20366         int8_t* _res_vals = (*env)->GetByteArrayElements (env, _res, NULL);
20367         for (size_t h = 0; h < _res_constr.datalen; h++) {
20368                 int8_t _res_conv_7 = _res_vals[h];
20369                 
20370                 _res_constr.data[h] = (LDKU5){ ._0 = _res_conv_7 };
20371         }
20372         (*env)->ReleaseByteArrayElements(env, _res, _res_vals, 0);
20373         CVec_U5Z_free(_res_constr);
20374 }
20375
20376 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
20377         LDKRecoverableSignature o_ref;
20378         CHECK((*env)->GetArrayLength(env, o) == 68);
20379         (*env)->GetByteArrayRegion(env, o, 0, 68, o_ref.serialized_form);
20380         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
20381         *ret_conv = CResult_RecoverableSignatureNoneZ_ok(o_ref);
20382         return tag_ptr(ret_conv, true);
20383 }
20384
20385 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1err(JNIEnv *env, jclass clz) {
20386         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
20387         *ret_conv = CResult_RecoverableSignatureNoneZ_err();
20388         return tag_ptr(ret_conv, true);
20389 }
20390
20391 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20392         LDKCResult_RecoverableSignatureNoneZ* o_conv = (LDKCResult_RecoverableSignatureNoneZ*)untag_ptr(o);
20393         jboolean ret_conv = CResult_RecoverableSignatureNoneZ_is_ok(o_conv);
20394         return ret_conv;
20395 }
20396
20397 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20398         if (!ptr_is_owned(_res)) return;
20399         void* _res_ptr = untag_ptr(_res);
20400         CHECK_ACCESS(_res_ptr);
20401         LDKCResult_RecoverableSignatureNoneZ _res_conv = *(LDKCResult_RecoverableSignatureNoneZ*)(_res_ptr);
20402         FREE(untag_ptr(_res));
20403         CResult_RecoverableSignatureNoneZ_free(_res_conv);
20404 }
20405
20406 static inline uint64_t CResult_RecoverableSignatureNoneZ_clone_ptr(LDKCResult_RecoverableSignatureNoneZ *NONNULL_PTR arg) {
20407         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
20408         *ret_conv = CResult_RecoverableSignatureNoneZ_clone(arg);
20409         return tag_ptr(ret_conv, true);
20410 }
20411 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20412         LDKCResult_RecoverableSignatureNoneZ* arg_conv = (LDKCResult_RecoverableSignatureNoneZ*)untag_ptr(arg);
20413         int64_t ret_conv = CResult_RecoverableSignatureNoneZ_clone_ptr(arg_conv);
20414         return ret_conv;
20415 }
20416
20417 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20418         LDKCResult_RecoverableSignatureNoneZ* orig_conv = (LDKCResult_RecoverableSignatureNoneZ*)untag_ptr(orig);
20419         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
20420         *ret_conv = CResult_RecoverableSignatureNoneZ_clone(orig_conv);
20421         return tag_ptr(ret_conv, true);
20422 }
20423
20424 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1u8Z_1free(JNIEnv *env, jclass clz, int8_tArray _res) {
20425         LDKCVec_u8Z _res_ref;
20426         _res_ref.datalen = (*env)->GetArrayLength(env, _res);
20427         _res_ref.data = MALLOC(_res_ref.datalen, "LDKCVec_u8Z Bytes");
20428         (*env)->GetByteArrayRegion(env, _res, 0, _res_ref.datalen, _res_ref.data);
20429         CVec_u8Z_free(_res_ref);
20430 }
20431
20432 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1CVec_1u8ZZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
20433         LDKCVec_CVec_u8ZZ _res_constr;
20434         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
20435         if (_res_constr.datalen > 0)
20436                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCVec_u8Z), "LDKCVec_CVec_u8ZZ Elements");
20437         else
20438                 _res_constr.data = NULL;
20439         for (size_t i = 0; i < _res_constr.datalen; i++) {
20440                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
20441                 LDKCVec_u8Z _res_conv_8_ref;
20442                 _res_conv_8_ref.datalen = (*env)->GetArrayLength(env, _res_conv_8);
20443                 _res_conv_8_ref.data = MALLOC(_res_conv_8_ref.datalen, "LDKCVec_u8Z Bytes");
20444                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, _res_conv_8_ref.datalen, _res_conv_8_ref.data);
20445                 _res_constr.data[i] = _res_conv_8_ref;
20446         }
20447         CVec_CVec_u8ZZ_free(_res_constr);
20448 }
20449
20450 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1ok(JNIEnv *env, jclass clz, jobjectArray o) {
20451         LDKCVec_CVec_u8ZZ o_constr;
20452         o_constr.datalen = (*env)->GetArrayLength(env, o);
20453         if (o_constr.datalen > 0)
20454                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKCVec_u8Z), "LDKCVec_CVec_u8ZZ Elements");
20455         else
20456                 o_constr.data = NULL;
20457         for (size_t i = 0; i < o_constr.datalen; i++) {
20458                 int8_tArray o_conv_8 = (*env)->GetObjectArrayElement(env, o, i);
20459                 LDKCVec_u8Z o_conv_8_ref;
20460                 o_conv_8_ref.datalen = (*env)->GetArrayLength(env, o_conv_8);
20461                 o_conv_8_ref.data = MALLOC(o_conv_8_ref.datalen, "LDKCVec_u8Z Bytes");
20462                 (*env)->GetByteArrayRegion(env, o_conv_8, 0, o_conv_8_ref.datalen, o_conv_8_ref.data);
20463                 o_constr.data[i] = o_conv_8_ref;
20464         }
20465         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
20466         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_ok(o_constr);
20467         return tag_ptr(ret_conv, true);
20468 }
20469
20470 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1err(JNIEnv *env, jclass clz) {
20471         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
20472         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_err();
20473         return tag_ptr(ret_conv, true);
20474 }
20475
20476 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20477         LDKCResult_CVec_CVec_u8ZZNoneZ* o_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)untag_ptr(o);
20478         jboolean ret_conv = CResult_CVec_CVec_u8ZZNoneZ_is_ok(o_conv);
20479         return ret_conv;
20480 }
20481
20482 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20483         if (!ptr_is_owned(_res)) return;
20484         void* _res_ptr = untag_ptr(_res);
20485         CHECK_ACCESS(_res_ptr);
20486         LDKCResult_CVec_CVec_u8ZZNoneZ _res_conv = *(LDKCResult_CVec_CVec_u8ZZNoneZ*)(_res_ptr);
20487         FREE(untag_ptr(_res));
20488         CResult_CVec_CVec_u8ZZNoneZ_free(_res_conv);
20489 }
20490
20491 static inline uint64_t CResult_CVec_CVec_u8ZZNoneZ_clone_ptr(LDKCResult_CVec_CVec_u8ZZNoneZ *NONNULL_PTR arg) {
20492         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
20493         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_clone(arg);
20494         return tag_ptr(ret_conv, true);
20495 }
20496 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20497         LDKCResult_CVec_CVec_u8ZZNoneZ* arg_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)untag_ptr(arg);
20498         int64_t ret_conv = CResult_CVec_CVec_u8ZZNoneZ_clone_ptr(arg_conv);
20499         return ret_conv;
20500 }
20501
20502 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20503         LDKCResult_CVec_CVec_u8ZZNoneZ* orig_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)untag_ptr(orig);
20504         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
20505         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_clone(orig_conv);
20506         return tag_ptr(ret_conv, true);
20507 }
20508
20509 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
20510         LDKInMemorySigner o_conv;
20511         o_conv.inner = untag_ptr(o);
20512         o_conv.is_owned = ptr_is_owned(o);
20513         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
20514         o_conv = InMemorySigner_clone(&o_conv);
20515         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
20516         *ret_conv = CResult_InMemorySignerDecodeErrorZ_ok(o_conv);
20517         return tag_ptr(ret_conv, true);
20518 }
20519
20520 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20521         void* e_ptr = untag_ptr(e);
20522         CHECK_ACCESS(e_ptr);
20523         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
20524         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
20525         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
20526         *ret_conv = CResult_InMemorySignerDecodeErrorZ_err(e_conv);
20527         return tag_ptr(ret_conv, true);
20528 }
20529
20530 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20531         LDKCResult_InMemorySignerDecodeErrorZ* o_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)untag_ptr(o);
20532         jboolean ret_conv = CResult_InMemorySignerDecodeErrorZ_is_ok(o_conv);
20533         return ret_conv;
20534 }
20535
20536 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20537         if (!ptr_is_owned(_res)) return;
20538         void* _res_ptr = untag_ptr(_res);
20539         CHECK_ACCESS(_res_ptr);
20540         LDKCResult_InMemorySignerDecodeErrorZ _res_conv = *(LDKCResult_InMemorySignerDecodeErrorZ*)(_res_ptr);
20541         FREE(untag_ptr(_res));
20542         CResult_InMemorySignerDecodeErrorZ_free(_res_conv);
20543 }
20544
20545 static inline uint64_t CResult_InMemorySignerDecodeErrorZ_clone_ptr(LDKCResult_InMemorySignerDecodeErrorZ *NONNULL_PTR arg) {
20546         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
20547         *ret_conv = CResult_InMemorySignerDecodeErrorZ_clone(arg);
20548         return tag_ptr(ret_conv, true);
20549 }
20550 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20551         LDKCResult_InMemorySignerDecodeErrorZ* arg_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)untag_ptr(arg);
20552         int64_t ret_conv = CResult_InMemorySignerDecodeErrorZ_clone_ptr(arg_conv);
20553         return ret_conv;
20554 }
20555
20556 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20557         LDKCResult_InMemorySignerDecodeErrorZ* orig_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)untag_ptr(orig);
20558         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
20559         *ret_conv = CResult_InMemorySignerDecodeErrorZ_clone(orig_conv);
20560         return tag_ptr(ret_conv, true);
20561 }
20562
20563 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1TxOutZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
20564         LDKCVec_TxOutZ _res_constr;
20565         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
20566         if (_res_constr.datalen > 0)
20567                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKTxOut), "LDKCVec_TxOutZ Elements");
20568         else
20569                 _res_constr.data = NULL;
20570         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
20571         for (size_t h = 0; h < _res_constr.datalen; h++) {
20572                 int64_t _res_conv_7 = _res_vals[h];
20573                 void* _res_conv_7_ptr = untag_ptr(_res_conv_7);
20574                 CHECK_ACCESS(_res_conv_7_ptr);
20575                 LDKTxOut _res_conv_7_conv = *(LDKTxOut*)(_res_conv_7_ptr);
20576                 FREE(untag_ptr(_res_conv_7));
20577                 _res_constr.data[h] = _res_conv_7_conv;
20578         }
20579         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
20580         CVec_TxOutZ_free(_res_constr);
20581 }
20582
20583 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
20584         LDKTransaction o_ref;
20585         o_ref.datalen = (*env)->GetArrayLength(env, o);
20586         o_ref.data = MALLOC(o_ref.datalen, "LDKTransaction Bytes");
20587         (*env)->GetByteArrayRegion(env, o, 0, o_ref.datalen, o_ref.data);
20588         o_ref.data_is_owned = true;
20589         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
20590         *ret_conv = CResult_TransactionNoneZ_ok(o_ref);
20591         return tag_ptr(ret_conv, true);
20592 }
20593
20594 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1err(JNIEnv *env, jclass clz) {
20595         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
20596         *ret_conv = CResult_TransactionNoneZ_err();
20597         return tag_ptr(ret_conv, true);
20598 }
20599
20600 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20601         LDKCResult_TransactionNoneZ* o_conv = (LDKCResult_TransactionNoneZ*)untag_ptr(o);
20602         jboolean ret_conv = CResult_TransactionNoneZ_is_ok(o_conv);
20603         return ret_conv;
20604 }
20605
20606 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20607         if (!ptr_is_owned(_res)) return;
20608         void* _res_ptr = untag_ptr(_res);
20609         CHECK_ACCESS(_res_ptr);
20610         LDKCResult_TransactionNoneZ _res_conv = *(LDKCResult_TransactionNoneZ*)(_res_ptr);
20611         FREE(untag_ptr(_res));
20612         CResult_TransactionNoneZ_free(_res_conv);
20613 }
20614
20615 static inline uint64_t CResult_TransactionNoneZ_clone_ptr(LDKCResult_TransactionNoneZ *NONNULL_PTR arg) {
20616         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
20617         *ret_conv = CResult_TransactionNoneZ_clone(arg);
20618         return tag_ptr(ret_conv, true);
20619 }
20620 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20621         LDKCResult_TransactionNoneZ* arg_conv = (LDKCResult_TransactionNoneZ*)untag_ptr(arg);
20622         int64_t ret_conv = CResult_TransactionNoneZ_clone_ptr(arg_conv);
20623         return ret_conv;
20624 }
20625
20626 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20627         LDKCResult_TransactionNoneZ* orig_conv = (LDKCResult_TransactionNoneZ*)untag_ptr(orig);
20628         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
20629         *ret_conv = CResult_TransactionNoneZ_clone(orig_conv);
20630         return tag_ptr(ret_conv, true);
20631 }
20632
20633 static inline uint64_t C2Tuple_BlockHashChannelMonitorZ_clone_ptr(LDKC2Tuple_BlockHashChannelMonitorZ *NONNULL_PTR arg) {
20634         LDKC2Tuple_BlockHashChannelMonitorZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
20635         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_clone(arg);
20636         return tag_ptr(ret_conv, true);
20637 }
20638 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20639         LDKC2Tuple_BlockHashChannelMonitorZ* arg_conv = (LDKC2Tuple_BlockHashChannelMonitorZ*)untag_ptr(arg);
20640         int64_t ret_conv = C2Tuple_BlockHashChannelMonitorZ_clone_ptr(arg_conv);
20641         return ret_conv;
20642 }
20643
20644 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20645         LDKC2Tuple_BlockHashChannelMonitorZ* orig_conv = (LDKC2Tuple_BlockHashChannelMonitorZ*)untag_ptr(orig);
20646         LDKC2Tuple_BlockHashChannelMonitorZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
20647         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_clone(orig_conv);
20648         return tag_ptr(ret_conv, true);
20649 }
20650
20651 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_t b) {
20652         LDKThirtyTwoBytes a_ref;
20653         CHECK((*env)->GetArrayLength(env, a) == 32);
20654         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
20655         LDKChannelMonitor b_conv;
20656         b_conv.inner = untag_ptr(b);
20657         b_conv.is_owned = ptr_is_owned(b);
20658         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
20659         b_conv = ChannelMonitor_clone(&b_conv);
20660         LDKC2Tuple_BlockHashChannelMonitorZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
20661         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_new(a_ref, b_conv);
20662         return tag_ptr(ret_conv, true);
20663 }
20664
20665 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20666         if (!ptr_is_owned(_res)) return;
20667         void* _res_ptr = untag_ptr(_res);
20668         CHECK_ACCESS(_res_ptr);
20669         LDKC2Tuple_BlockHashChannelMonitorZ _res_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(_res_ptr);
20670         FREE(untag_ptr(_res));
20671         C2Tuple_BlockHashChannelMonitorZ_free(_res_conv);
20672 }
20673
20674 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1BlockHashChannelMonitorZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
20675         LDKCVec_C2Tuple_BlockHashChannelMonitorZZ _res_constr;
20676         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
20677         if (_res_constr.datalen > 0)
20678                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKCVec_C2Tuple_BlockHashChannelMonitorZZ Elements");
20679         else
20680                 _res_constr.data = NULL;
20681         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
20682         for (size_t j = 0; j < _res_constr.datalen; j++) {
20683                 int64_t _res_conv_35 = _res_vals[j];
20684                 void* _res_conv_35_ptr = untag_ptr(_res_conv_35);
20685                 CHECK_ACCESS(_res_conv_35_ptr);
20686                 LDKC2Tuple_BlockHashChannelMonitorZ _res_conv_35_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(_res_conv_35_ptr);
20687                 FREE(untag_ptr(_res_conv_35));
20688                 _res_constr.data[j] = _res_conv_35_conv;
20689         }
20690         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
20691         CVec_C2Tuple_BlockHashChannelMonitorZZ_free(_res_constr);
20692 }
20693
20694 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1ok(JNIEnv *env, jclass clz, int64_tArray o) {
20695         LDKCVec_C2Tuple_BlockHashChannelMonitorZZ o_constr;
20696         o_constr.datalen = (*env)->GetArrayLength(env, o);
20697         if (o_constr.datalen > 0)
20698                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKCVec_C2Tuple_BlockHashChannelMonitorZZ Elements");
20699         else
20700                 o_constr.data = NULL;
20701         int64_t* o_vals = (*env)->GetLongArrayElements (env, o, NULL);
20702         for (size_t j = 0; j < o_constr.datalen; j++) {
20703                 int64_t o_conv_35 = o_vals[j];
20704                 void* o_conv_35_ptr = untag_ptr(o_conv_35);
20705                 CHECK_ACCESS(o_conv_35_ptr);
20706                 LDKC2Tuple_BlockHashChannelMonitorZ o_conv_35_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(o_conv_35_ptr);
20707                 o_conv_35_conv = C2Tuple_BlockHashChannelMonitorZ_clone((LDKC2Tuple_BlockHashChannelMonitorZ*)untag_ptr(o_conv_35));
20708                 o_constr.data[j] = o_conv_35_conv;
20709         }
20710         (*env)->ReleaseLongArrayElements(env, o, o_vals, 0);
20711         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
20712         *ret_conv = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_ok(o_constr);
20713         return tag_ptr(ret_conv, true);
20714 }
20715
20716 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
20717         LDKIOError e_conv = LDKIOError_from_java(env, e);
20718         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
20719         *ret_conv = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_err(e_conv);
20720         return tag_ptr(ret_conv, true);
20721 }
20722
20723 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20724         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* o_conv = (LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)untag_ptr(o);
20725         jboolean ret_conv = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_is_ok(o_conv);
20726         return ret_conv;
20727 }
20728
20729 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20730         if (!ptr_is_owned(_res)) return;
20731         void* _res_ptr = untag_ptr(_res);
20732         CHECK_ACCESS(_res_ptr);
20733         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ _res_conv = *(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)(_res_ptr);
20734         FREE(untag_ptr(_res));
20735         CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_free(_res_conv);
20736 }
20737
20738 static inline uint64_t CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_clone_ptr(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ *NONNULL_PTR arg) {
20739         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
20740         *ret_conv = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_clone(arg);
20741         return tag_ptr(ret_conv, true);
20742 }
20743 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20744         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* arg_conv = (LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)untag_ptr(arg);
20745         int64_t ret_conv = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_clone_ptr(arg_conv);
20746         return ret_conv;
20747 }
20748
20749 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20750         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* orig_conv = (LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)untag_ptr(orig);
20751         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
20752         *ret_conv = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_clone(orig_conv);
20753         return tag_ptr(ret_conv, true);
20754 }
20755
20756 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u16Z_1some(JNIEnv *env, jclass clz, int16_t o) {
20757         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
20758         *ret_copy = COption_u16Z_some(o);
20759         int64_t ret_ref = tag_ptr(ret_copy, true);
20760         return ret_ref;
20761 }
20762
20763 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u16Z_1none(JNIEnv *env, jclass clz) {
20764         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
20765         *ret_copy = COption_u16Z_none();
20766         int64_t ret_ref = tag_ptr(ret_copy, true);
20767         return ret_ref;
20768 }
20769
20770 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1u16Z_1free(JNIEnv *env, jclass clz, int64_t _res) {
20771         if (!ptr_is_owned(_res)) return;
20772         void* _res_ptr = untag_ptr(_res);
20773         CHECK_ACCESS(_res_ptr);
20774         LDKCOption_u16Z _res_conv = *(LDKCOption_u16Z*)(_res_ptr);
20775         FREE(untag_ptr(_res));
20776         COption_u16Z_free(_res_conv);
20777 }
20778
20779 static inline uint64_t COption_u16Z_clone_ptr(LDKCOption_u16Z *NONNULL_PTR arg) {
20780         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
20781         *ret_copy = COption_u16Z_clone(arg);
20782         int64_t ret_ref = tag_ptr(ret_copy, true);
20783         return ret_ref;
20784 }
20785 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u16Z_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20786         LDKCOption_u16Z* arg_conv = (LDKCOption_u16Z*)untag_ptr(arg);
20787         int64_t ret_conv = COption_u16Z_clone_ptr(arg_conv);
20788         return ret_conv;
20789 }
20790
20791 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u16Z_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20792         LDKCOption_u16Z* orig_conv = (LDKCOption_u16Z*)untag_ptr(orig);
20793         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
20794         *ret_copy = COption_u16Z_clone(orig_conv);
20795         int64_t ret_ref = tag_ptr(ret_copy, true);
20796         return ret_ref;
20797 }
20798
20799 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1ok(JNIEnv *env, jclass clz) {
20800         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
20801         *ret_conv = CResult_NoneAPIErrorZ_ok();
20802         return tag_ptr(ret_conv, true);
20803 }
20804
20805 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20806         void* e_ptr = untag_ptr(e);
20807         CHECK_ACCESS(e_ptr);
20808         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
20809         e_conv = APIError_clone((LDKAPIError*)untag_ptr(e));
20810         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
20811         *ret_conv = CResult_NoneAPIErrorZ_err(e_conv);
20812         return tag_ptr(ret_conv, true);
20813 }
20814
20815 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20816         LDKCResult_NoneAPIErrorZ* o_conv = (LDKCResult_NoneAPIErrorZ*)untag_ptr(o);
20817         jboolean ret_conv = CResult_NoneAPIErrorZ_is_ok(o_conv);
20818         return ret_conv;
20819 }
20820
20821 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_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_NoneAPIErrorZ _res_conv = *(LDKCResult_NoneAPIErrorZ*)(_res_ptr);
20826         FREE(untag_ptr(_res));
20827         CResult_NoneAPIErrorZ_free(_res_conv);
20828 }
20829
20830 static inline uint64_t CResult_NoneAPIErrorZ_clone_ptr(LDKCResult_NoneAPIErrorZ *NONNULL_PTR arg) {
20831         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
20832         *ret_conv = CResult_NoneAPIErrorZ_clone(arg);
20833         return tag_ptr(ret_conv, true);
20834 }
20835 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20836         LDKCResult_NoneAPIErrorZ* arg_conv = (LDKCResult_NoneAPIErrorZ*)untag_ptr(arg);
20837         int64_t ret_conv = CResult_NoneAPIErrorZ_clone_ptr(arg_conv);
20838         return ret_conv;
20839 }
20840
20841 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20842         LDKCResult_NoneAPIErrorZ* orig_conv = (LDKCResult_NoneAPIErrorZ*)untag_ptr(orig);
20843         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
20844         *ret_conv = CResult_NoneAPIErrorZ_clone(orig_conv);
20845         return tag_ptr(ret_conv, true);
20846 }
20847
20848 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1CResult_1NoneAPIErrorZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
20849         LDKCVec_CResult_NoneAPIErrorZZ _res_constr;
20850         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
20851         if (_res_constr.datalen > 0)
20852                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCResult_NoneAPIErrorZ), "LDKCVec_CResult_NoneAPIErrorZZ Elements");
20853         else
20854                 _res_constr.data = NULL;
20855         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
20856         for (size_t w = 0; w < _res_constr.datalen; w++) {
20857                 int64_t _res_conv_22 = _res_vals[w];
20858                 void* _res_conv_22_ptr = untag_ptr(_res_conv_22);
20859                 CHECK_ACCESS(_res_conv_22_ptr);
20860                 LDKCResult_NoneAPIErrorZ _res_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(_res_conv_22_ptr);
20861                 FREE(untag_ptr(_res_conv_22));
20862                 _res_constr.data[w] = _res_conv_22_conv;
20863         }
20864         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
20865         CVec_CResult_NoneAPIErrorZZ_free(_res_constr);
20866 }
20867
20868 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1APIErrorZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
20869         LDKCVec_APIErrorZ _res_constr;
20870         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
20871         if (_res_constr.datalen > 0)
20872                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKAPIError), "LDKCVec_APIErrorZ Elements");
20873         else
20874                 _res_constr.data = NULL;
20875         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
20876         for (size_t k = 0; k < _res_constr.datalen; k++) {
20877                 int64_t _res_conv_10 = _res_vals[k];
20878                 void* _res_conv_10_ptr = untag_ptr(_res_conv_10);
20879                 CHECK_ACCESS(_res_conv_10_ptr);
20880                 LDKAPIError _res_conv_10_conv = *(LDKAPIError*)(_res_conv_10_ptr);
20881                 FREE(untag_ptr(_res_conv_10));
20882                 _res_constr.data[k] = _res_conv_10_conv;
20883         }
20884         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
20885         CVec_APIErrorZ_free(_res_constr);
20886 }
20887
20888 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1_1u832APIErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
20889         LDKThirtyTwoBytes o_ref;
20890         CHECK((*env)->GetArrayLength(env, o) == 32);
20891         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.data);
20892         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
20893         *ret_conv = CResult__u832APIErrorZ_ok(o_ref);
20894         return tag_ptr(ret_conv, true);
20895 }
20896
20897 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1_1u832APIErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20898         void* e_ptr = untag_ptr(e);
20899         CHECK_ACCESS(e_ptr);
20900         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
20901         e_conv = APIError_clone((LDKAPIError*)untag_ptr(e));
20902         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
20903         *ret_conv = CResult__u832APIErrorZ_err(e_conv);
20904         return tag_ptr(ret_conv, true);
20905 }
20906
20907 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1_1u832APIErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20908         LDKCResult__u832APIErrorZ* o_conv = (LDKCResult__u832APIErrorZ*)untag_ptr(o);
20909         jboolean ret_conv = CResult__u832APIErrorZ_is_ok(o_conv);
20910         return ret_conv;
20911 }
20912
20913 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1_1u832APIErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20914         if (!ptr_is_owned(_res)) return;
20915         void* _res_ptr = untag_ptr(_res);
20916         CHECK_ACCESS(_res_ptr);
20917         LDKCResult__u832APIErrorZ _res_conv = *(LDKCResult__u832APIErrorZ*)(_res_ptr);
20918         FREE(untag_ptr(_res));
20919         CResult__u832APIErrorZ_free(_res_conv);
20920 }
20921
20922 static inline uint64_t CResult__u832APIErrorZ_clone_ptr(LDKCResult__u832APIErrorZ *NONNULL_PTR arg) {
20923         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
20924         *ret_conv = CResult__u832APIErrorZ_clone(arg);
20925         return tag_ptr(ret_conv, true);
20926 }
20927 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1_1u832APIErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20928         LDKCResult__u832APIErrorZ* arg_conv = (LDKCResult__u832APIErrorZ*)untag_ptr(arg);
20929         int64_t ret_conv = CResult__u832APIErrorZ_clone_ptr(arg_conv);
20930         return ret_conv;
20931 }
20932
20933 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1_1u832APIErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20934         LDKCResult__u832APIErrorZ* orig_conv = (LDKCResult__u832APIErrorZ*)untag_ptr(orig);
20935         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
20936         *ret_conv = CResult__u832APIErrorZ_clone(orig_conv);
20937         return tag_ptr(ret_conv, true);
20938 }
20939
20940 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1ok(JNIEnv *env, jclass clz) {
20941         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
20942         *ret_conv = CResult_NonePaymentSendFailureZ_ok();
20943         return tag_ptr(ret_conv, true);
20944 }
20945
20946 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20947         void* e_ptr = untag_ptr(e);
20948         CHECK_ACCESS(e_ptr);
20949         LDKPaymentSendFailure e_conv = *(LDKPaymentSendFailure*)(e_ptr);
20950         e_conv = PaymentSendFailure_clone((LDKPaymentSendFailure*)untag_ptr(e));
20951         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
20952         *ret_conv = CResult_NonePaymentSendFailureZ_err(e_conv);
20953         return tag_ptr(ret_conv, true);
20954 }
20955
20956 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
20957         LDKCResult_NonePaymentSendFailureZ* o_conv = (LDKCResult_NonePaymentSendFailureZ*)untag_ptr(o);
20958         jboolean ret_conv = CResult_NonePaymentSendFailureZ_is_ok(o_conv);
20959         return ret_conv;
20960 }
20961
20962 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
20963         if (!ptr_is_owned(_res)) return;
20964         void* _res_ptr = untag_ptr(_res);
20965         CHECK_ACCESS(_res_ptr);
20966         LDKCResult_NonePaymentSendFailureZ _res_conv = *(LDKCResult_NonePaymentSendFailureZ*)(_res_ptr);
20967         FREE(untag_ptr(_res));
20968         CResult_NonePaymentSendFailureZ_free(_res_conv);
20969 }
20970
20971 static inline uint64_t CResult_NonePaymentSendFailureZ_clone_ptr(LDKCResult_NonePaymentSendFailureZ *NONNULL_PTR arg) {
20972         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
20973         *ret_conv = CResult_NonePaymentSendFailureZ_clone(arg);
20974         return tag_ptr(ret_conv, true);
20975 }
20976 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20977         LDKCResult_NonePaymentSendFailureZ* arg_conv = (LDKCResult_NonePaymentSendFailureZ*)untag_ptr(arg);
20978         int64_t ret_conv = CResult_NonePaymentSendFailureZ_clone_ptr(arg_conv);
20979         return ret_conv;
20980 }
20981
20982 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20983         LDKCResult_NonePaymentSendFailureZ* orig_conv = (LDKCResult_NonePaymentSendFailureZ*)untag_ptr(orig);
20984         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
20985         *ret_conv = CResult_NonePaymentSendFailureZ_clone(orig_conv);
20986         return tag_ptr(ret_conv, true);
20987 }
20988
20989 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentHashPaymentSendFailureZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
20990         LDKThirtyTwoBytes o_ref;
20991         CHECK((*env)->GetArrayLength(env, o) == 32);
20992         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.data);
20993         LDKCResult_PaymentHashPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentHashPaymentSendFailureZ), "LDKCResult_PaymentHashPaymentSendFailureZ");
20994         *ret_conv = CResult_PaymentHashPaymentSendFailureZ_ok(o_ref);
20995         return tag_ptr(ret_conv, true);
20996 }
20997
20998 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentHashPaymentSendFailureZ_1err(JNIEnv *env, jclass clz, int64_t e) {
20999         void* e_ptr = untag_ptr(e);
21000         CHECK_ACCESS(e_ptr);
21001         LDKPaymentSendFailure e_conv = *(LDKPaymentSendFailure*)(e_ptr);
21002         e_conv = PaymentSendFailure_clone((LDKPaymentSendFailure*)untag_ptr(e));
21003         LDKCResult_PaymentHashPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentHashPaymentSendFailureZ), "LDKCResult_PaymentHashPaymentSendFailureZ");
21004         *ret_conv = CResult_PaymentHashPaymentSendFailureZ_err(e_conv);
21005         return tag_ptr(ret_conv, true);
21006 }
21007
21008 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentHashPaymentSendFailureZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21009         LDKCResult_PaymentHashPaymentSendFailureZ* o_conv = (LDKCResult_PaymentHashPaymentSendFailureZ*)untag_ptr(o);
21010         jboolean ret_conv = CResult_PaymentHashPaymentSendFailureZ_is_ok(o_conv);
21011         return ret_conv;
21012 }
21013
21014 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentHashPaymentSendFailureZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21015         if (!ptr_is_owned(_res)) return;
21016         void* _res_ptr = untag_ptr(_res);
21017         CHECK_ACCESS(_res_ptr);
21018         LDKCResult_PaymentHashPaymentSendFailureZ _res_conv = *(LDKCResult_PaymentHashPaymentSendFailureZ*)(_res_ptr);
21019         FREE(untag_ptr(_res));
21020         CResult_PaymentHashPaymentSendFailureZ_free(_res_conv);
21021 }
21022
21023 static inline uint64_t CResult_PaymentHashPaymentSendFailureZ_clone_ptr(LDKCResult_PaymentHashPaymentSendFailureZ *NONNULL_PTR arg) {
21024         LDKCResult_PaymentHashPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentHashPaymentSendFailureZ), "LDKCResult_PaymentHashPaymentSendFailureZ");
21025         *ret_conv = CResult_PaymentHashPaymentSendFailureZ_clone(arg);
21026         return tag_ptr(ret_conv, true);
21027 }
21028 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentHashPaymentSendFailureZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21029         LDKCResult_PaymentHashPaymentSendFailureZ* arg_conv = (LDKCResult_PaymentHashPaymentSendFailureZ*)untag_ptr(arg);
21030         int64_t ret_conv = CResult_PaymentHashPaymentSendFailureZ_clone_ptr(arg_conv);
21031         return ret_conv;
21032 }
21033
21034 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentHashPaymentSendFailureZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21035         LDKCResult_PaymentHashPaymentSendFailureZ* orig_conv = (LDKCResult_PaymentHashPaymentSendFailureZ*)untag_ptr(orig);
21036         LDKCResult_PaymentHashPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentHashPaymentSendFailureZ), "LDKCResult_PaymentHashPaymentSendFailureZ");
21037         *ret_conv = CResult_PaymentHashPaymentSendFailureZ_clone(orig_conv);
21038         return tag_ptr(ret_conv, true);
21039 }
21040
21041 static inline uint64_t C2Tuple_PaymentHashPaymentIdZ_clone_ptr(LDKC2Tuple_PaymentHashPaymentIdZ *NONNULL_PTR arg) {
21042         LDKC2Tuple_PaymentHashPaymentIdZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentIdZ), "LDKC2Tuple_PaymentHashPaymentIdZ");
21043         *ret_conv = C2Tuple_PaymentHashPaymentIdZ_clone(arg);
21044         return tag_ptr(ret_conv, true);
21045 }
21046 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentIdZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21047         LDKC2Tuple_PaymentHashPaymentIdZ* arg_conv = (LDKC2Tuple_PaymentHashPaymentIdZ*)untag_ptr(arg);
21048         int64_t ret_conv = C2Tuple_PaymentHashPaymentIdZ_clone_ptr(arg_conv);
21049         return ret_conv;
21050 }
21051
21052 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentIdZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21053         LDKC2Tuple_PaymentHashPaymentIdZ* orig_conv = (LDKC2Tuple_PaymentHashPaymentIdZ*)untag_ptr(orig);
21054         LDKC2Tuple_PaymentHashPaymentIdZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentIdZ), "LDKC2Tuple_PaymentHashPaymentIdZ");
21055         *ret_conv = C2Tuple_PaymentHashPaymentIdZ_clone(orig_conv);
21056         return tag_ptr(ret_conv, true);
21057 }
21058
21059 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentIdZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int8_tArray b) {
21060         LDKThirtyTwoBytes a_ref;
21061         CHECK((*env)->GetArrayLength(env, a) == 32);
21062         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
21063         LDKThirtyTwoBytes b_ref;
21064         CHECK((*env)->GetArrayLength(env, b) == 32);
21065         (*env)->GetByteArrayRegion(env, b, 0, 32, b_ref.data);
21066         LDKC2Tuple_PaymentHashPaymentIdZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentIdZ), "LDKC2Tuple_PaymentHashPaymentIdZ");
21067         *ret_conv = C2Tuple_PaymentHashPaymentIdZ_new(a_ref, b_ref);
21068         return tag_ptr(ret_conv, true);
21069 }
21070
21071 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentIdZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21072         if (!ptr_is_owned(_res)) return;
21073         void* _res_ptr = untag_ptr(_res);
21074         CHECK_ACCESS(_res_ptr);
21075         LDKC2Tuple_PaymentHashPaymentIdZ _res_conv = *(LDKC2Tuple_PaymentHashPaymentIdZ*)(_res_ptr);
21076         FREE(untag_ptr(_res));
21077         C2Tuple_PaymentHashPaymentIdZ_free(_res_conv);
21078 }
21079
21080 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21081         void* o_ptr = untag_ptr(o);
21082         CHECK_ACCESS(o_ptr);
21083         LDKC2Tuple_PaymentHashPaymentIdZ o_conv = *(LDKC2Tuple_PaymentHashPaymentIdZ*)(o_ptr);
21084         o_conv = C2Tuple_PaymentHashPaymentIdZ_clone((LDKC2Tuple_PaymentHashPaymentIdZ*)untag_ptr(o));
21085         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
21086         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_ok(o_conv);
21087         return tag_ptr(ret_conv, true);
21088 }
21089
21090 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21091         void* e_ptr = untag_ptr(e);
21092         CHECK_ACCESS(e_ptr);
21093         LDKPaymentSendFailure e_conv = *(LDKPaymentSendFailure*)(e_ptr);
21094         e_conv = PaymentSendFailure_clone((LDKPaymentSendFailure*)untag_ptr(e));
21095         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
21096         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_err(e_conv);
21097         return tag_ptr(ret_conv, true);
21098 }
21099
21100 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21101         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* o_conv = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)untag_ptr(o);
21102         jboolean ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_is_ok(o_conv);
21103         return ret_conv;
21104 }
21105
21106 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21107         if (!ptr_is_owned(_res)) return;
21108         void* _res_ptr = untag_ptr(_res);
21109         CHECK_ACCESS(_res_ptr);
21110         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ _res_conv = *(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(_res_ptr);
21111         FREE(untag_ptr(_res));
21112         CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_free(_res_conv);
21113 }
21114
21115 static inline uint64_t CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone_ptr(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ *NONNULL_PTR arg) {
21116         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
21117         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone(arg);
21118         return tag_ptr(ret_conv, true);
21119 }
21120 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21121         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* arg_conv = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)untag_ptr(arg);
21122         int64_t ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone_ptr(arg_conv);
21123         return ret_conv;
21124 }
21125
21126 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21127         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* orig_conv = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)untag_ptr(orig);
21128         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
21129         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone(orig_conv);
21130         return tag_ptr(ret_conv, true);
21131 }
21132
21133 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1ThirtyTwoBytesZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
21134         LDKCVec_ThirtyTwoBytesZ _res_constr;
21135         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
21136         if (_res_constr.datalen > 0)
21137                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_ThirtyTwoBytesZ Elements");
21138         else
21139                 _res_constr.data = NULL;
21140         for (size_t i = 0; i < _res_constr.datalen; i++) {
21141                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
21142                 LDKThirtyTwoBytes _res_conv_8_ref;
21143                 CHECK((*env)->GetArrayLength(env, _res_conv_8) == 32);
21144                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, 32, _res_conv_8_ref.data);
21145                 _res_constr.data[i] = _res_conv_8_ref;
21146         }
21147         CVec_ThirtyTwoBytesZ_free(_res_constr);
21148 }
21149
21150 static inline uint64_t C2Tuple_PaymentHashPaymentSecretZ_clone_ptr(LDKC2Tuple_PaymentHashPaymentSecretZ *NONNULL_PTR arg) {
21151         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
21152         *ret_conv = C2Tuple_PaymentHashPaymentSecretZ_clone(arg);
21153         return tag_ptr(ret_conv, true);
21154 }
21155 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentSecretZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21156         LDKC2Tuple_PaymentHashPaymentSecretZ* arg_conv = (LDKC2Tuple_PaymentHashPaymentSecretZ*)untag_ptr(arg);
21157         int64_t ret_conv = C2Tuple_PaymentHashPaymentSecretZ_clone_ptr(arg_conv);
21158         return ret_conv;
21159 }
21160
21161 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentSecretZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21162         LDKC2Tuple_PaymentHashPaymentSecretZ* orig_conv = (LDKC2Tuple_PaymentHashPaymentSecretZ*)untag_ptr(orig);
21163         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
21164         *ret_conv = C2Tuple_PaymentHashPaymentSecretZ_clone(orig_conv);
21165         return tag_ptr(ret_conv, true);
21166 }
21167
21168 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentSecretZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int8_tArray b) {
21169         LDKThirtyTwoBytes a_ref;
21170         CHECK((*env)->GetArrayLength(env, a) == 32);
21171         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
21172         LDKThirtyTwoBytes b_ref;
21173         CHECK((*env)->GetArrayLength(env, b) == 32);
21174         (*env)->GetByteArrayRegion(env, b, 0, 32, b_ref.data);
21175         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
21176         *ret_conv = C2Tuple_PaymentHashPaymentSecretZ_new(a_ref, b_ref);
21177         return tag_ptr(ret_conv, true);
21178 }
21179
21180 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentSecretZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21181         if (!ptr_is_owned(_res)) return;
21182         void* _res_ptr = untag_ptr(_res);
21183         CHECK_ACCESS(_res_ptr);
21184         LDKC2Tuple_PaymentHashPaymentSecretZ _res_conv = *(LDKC2Tuple_PaymentHashPaymentSecretZ*)(_res_ptr);
21185         FREE(untag_ptr(_res));
21186         C2Tuple_PaymentHashPaymentSecretZ_free(_res_conv);
21187 }
21188
21189 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21190         void* o_ptr = untag_ptr(o);
21191         CHECK_ACCESS(o_ptr);
21192         LDKC2Tuple_PaymentHashPaymentSecretZ o_conv = *(LDKC2Tuple_PaymentHashPaymentSecretZ*)(o_ptr);
21193         o_conv = C2Tuple_PaymentHashPaymentSecretZ_clone((LDKC2Tuple_PaymentHashPaymentSecretZ*)untag_ptr(o));
21194         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
21195         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_ok(o_conv);
21196         return tag_ptr(ret_conv, true);
21197 }
21198
21199 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZNoneZ_1err(JNIEnv *env, jclass clz) {
21200         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
21201         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_err();
21202         return tag_ptr(ret_conv, true);
21203 }
21204
21205 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21206         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* o_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)untag_ptr(o);
21207         jboolean ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_is_ok(o_conv);
21208         return ret_conv;
21209 }
21210
21211 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21212         if (!ptr_is_owned(_res)) return;
21213         void* _res_ptr = untag_ptr(_res);
21214         CHECK_ACCESS(_res_ptr);
21215         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ _res_conv = *(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)(_res_ptr);
21216         FREE(untag_ptr(_res));
21217         CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_free(_res_conv);
21218 }
21219
21220 static inline uint64_t CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone_ptr(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ *NONNULL_PTR arg) {
21221         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
21222         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone(arg);
21223         return tag_ptr(ret_conv, true);
21224 }
21225 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21226         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* arg_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)untag_ptr(arg);
21227         int64_t ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone_ptr(arg_conv);
21228         return ret_conv;
21229 }
21230
21231 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21232         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* orig_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ*)untag_ptr(orig);
21233         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
21234         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_clone(orig_conv);
21235         return tag_ptr(ret_conv, true);
21236 }
21237
21238 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZAPIErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21239         void* o_ptr = untag_ptr(o);
21240         CHECK_ACCESS(o_ptr);
21241         LDKC2Tuple_PaymentHashPaymentSecretZ o_conv = *(LDKC2Tuple_PaymentHashPaymentSecretZ*)(o_ptr);
21242         o_conv = C2Tuple_PaymentHashPaymentSecretZ_clone((LDKC2Tuple_PaymentHashPaymentSecretZ*)untag_ptr(o));
21243         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ");
21244         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_ok(o_conv);
21245         return tag_ptr(ret_conv, true);
21246 }
21247
21248 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZAPIErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21249         void* e_ptr = untag_ptr(e);
21250         CHECK_ACCESS(e_ptr);
21251         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
21252         e_conv = APIError_clone((LDKAPIError*)untag_ptr(e));
21253         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ");
21254         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_err(e_conv);
21255         return tag_ptr(ret_conv, true);
21256 }
21257
21258 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZAPIErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21259         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* o_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)untag_ptr(o);
21260         jboolean ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_is_ok(o_conv);
21261         return ret_conv;
21262 }
21263
21264 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZAPIErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21265         if (!ptr_is_owned(_res)) return;
21266         void* _res_ptr = untag_ptr(_res);
21267         CHECK_ACCESS(_res_ptr);
21268         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ _res_conv = *(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)(_res_ptr);
21269         FREE(untag_ptr(_res));
21270         CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_free(_res_conv);
21271 }
21272
21273 static inline uint64_t CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone_ptr(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ *NONNULL_PTR arg) {
21274         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ");
21275         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone(arg);
21276         return tag_ptr(ret_conv, true);
21277 }
21278 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZAPIErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21279         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* arg_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)untag_ptr(arg);
21280         int64_t ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone_ptr(arg_conv);
21281         return ret_conv;
21282 }
21283
21284 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentSecretZAPIErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21285         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* orig_conv = (LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ*)untag_ptr(orig);
21286         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ");
21287         *ret_conv = CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ_clone(orig_conv);
21288         return tag_ptr(ret_conv, true);
21289 }
21290
21291 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretNoneZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
21292         LDKThirtyTwoBytes o_ref;
21293         CHECK((*env)->GetArrayLength(env, o) == 32);
21294         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.data);
21295         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
21296         *ret_conv = CResult_PaymentSecretNoneZ_ok(o_ref);
21297         return tag_ptr(ret_conv, true);
21298 }
21299
21300 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretNoneZ_1err(JNIEnv *env, jclass clz) {
21301         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
21302         *ret_conv = CResult_PaymentSecretNoneZ_err();
21303         return tag_ptr(ret_conv, true);
21304 }
21305
21306 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21307         LDKCResult_PaymentSecretNoneZ* o_conv = (LDKCResult_PaymentSecretNoneZ*)untag_ptr(o);
21308         jboolean ret_conv = CResult_PaymentSecretNoneZ_is_ok(o_conv);
21309         return ret_conv;
21310 }
21311
21312 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21313         if (!ptr_is_owned(_res)) return;
21314         void* _res_ptr = untag_ptr(_res);
21315         CHECK_ACCESS(_res_ptr);
21316         LDKCResult_PaymentSecretNoneZ _res_conv = *(LDKCResult_PaymentSecretNoneZ*)(_res_ptr);
21317         FREE(untag_ptr(_res));
21318         CResult_PaymentSecretNoneZ_free(_res_conv);
21319 }
21320
21321 static inline uint64_t CResult_PaymentSecretNoneZ_clone_ptr(LDKCResult_PaymentSecretNoneZ *NONNULL_PTR arg) {
21322         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
21323         *ret_conv = CResult_PaymentSecretNoneZ_clone(arg);
21324         return tag_ptr(ret_conv, true);
21325 }
21326 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21327         LDKCResult_PaymentSecretNoneZ* arg_conv = (LDKCResult_PaymentSecretNoneZ*)untag_ptr(arg);
21328         int64_t ret_conv = CResult_PaymentSecretNoneZ_clone_ptr(arg_conv);
21329         return ret_conv;
21330 }
21331
21332 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21333         LDKCResult_PaymentSecretNoneZ* orig_conv = (LDKCResult_PaymentSecretNoneZ*)untag_ptr(orig);
21334         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
21335         *ret_conv = CResult_PaymentSecretNoneZ_clone(orig_conv);
21336         return tag_ptr(ret_conv, true);
21337 }
21338
21339 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
21340         LDKThirtyTwoBytes o_ref;
21341         CHECK((*env)->GetArrayLength(env, o) == 32);
21342         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.data);
21343         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
21344         *ret_conv = CResult_PaymentSecretAPIErrorZ_ok(o_ref);
21345         return tag_ptr(ret_conv, true);
21346 }
21347
21348 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21349         void* e_ptr = untag_ptr(e);
21350         CHECK_ACCESS(e_ptr);
21351         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
21352         e_conv = APIError_clone((LDKAPIError*)untag_ptr(e));
21353         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
21354         *ret_conv = CResult_PaymentSecretAPIErrorZ_err(e_conv);
21355         return tag_ptr(ret_conv, true);
21356 }
21357
21358 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21359         LDKCResult_PaymentSecretAPIErrorZ* o_conv = (LDKCResult_PaymentSecretAPIErrorZ*)untag_ptr(o);
21360         jboolean ret_conv = CResult_PaymentSecretAPIErrorZ_is_ok(o_conv);
21361         return ret_conv;
21362 }
21363
21364 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21365         if (!ptr_is_owned(_res)) return;
21366         void* _res_ptr = untag_ptr(_res);
21367         CHECK_ACCESS(_res_ptr);
21368         LDKCResult_PaymentSecretAPIErrorZ _res_conv = *(LDKCResult_PaymentSecretAPIErrorZ*)(_res_ptr);
21369         FREE(untag_ptr(_res));
21370         CResult_PaymentSecretAPIErrorZ_free(_res_conv);
21371 }
21372
21373 static inline uint64_t CResult_PaymentSecretAPIErrorZ_clone_ptr(LDKCResult_PaymentSecretAPIErrorZ *NONNULL_PTR arg) {
21374         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
21375         *ret_conv = CResult_PaymentSecretAPIErrorZ_clone(arg);
21376         return tag_ptr(ret_conv, true);
21377 }
21378 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21379         LDKCResult_PaymentSecretAPIErrorZ* arg_conv = (LDKCResult_PaymentSecretAPIErrorZ*)untag_ptr(arg);
21380         int64_t ret_conv = CResult_PaymentSecretAPIErrorZ_clone_ptr(arg_conv);
21381         return ret_conv;
21382 }
21383
21384 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21385         LDKCResult_PaymentSecretAPIErrorZ* orig_conv = (LDKCResult_PaymentSecretAPIErrorZ*)untag_ptr(orig);
21386         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
21387         *ret_conv = CResult_PaymentSecretAPIErrorZ_clone(orig_conv);
21388         return tag_ptr(ret_conv, true);
21389 }
21390
21391 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPreimageAPIErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
21392         LDKThirtyTwoBytes o_ref;
21393         CHECK((*env)->GetArrayLength(env, o) == 32);
21394         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.data);
21395         LDKCResult_PaymentPreimageAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPreimageAPIErrorZ), "LDKCResult_PaymentPreimageAPIErrorZ");
21396         *ret_conv = CResult_PaymentPreimageAPIErrorZ_ok(o_ref);
21397         return tag_ptr(ret_conv, true);
21398 }
21399
21400 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPreimageAPIErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21401         void* e_ptr = untag_ptr(e);
21402         CHECK_ACCESS(e_ptr);
21403         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
21404         e_conv = APIError_clone((LDKAPIError*)untag_ptr(e));
21405         LDKCResult_PaymentPreimageAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPreimageAPIErrorZ), "LDKCResult_PaymentPreimageAPIErrorZ");
21406         *ret_conv = CResult_PaymentPreimageAPIErrorZ_err(e_conv);
21407         return tag_ptr(ret_conv, true);
21408 }
21409
21410 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPreimageAPIErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21411         LDKCResult_PaymentPreimageAPIErrorZ* o_conv = (LDKCResult_PaymentPreimageAPIErrorZ*)untag_ptr(o);
21412         jboolean ret_conv = CResult_PaymentPreimageAPIErrorZ_is_ok(o_conv);
21413         return ret_conv;
21414 }
21415
21416 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPreimageAPIErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21417         if (!ptr_is_owned(_res)) return;
21418         void* _res_ptr = untag_ptr(_res);
21419         CHECK_ACCESS(_res_ptr);
21420         LDKCResult_PaymentPreimageAPIErrorZ _res_conv = *(LDKCResult_PaymentPreimageAPIErrorZ*)(_res_ptr);
21421         FREE(untag_ptr(_res));
21422         CResult_PaymentPreimageAPIErrorZ_free(_res_conv);
21423 }
21424
21425 static inline uint64_t CResult_PaymentPreimageAPIErrorZ_clone_ptr(LDKCResult_PaymentPreimageAPIErrorZ *NONNULL_PTR arg) {
21426         LDKCResult_PaymentPreimageAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPreimageAPIErrorZ), "LDKCResult_PaymentPreimageAPIErrorZ");
21427         *ret_conv = CResult_PaymentPreimageAPIErrorZ_clone(arg);
21428         return tag_ptr(ret_conv, true);
21429 }
21430 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPreimageAPIErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21431         LDKCResult_PaymentPreimageAPIErrorZ* arg_conv = (LDKCResult_PaymentPreimageAPIErrorZ*)untag_ptr(arg);
21432         int64_t ret_conv = CResult_PaymentPreimageAPIErrorZ_clone_ptr(arg_conv);
21433         return ret_conv;
21434 }
21435
21436 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentPreimageAPIErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21437         LDKCResult_PaymentPreimageAPIErrorZ* orig_conv = (LDKCResult_PaymentPreimageAPIErrorZ*)untag_ptr(orig);
21438         LDKCResult_PaymentPreimageAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPreimageAPIErrorZ), "LDKCResult_PaymentPreimageAPIErrorZ");
21439         *ret_conv = CResult_PaymentPreimageAPIErrorZ_clone(orig_conv);
21440         return tag_ptr(ret_conv, true);
21441 }
21442
21443 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyForwardingInfoDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21444         LDKCounterpartyForwardingInfo o_conv;
21445         o_conv.inner = untag_ptr(o);
21446         o_conv.is_owned = ptr_is_owned(o);
21447         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
21448         o_conv = CounterpartyForwardingInfo_clone(&o_conv);
21449         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ), "LDKCResult_CounterpartyForwardingInfoDecodeErrorZ");
21450         *ret_conv = CResult_CounterpartyForwardingInfoDecodeErrorZ_ok(o_conv);
21451         return tag_ptr(ret_conv, true);
21452 }
21453
21454 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyForwardingInfoDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21455         void* e_ptr = untag_ptr(e);
21456         CHECK_ACCESS(e_ptr);
21457         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
21458         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
21459         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ), "LDKCResult_CounterpartyForwardingInfoDecodeErrorZ");
21460         *ret_conv = CResult_CounterpartyForwardingInfoDecodeErrorZ_err(e_conv);
21461         return tag_ptr(ret_conv, true);
21462 }
21463
21464 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyForwardingInfoDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21465         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* o_conv = (LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)untag_ptr(o);
21466         jboolean ret_conv = CResult_CounterpartyForwardingInfoDecodeErrorZ_is_ok(o_conv);
21467         return ret_conv;
21468 }
21469
21470 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyForwardingInfoDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21471         if (!ptr_is_owned(_res)) return;
21472         void* _res_ptr = untag_ptr(_res);
21473         CHECK_ACCESS(_res_ptr);
21474         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ _res_conv = *(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)(_res_ptr);
21475         FREE(untag_ptr(_res));
21476         CResult_CounterpartyForwardingInfoDecodeErrorZ_free(_res_conv);
21477 }
21478
21479 static inline uint64_t CResult_CounterpartyForwardingInfoDecodeErrorZ_clone_ptr(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ *NONNULL_PTR arg) {
21480         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ), "LDKCResult_CounterpartyForwardingInfoDecodeErrorZ");
21481         *ret_conv = CResult_CounterpartyForwardingInfoDecodeErrorZ_clone(arg);
21482         return tag_ptr(ret_conv, true);
21483 }
21484 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyForwardingInfoDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21485         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* arg_conv = (LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)untag_ptr(arg);
21486         int64_t ret_conv = CResult_CounterpartyForwardingInfoDecodeErrorZ_clone_ptr(arg_conv);
21487         return ret_conv;
21488 }
21489
21490 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyForwardingInfoDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21491         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* orig_conv = (LDKCResult_CounterpartyForwardingInfoDecodeErrorZ*)untag_ptr(orig);
21492         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ), "LDKCResult_CounterpartyForwardingInfoDecodeErrorZ");
21493         *ret_conv = CResult_CounterpartyForwardingInfoDecodeErrorZ_clone(orig_conv);
21494         return tag_ptr(ret_conv, true);
21495 }
21496
21497 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelCounterpartyDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21498         LDKChannelCounterparty o_conv;
21499         o_conv.inner = untag_ptr(o);
21500         o_conv.is_owned = ptr_is_owned(o);
21501         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
21502         o_conv = ChannelCounterparty_clone(&o_conv);
21503         LDKCResult_ChannelCounterpartyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelCounterpartyDecodeErrorZ), "LDKCResult_ChannelCounterpartyDecodeErrorZ");
21504         *ret_conv = CResult_ChannelCounterpartyDecodeErrorZ_ok(o_conv);
21505         return tag_ptr(ret_conv, true);
21506 }
21507
21508 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelCounterpartyDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21509         void* e_ptr = untag_ptr(e);
21510         CHECK_ACCESS(e_ptr);
21511         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
21512         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
21513         LDKCResult_ChannelCounterpartyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelCounterpartyDecodeErrorZ), "LDKCResult_ChannelCounterpartyDecodeErrorZ");
21514         *ret_conv = CResult_ChannelCounterpartyDecodeErrorZ_err(e_conv);
21515         return tag_ptr(ret_conv, true);
21516 }
21517
21518 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelCounterpartyDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21519         LDKCResult_ChannelCounterpartyDecodeErrorZ* o_conv = (LDKCResult_ChannelCounterpartyDecodeErrorZ*)untag_ptr(o);
21520         jboolean ret_conv = CResult_ChannelCounterpartyDecodeErrorZ_is_ok(o_conv);
21521         return ret_conv;
21522 }
21523
21524 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelCounterpartyDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21525         if (!ptr_is_owned(_res)) return;
21526         void* _res_ptr = untag_ptr(_res);
21527         CHECK_ACCESS(_res_ptr);
21528         LDKCResult_ChannelCounterpartyDecodeErrorZ _res_conv = *(LDKCResult_ChannelCounterpartyDecodeErrorZ*)(_res_ptr);
21529         FREE(untag_ptr(_res));
21530         CResult_ChannelCounterpartyDecodeErrorZ_free(_res_conv);
21531 }
21532
21533 static inline uint64_t CResult_ChannelCounterpartyDecodeErrorZ_clone_ptr(LDKCResult_ChannelCounterpartyDecodeErrorZ *NONNULL_PTR arg) {
21534         LDKCResult_ChannelCounterpartyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelCounterpartyDecodeErrorZ), "LDKCResult_ChannelCounterpartyDecodeErrorZ");
21535         *ret_conv = CResult_ChannelCounterpartyDecodeErrorZ_clone(arg);
21536         return tag_ptr(ret_conv, true);
21537 }
21538 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelCounterpartyDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21539         LDKCResult_ChannelCounterpartyDecodeErrorZ* arg_conv = (LDKCResult_ChannelCounterpartyDecodeErrorZ*)untag_ptr(arg);
21540         int64_t ret_conv = CResult_ChannelCounterpartyDecodeErrorZ_clone_ptr(arg_conv);
21541         return ret_conv;
21542 }
21543
21544 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelCounterpartyDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21545         LDKCResult_ChannelCounterpartyDecodeErrorZ* orig_conv = (LDKCResult_ChannelCounterpartyDecodeErrorZ*)untag_ptr(orig);
21546         LDKCResult_ChannelCounterpartyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelCounterpartyDecodeErrorZ), "LDKCResult_ChannelCounterpartyDecodeErrorZ");
21547         *ret_conv = CResult_ChannelCounterpartyDecodeErrorZ_clone(orig_conv);
21548         return tag_ptr(ret_conv, true);
21549 }
21550
21551 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelDetailsDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21552         LDKChannelDetails o_conv;
21553         o_conv.inner = untag_ptr(o);
21554         o_conv.is_owned = ptr_is_owned(o);
21555         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
21556         o_conv = ChannelDetails_clone(&o_conv);
21557         LDKCResult_ChannelDetailsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelDetailsDecodeErrorZ), "LDKCResult_ChannelDetailsDecodeErrorZ");
21558         *ret_conv = CResult_ChannelDetailsDecodeErrorZ_ok(o_conv);
21559         return tag_ptr(ret_conv, true);
21560 }
21561
21562 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelDetailsDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21563         void* e_ptr = untag_ptr(e);
21564         CHECK_ACCESS(e_ptr);
21565         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
21566         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
21567         LDKCResult_ChannelDetailsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelDetailsDecodeErrorZ), "LDKCResult_ChannelDetailsDecodeErrorZ");
21568         *ret_conv = CResult_ChannelDetailsDecodeErrorZ_err(e_conv);
21569         return tag_ptr(ret_conv, true);
21570 }
21571
21572 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelDetailsDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21573         LDKCResult_ChannelDetailsDecodeErrorZ* o_conv = (LDKCResult_ChannelDetailsDecodeErrorZ*)untag_ptr(o);
21574         jboolean ret_conv = CResult_ChannelDetailsDecodeErrorZ_is_ok(o_conv);
21575         return ret_conv;
21576 }
21577
21578 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelDetailsDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21579         if (!ptr_is_owned(_res)) return;
21580         void* _res_ptr = untag_ptr(_res);
21581         CHECK_ACCESS(_res_ptr);
21582         LDKCResult_ChannelDetailsDecodeErrorZ _res_conv = *(LDKCResult_ChannelDetailsDecodeErrorZ*)(_res_ptr);
21583         FREE(untag_ptr(_res));
21584         CResult_ChannelDetailsDecodeErrorZ_free(_res_conv);
21585 }
21586
21587 static inline uint64_t CResult_ChannelDetailsDecodeErrorZ_clone_ptr(LDKCResult_ChannelDetailsDecodeErrorZ *NONNULL_PTR arg) {
21588         LDKCResult_ChannelDetailsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelDetailsDecodeErrorZ), "LDKCResult_ChannelDetailsDecodeErrorZ");
21589         *ret_conv = CResult_ChannelDetailsDecodeErrorZ_clone(arg);
21590         return tag_ptr(ret_conv, true);
21591 }
21592 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelDetailsDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21593         LDKCResult_ChannelDetailsDecodeErrorZ* arg_conv = (LDKCResult_ChannelDetailsDecodeErrorZ*)untag_ptr(arg);
21594         int64_t ret_conv = CResult_ChannelDetailsDecodeErrorZ_clone_ptr(arg_conv);
21595         return ret_conv;
21596 }
21597
21598 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelDetailsDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21599         LDKCResult_ChannelDetailsDecodeErrorZ* orig_conv = (LDKCResult_ChannelDetailsDecodeErrorZ*)untag_ptr(orig);
21600         LDKCResult_ChannelDetailsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelDetailsDecodeErrorZ), "LDKCResult_ChannelDetailsDecodeErrorZ");
21601         *ret_conv = CResult_ChannelDetailsDecodeErrorZ_clone(orig_conv);
21602         return tag_ptr(ret_conv, true);
21603 }
21604
21605 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PhantomRouteHintsDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21606         LDKPhantomRouteHints o_conv;
21607         o_conv.inner = untag_ptr(o);
21608         o_conv.is_owned = ptr_is_owned(o);
21609         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
21610         o_conv = PhantomRouteHints_clone(&o_conv);
21611         LDKCResult_PhantomRouteHintsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PhantomRouteHintsDecodeErrorZ), "LDKCResult_PhantomRouteHintsDecodeErrorZ");
21612         *ret_conv = CResult_PhantomRouteHintsDecodeErrorZ_ok(o_conv);
21613         return tag_ptr(ret_conv, true);
21614 }
21615
21616 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PhantomRouteHintsDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21617         void* e_ptr = untag_ptr(e);
21618         CHECK_ACCESS(e_ptr);
21619         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
21620         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
21621         LDKCResult_PhantomRouteHintsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PhantomRouteHintsDecodeErrorZ), "LDKCResult_PhantomRouteHintsDecodeErrorZ");
21622         *ret_conv = CResult_PhantomRouteHintsDecodeErrorZ_err(e_conv);
21623         return tag_ptr(ret_conv, true);
21624 }
21625
21626 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PhantomRouteHintsDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21627         LDKCResult_PhantomRouteHintsDecodeErrorZ* o_conv = (LDKCResult_PhantomRouteHintsDecodeErrorZ*)untag_ptr(o);
21628         jboolean ret_conv = CResult_PhantomRouteHintsDecodeErrorZ_is_ok(o_conv);
21629         return ret_conv;
21630 }
21631
21632 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PhantomRouteHintsDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21633         if (!ptr_is_owned(_res)) return;
21634         void* _res_ptr = untag_ptr(_res);
21635         CHECK_ACCESS(_res_ptr);
21636         LDKCResult_PhantomRouteHintsDecodeErrorZ _res_conv = *(LDKCResult_PhantomRouteHintsDecodeErrorZ*)(_res_ptr);
21637         FREE(untag_ptr(_res));
21638         CResult_PhantomRouteHintsDecodeErrorZ_free(_res_conv);
21639 }
21640
21641 static inline uint64_t CResult_PhantomRouteHintsDecodeErrorZ_clone_ptr(LDKCResult_PhantomRouteHintsDecodeErrorZ *NONNULL_PTR arg) {
21642         LDKCResult_PhantomRouteHintsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PhantomRouteHintsDecodeErrorZ), "LDKCResult_PhantomRouteHintsDecodeErrorZ");
21643         *ret_conv = CResult_PhantomRouteHintsDecodeErrorZ_clone(arg);
21644         return tag_ptr(ret_conv, true);
21645 }
21646 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PhantomRouteHintsDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21647         LDKCResult_PhantomRouteHintsDecodeErrorZ* arg_conv = (LDKCResult_PhantomRouteHintsDecodeErrorZ*)untag_ptr(arg);
21648         int64_t ret_conv = CResult_PhantomRouteHintsDecodeErrorZ_clone_ptr(arg_conv);
21649         return ret_conv;
21650 }
21651
21652 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PhantomRouteHintsDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21653         LDKCResult_PhantomRouteHintsDecodeErrorZ* orig_conv = (LDKCResult_PhantomRouteHintsDecodeErrorZ*)untag_ptr(orig);
21654         LDKCResult_PhantomRouteHintsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PhantomRouteHintsDecodeErrorZ), "LDKCResult_PhantomRouteHintsDecodeErrorZ");
21655         *ret_conv = CResult_PhantomRouteHintsDecodeErrorZ_clone(orig_conv);
21656         return tag_ptr(ret_conv, true);
21657 }
21658
21659 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1ChannelMonitorZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
21660         LDKCVec_ChannelMonitorZ _res_constr;
21661         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
21662         if (_res_constr.datalen > 0)
21663                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKChannelMonitor), "LDKCVec_ChannelMonitorZ Elements");
21664         else
21665                 _res_constr.data = NULL;
21666         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
21667         for (size_t q = 0; q < _res_constr.datalen; q++) {
21668                 int64_t _res_conv_16 = _res_vals[q];
21669                 LDKChannelMonitor _res_conv_16_conv;
21670                 _res_conv_16_conv.inner = untag_ptr(_res_conv_16);
21671                 _res_conv_16_conv.is_owned = ptr_is_owned(_res_conv_16);
21672                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_16_conv);
21673                 _res_constr.data[q] = _res_conv_16_conv;
21674         }
21675         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
21676         CVec_ChannelMonitorZ_free(_res_constr);
21677 }
21678
21679 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelManagerZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_t b) {
21680         LDKThirtyTwoBytes a_ref;
21681         CHECK((*env)->GetArrayLength(env, a) == 32);
21682         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
21683         LDKChannelManager b_conv;
21684         b_conv.inner = untag_ptr(b);
21685         b_conv.is_owned = ptr_is_owned(b);
21686         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
21687         // WARNING: we need a move here but no clone is available for LDKChannelManager
21688         
21689         LDKC2Tuple_BlockHashChannelManagerZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelManagerZ), "LDKC2Tuple_BlockHashChannelManagerZ");
21690         *ret_conv = C2Tuple_BlockHashChannelManagerZ_new(a_ref, b_conv);
21691         return tag_ptr(ret_conv, true);
21692 }
21693
21694 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelManagerZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21695         if (!ptr_is_owned(_res)) return;
21696         void* _res_ptr = untag_ptr(_res);
21697         CHECK_ACCESS(_res_ptr);
21698         LDKC2Tuple_BlockHashChannelManagerZ _res_conv = *(LDKC2Tuple_BlockHashChannelManagerZ*)(_res_ptr);
21699         FREE(untag_ptr(_res));
21700         C2Tuple_BlockHashChannelManagerZ_free(_res_conv);
21701 }
21702
21703 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21704         void* o_ptr = untag_ptr(o);
21705         CHECK_ACCESS(o_ptr);
21706         LDKC2Tuple_BlockHashChannelManagerZ o_conv = *(LDKC2Tuple_BlockHashChannelManagerZ*)(o_ptr);
21707         // WARNING: we may need a move here but no clone is available for LDKC2Tuple_BlockHashChannelManagerZ
21708         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
21709         *ret_conv = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_ok(o_conv);
21710         return tag_ptr(ret_conv, true);
21711 }
21712
21713 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21714         void* e_ptr = untag_ptr(e);
21715         CHECK_ACCESS(e_ptr);
21716         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
21717         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
21718         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
21719         *ret_conv = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_err(e_conv);
21720         return tag_ptr(ret_conv, true);
21721 }
21722
21723 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21724         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* o_conv = (LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)untag_ptr(o);
21725         jboolean ret_conv = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_is_ok(o_conv);
21726         return ret_conv;
21727 }
21728
21729 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21730         if (!ptr_is_owned(_res)) return;
21731         void* _res_ptr = untag_ptr(_res);
21732         CHECK_ACCESS(_res_ptr);
21733         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ _res_conv = *(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(_res_ptr);
21734         FREE(untag_ptr(_res));
21735         CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_free(_res_conv);
21736 }
21737
21738 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21739         LDKChannelConfig o_conv;
21740         o_conv.inner = untag_ptr(o);
21741         o_conv.is_owned = ptr_is_owned(o);
21742         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
21743         o_conv = ChannelConfig_clone(&o_conv);
21744         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
21745         *ret_conv = CResult_ChannelConfigDecodeErrorZ_ok(o_conv);
21746         return tag_ptr(ret_conv, true);
21747 }
21748
21749 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21750         void* e_ptr = untag_ptr(e);
21751         CHECK_ACCESS(e_ptr);
21752         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
21753         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
21754         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
21755         *ret_conv = CResult_ChannelConfigDecodeErrorZ_err(e_conv);
21756         return tag_ptr(ret_conv, true);
21757 }
21758
21759 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21760         LDKCResult_ChannelConfigDecodeErrorZ* o_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)untag_ptr(o);
21761         jboolean ret_conv = CResult_ChannelConfigDecodeErrorZ_is_ok(o_conv);
21762         return ret_conv;
21763 }
21764
21765 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21766         if (!ptr_is_owned(_res)) return;
21767         void* _res_ptr = untag_ptr(_res);
21768         CHECK_ACCESS(_res_ptr);
21769         LDKCResult_ChannelConfigDecodeErrorZ _res_conv = *(LDKCResult_ChannelConfigDecodeErrorZ*)(_res_ptr);
21770         FREE(untag_ptr(_res));
21771         CResult_ChannelConfigDecodeErrorZ_free(_res_conv);
21772 }
21773
21774 static inline uint64_t CResult_ChannelConfigDecodeErrorZ_clone_ptr(LDKCResult_ChannelConfigDecodeErrorZ *NONNULL_PTR arg) {
21775         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
21776         *ret_conv = CResult_ChannelConfigDecodeErrorZ_clone(arg);
21777         return tag_ptr(ret_conv, true);
21778 }
21779 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21780         LDKCResult_ChannelConfigDecodeErrorZ* arg_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)untag_ptr(arg);
21781         int64_t ret_conv = CResult_ChannelConfigDecodeErrorZ_clone_ptr(arg_conv);
21782         return ret_conv;
21783 }
21784
21785 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21786         LDKCResult_ChannelConfigDecodeErrorZ* orig_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)untag_ptr(orig);
21787         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
21788         *ret_conv = CResult_ChannelConfigDecodeErrorZ_clone(orig_conv);
21789         return tag_ptr(ret_conv, true);
21790 }
21791
21792 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21793         LDKOutPoint o_conv;
21794         o_conv.inner = untag_ptr(o);
21795         o_conv.is_owned = ptr_is_owned(o);
21796         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
21797         o_conv = OutPoint_clone(&o_conv);
21798         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
21799         *ret_conv = CResult_OutPointDecodeErrorZ_ok(o_conv);
21800         return tag_ptr(ret_conv, true);
21801 }
21802
21803 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21804         void* e_ptr = untag_ptr(e);
21805         CHECK_ACCESS(e_ptr);
21806         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
21807         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
21808         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
21809         *ret_conv = CResult_OutPointDecodeErrorZ_err(e_conv);
21810         return tag_ptr(ret_conv, true);
21811 }
21812
21813 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21814         LDKCResult_OutPointDecodeErrorZ* o_conv = (LDKCResult_OutPointDecodeErrorZ*)untag_ptr(o);
21815         jboolean ret_conv = CResult_OutPointDecodeErrorZ_is_ok(o_conv);
21816         return ret_conv;
21817 }
21818
21819 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21820         if (!ptr_is_owned(_res)) return;
21821         void* _res_ptr = untag_ptr(_res);
21822         CHECK_ACCESS(_res_ptr);
21823         LDKCResult_OutPointDecodeErrorZ _res_conv = *(LDKCResult_OutPointDecodeErrorZ*)(_res_ptr);
21824         FREE(untag_ptr(_res));
21825         CResult_OutPointDecodeErrorZ_free(_res_conv);
21826 }
21827
21828 static inline uint64_t CResult_OutPointDecodeErrorZ_clone_ptr(LDKCResult_OutPointDecodeErrorZ *NONNULL_PTR arg) {
21829         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
21830         *ret_conv = CResult_OutPointDecodeErrorZ_clone(arg);
21831         return tag_ptr(ret_conv, true);
21832 }
21833 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21834         LDKCResult_OutPointDecodeErrorZ* arg_conv = (LDKCResult_OutPointDecodeErrorZ*)untag_ptr(arg);
21835         int64_t ret_conv = CResult_OutPointDecodeErrorZ_clone_ptr(arg_conv);
21836         return ret_conv;
21837 }
21838
21839 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21840         LDKCResult_OutPointDecodeErrorZ* orig_conv = (LDKCResult_OutPointDecodeErrorZ*)untag_ptr(orig);
21841         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
21842         *ret_conv = CResult_OutPointDecodeErrorZ_clone(orig_conv);
21843         return tag_ptr(ret_conv, true);
21844 }
21845
21846 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1TypeZ_1some(JNIEnv *env, jclass clz, int64_t o) {
21847         void* o_ptr = untag_ptr(o);
21848         CHECK_ACCESS(o_ptr);
21849         LDKType o_conv = *(LDKType*)(o_ptr);
21850         if (o_conv.free == LDKType_JCalls_free) {
21851                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
21852                 LDKType_JCalls_cloned(&o_conv);
21853         }
21854         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
21855         *ret_copy = COption_TypeZ_some(o_conv);
21856         int64_t ret_ref = tag_ptr(ret_copy, true);
21857         return ret_ref;
21858 }
21859
21860 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1TypeZ_1none(JNIEnv *env, jclass clz) {
21861         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
21862         *ret_copy = COption_TypeZ_none();
21863         int64_t ret_ref = tag_ptr(ret_copy, true);
21864         return ret_ref;
21865 }
21866
21867 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1TypeZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21868         if (!ptr_is_owned(_res)) return;
21869         void* _res_ptr = untag_ptr(_res);
21870         CHECK_ACCESS(_res_ptr);
21871         LDKCOption_TypeZ _res_conv = *(LDKCOption_TypeZ*)(_res_ptr);
21872         FREE(untag_ptr(_res));
21873         COption_TypeZ_free(_res_conv);
21874 }
21875
21876 static inline uint64_t COption_TypeZ_clone_ptr(LDKCOption_TypeZ *NONNULL_PTR arg) {
21877         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
21878         *ret_copy = COption_TypeZ_clone(arg);
21879         int64_t ret_ref = tag_ptr(ret_copy, true);
21880         return ret_ref;
21881 }
21882 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1TypeZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21883         LDKCOption_TypeZ* arg_conv = (LDKCOption_TypeZ*)untag_ptr(arg);
21884         int64_t ret_conv = COption_TypeZ_clone_ptr(arg_conv);
21885         return ret_conv;
21886 }
21887
21888 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1TypeZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21889         LDKCOption_TypeZ* orig_conv = (LDKCOption_TypeZ*)untag_ptr(orig);
21890         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
21891         *ret_copy = COption_TypeZ_clone(orig_conv);
21892         int64_t ret_ref = tag_ptr(ret_copy, true);
21893         return ret_ref;
21894 }
21895
21896 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
21897         void* o_ptr = untag_ptr(o);
21898         CHECK_ACCESS(o_ptr);
21899         LDKCOption_TypeZ o_conv = *(LDKCOption_TypeZ*)(o_ptr);
21900         o_conv = COption_TypeZ_clone((LDKCOption_TypeZ*)untag_ptr(o));
21901         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
21902         *ret_conv = CResult_COption_TypeZDecodeErrorZ_ok(o_conv);
21903         return tag_ptr(ret_conv, true);
21904 }
21905
21906 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21907         void* e_ptr = untag_ptr(e);
21908         CHECK_ACCESS(e_ptr);
21909         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
21910         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
21911         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
21912         *ret_conv = CResult_COption_TypeZDecodeErrorZ_err(e_conv);
21913         return tag_ptr(ret_conv, true);
21914 }
21915
21916 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21917         LDKCResult_COption_TypeZDecodeErrorZ* o_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)untag_ptr(o);
21918         jboolean ret_conv = CResult_COption_TypeZDecodeErrorZ_is_ok(o_conv);
21919         return ret_conv;
21920 }
21921
21922 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21923         if (!ptr_is_owned(_res)) return;
21924         void* _res_ptr = untag_ptr(_res);
21925         CHECK_ACCESS(_res_ptr);
21926         LDKCResult_COption_TypeZDecodeErrorZ _res_conv = *(LDKCResult_COption_TypeZDecodeErrorZ*)(_res_ptr);
21927         FREE(untag_ptr(_res));
21928         CResult_COption_TypeZDecodeErrorZ_free(_res_conv);
21929 }
21930
21931 static inline uint64_t CResult_COption_TypeZDecodeErrorZ_clone_ptr(LDKCResult_COption_TypeZDecodeErrorZ *NONNULL_PTR arg) {
21932         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
21933         *ret_conv = CResult_COption_TypeZDecodeErrorZ_clone(arg);
21934         return tag_ptr(ret_conv, true);
21935 }
21936 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21937         LDKCResult_COption_TypeZDecodeErrorZ* arg_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)untag_ptr(arg);
21938         int64_t ret_conv = CResult_COption_TypeZDecodeErrorZ_clone_ptr(arg_conv);
21939         return ret_conv;
21940 }
21941
21942 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21943         LDKCResult_COption_TypeZDecodeErrorZ* orig_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)untag_ptr(orig);
21944         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
21945         *ret_conv = CResult_COption_TypeZDecodeErrorZ_clone(orig_conv);
21946         return tag_ptr(ret_conv, true);
21947 }
21948
21949 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
21950         LDKThirtyTwoBytes o_ref;
21951         CHECK((*env)->GetArrayLength(env, o) == 32);
21952         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.data);
21953         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
21954         *ret_conv = CResult_PaymentIdPaymentErrorZ_ok(o_ref);
21955         return tag_ptr(ret_conv, true);
21956 }
21957
21958 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
21959         void* e_ptr = untag_ptr(e);
21960         CHECK_ACCESS(e_ptr);
21961         LDKPaymentError e_conv = *(LDKPaymentError*)(e_ptr);
21962         e_conv = PaymentError_clone((LDKPaymentError*)untag_ptr(e));
21963         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
21964         *ret_conv = CResult_PaymentIdPaymentErrorZ_err(e_conv);
21965         return tag_ptr(ret_conv, true);
21966 }
21967
21968 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
21969         LDKCResult_PaymentIdPaymentErrorZ* o_conv = (LDKCResult_PaymentIdPaymentErrorZ*)untag_ptr(o);
21970         jboolean ret_conv = CResult_PaymentIdPaymentErrorZ_is_ok(o_conv);
21971         return ret_conv;
21972 }
21973
21974 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
21975         if (!ptr_is_owned(_res)) return;
21976         void* _res_ptr = untag_ptr(_res);
21977         CHECK_ACCESS(_res_ptr);
21978         LDKCResult_PaymentIdPaymentErrorZ _res_conv = *(LDKCResult_PaymentIdPaymentErrorZ*)(_res_ptr);
21979         FREE(untag_ptr(_res));
21980         CResult_PaymentIdPaymentErrorZ_free(_res_conv);
21981 }
21982
21983 static inline uint64_t CResult_PaymentIdPaymentErrorZ_clone_ptr(LDKCResult_PaymentIdPaymentErrorZ *NONNULL_PTR arg) {
21984         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
21985         *ret_conv = CResult_PaymentIdPaymentErrorZ_clone(arg);
21986         return tag_ptr(ret_conv, true);
21987 }
21988 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21989         LDKCResult_PaymentIdPaymentErrorZ* arg_conv = (LDKCResult_PaymentIdPaymentErrorZ*)untag_ptr(arg);
21990         int64_t ret_conv = CResult_PaymentIdPaymentErrorZ_clone_ptr(arg_conv);
21991         return ret_conv;
21992 }
21993
21994 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21995         LDKCResult_PaymentIdPaymentErrorZ* orig_conv = (LDKCResult_PaymentIdPaymentErrorZ*)untag_ptr(orig);
21996         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
21997         *ret_conv = CResult_PaymentIdPaymentErrorZ_clone(orig_conv);
21998         return tag_ptr(ret_conv, true);
21999 }
22000
22001 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentErrorZ_1ok(JNIEnv *env, jclass clz) {
22002         LDKCResult_NonePaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentErrorZ), "LDKCResult_NonePaymentErrorZ");
22003         *ret_conv = CResult_NonePaymentErrorZ_ok();
22004         return tag_ptr(ret_conv, true);
22005 }
22006
22007 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22008         void* e_ptr = untag_ptr(e);
22009         CHECK_ACCESS(e_ptr);
22010         LDKPaymentError e_conv = *(LDKPaymentError*)(e_ptr);
22011         e_conv = PaymentError_clone((LDKPaymentError*)untag_ptr(e));
22012         LDKCResult_NonePaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentErrorZ), "LDKCResult_NonePaymentErrorZ");
22013         *ret_conv = CResult_NonePaymentErrorZ_err(e_conv);
22014         return tag_ptr(ret_conv, true);
22015 }
22016
22017 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22018         LDKCResult_NonePaymentErrorZ* o_conv = (LDKCResult_NonePaymentErrorZ*)untag_ptr(o);
22019         jboolean ret_conv = CResult_NonePaymentErrorZ_is_ok(o_conv);
22020         return ret_conv;
22021 }
22022
22023 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22024         if (!ptr_is_owned(_res)) return;
22025         void* _res_ptr = untag_ptr(_res);
22026         CHECK_ACCESS(_res_ptr);
22027         LDKCResult_NonePaymentErrorZ _res_conv = *(LDKCResult_NonePaymentErrorZ*)(_res_ptr);
22028         FREE(untag_ptr(_res));
22029         CResult_NonePaymentErrorZ_free(_res_conv);
22030 }
22031
22032 static inline uint64_t CResult_NonePaymentErrorZ_clone_ptr(LDKCResult_NonePaymentErrorZ *NONNULL_PTR arg) {
22033         LDKCResult_NonePaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentErrorZ), "LDKCResult_NonePaymentErrorZ");
22034         *ret_conv = CResult_NonePaymentErrorZ_clone(arg);
22035         return tag_ptr(ret_conv, true);
22036 }
22037 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22038         LDKCResult_NonePaymentErrorZ* arg_conv = (LDKCResult_NonePaymentErrorZ*)untag_ptr(arg);
22039         int64_t ret_conv = CResult_NonePaymentErrorZ_clone_ptr(arg_conv);
22040         return ret_conv;
22041 }
22042
22043 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22044         LDKCResult_NonePaymentErrorZ* orig_conv = (LDKCResult_NonePaymentErrorZ*)untag_ptr(orig);
22045         LDKCResult_NonePaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentErrorZ), "LDKCResult_NonePaymentErrorZ");
22046         *ret_conv = CResult_NonePaymentErrorZ_clone(orig_conv);
22047         return tag_ptr(ret_conv, true);
22048 }
22049
22050 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1ok(JNIEnv *env, jclass clz, jstring o) {
22051         LDKStr o_conv = java_to_owned_str(env, o);
22052         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
22053         *ret_conv = CResult_StringErrorZ_ok(o_conv);
22054         return tag_ptr(ret_conv, true);
22055 }
22056
22057 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
22058         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_java(env, e);
22059         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
22060         *ret_conv = CResult_StringErrorZ_err(e_conv);
22061         return tag_ptr(ret_conv, true);
22062 }
22063
22064 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22065         LDKCResult_StringErrorZ* o_conv = (LDKCResult_StringErrorZ*)untag_ptr(o);
22066         jboolean ret_conv = CResult_StringErrorZ_is_ok(o_conv);
22067         return ret_conv;
22068 }
22069
22070 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22071         if (!ptr_is_owned(_res)) return;
22072         void* _res_ptr = untag_ptr(_res);
22073         CHECK_ACCESS(_res_ptr);
22074         LDKCResult_StringErrorZ _res_conv = *(LDKCResult_StringErrorZ*)(_res_ptr);
22075         FREE(untag_ptr(_res));
22076         CResult_StringErrorZ_free(_res_conv);
22077 }
22078
22079 static inline uint64_t CResult_StringErrorZ_clone_ptr(LDKCResult_StringErrorZ *NONNULL_PTR arg) {
22080         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
22081         *ret_conv = CResult_StringErrorZ_clone(arg);
22082         return tag_ptr(ret_conv, true);
22083 }
22084 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22085         LDKCResult_StringErrorZ* arg_conv = (LDKCResult_StringErrorZ*)untag_ptr(arg);
22086         int64_t ret_conv = CResult_StringErrorZ_clone_ptr(arg_conv);
22087         return ret_conv;
22088 }
22089
22090 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22091         LDKCResult_StringErrorZ* orig_conv = (LDKCResult_StringErrorZ*)untag_ptr(orig);
22092         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
22093         *ret_conv = CResult_StringErrorZ_clone(orig_conv);
22094         return tag_ptr(ret_conv, true);
22095 }
22096
22097 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
22098         LDKPublicKey o_ref;
22099         CHECK((*env)->GetArrayLength(env, o) == 33);
22100         (*env)->GetByteArrayRegion(env, o, 0, 33, o_ref.compressed_form);
22101         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
22102         *ret_conv = CResult_PublicKeyErrorZ_ok(o_ref);
22103         return tag_ptr(ret_conv, true);
22104 }
22105
22106 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
22107         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_java(env, e);
22108         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
22109         *ret_conv = CResult_PublicKeyErrorZ_err(e_conv);
22110         return tag_ptr(ret_conv, true);
22111 }
22112
22113 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22114         LDKCResult_PublicKeyErrorZ* o_conv = (LDKCResult_PublicKeyErrorZ*)untag_ptr(o);
22115         jboolean ret_conv = CResult_PublicKeyErrorZ_is_ok(o_conv);
22116         return ret_conv;
22117 }
22118
22119 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22120         if (!ptr_is_owned(_res)) return;
22121         void* _res_ptr = untag_ptr(_res);
22122         CHECK_ACCESS(_res_ptr);
22123         LDKCResult_PublicKeyErrorZ _res_conv = *(LDKCResult_PublicKeyErrorZ*)(_res_ptr);
22124         FREE(untag_ptr(_res));
22125         CResult_PublicKeyErrorZ_free(_res_conv);
22126 }
22127
22128 static inline uint64_t CResult_PublicKeyErrorZ_clone_ptr(LDKCResult_PublicKeyErrorZ *NONNULL_PTR arg) {
22129         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
22130         *ret_conv = CResult_PublicKeyErrorZ_clone(arg);
22131         return tag_ptr(ret_conv, true);
22132 }
22133 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22134         LDKCResult_PublicKeyErrorZ* arg_conv = (LDKCResult_PublicKeyErrorZ*)untag_ptr(arg);
22135         int64_t ret_conv = CResult_PublicKeyErrorZ_clone_ptr(arg_conv);
22136         return ret_conv;
22137 }
22138
22139 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22140         LDKCResult_PublicKeyErrorZ* orig_conv = (LDKCResult_PublicKeyErrorZ*)untag_ptr(orig);
22141         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
22142         *ret_conv = CResult_PublicKeyErrorZ_clone(orig_conv);
22143         return tag_ptr(ret_conv, true);
22144 }
22145
22146 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22147         LDKChannelMonitorUpdate o_conv;
22148         o_conv.inner = untag_ptr(o);
22149         o_conv.is_owned = ptr_is_owned(o);
22150         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22151         o_conv = ChannelMonitorUpdate_clone(&o_conv);
22152         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
22153         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_ok(o_conv);
22154         return tag_ptr(ret_conv, true);
22155 }
22156
22157 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22158         void* e_ptr = untag_ptr(e);
22159         CHECK_ACCESS(e_ptr);
22160         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
22161         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
22162         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
22163         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_err(e_conv);
22164         return tag_ptr(ret_conv, true);
22165 }
22166
22167 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22168         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* o_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)untag_ptr(o);
22169         jboolean ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_is_ok(o_conv);
22170         return ret_conv;
22171 }
22172
22173 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22174         if (!ptr_is_owned(_res)) return;
22175         void* _res_ptr = untag_ptr(_res);
22176         CHECK_ACCESS(_res_ptr);
22177         LDKCResult_ChannelMonitorUpdateDecodeErrorZ _res_conv = *(LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(_res_ptr);
22178         FREE(untag_ptr(_res));
22179         CResult_ChannelMonitorUpdateDecodeErrorZ_free(_res_conv);
22180 }
22181
22182 static inline uint64_t CResult_ChannelMonitorUpdateDecodeErrorZ_clone_ptr(LDKCResult_ChannelMonitorUpdateDecodeErrorZ *NONNULL_PTR arg) {
22183         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
22184         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_clone(arg);
22185         return tag_ptr(ret_conv, true);
22186 }
22187 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22188         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* arg_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)untag_ptr(arg);
22189         int64_t ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_clone_ptr(arg_conv);
22190         return ret_conv;
22191 }
22192
22193 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22194         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* orig_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)untag_ptr(orig);
22195         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
22196         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_clone(orig_conv);
22197         return tag_ptr(ret_conv, true);
22198 }
22199
22200 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1MonitorEventZ_1some(JNIEnv *env, jclass clz, int64_t o) {
22201         void* o_ptr = untag_ptr(o);
22202         CHECK_ACCESS(o_ptr);
22203         LDKMonitorEvent o_conv = *(LDKMonitorEvent*)(o_ptr);
22204         o_conv = MonitorEvent_clone((LDKMonitorEvent*)untag_ptr(o));
22205         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
22206         *ret_copy = COption_MonitorEventZ_some(o_conv);
22207         int64_t ret_ref = tag_ptr(ret_copy, true);
22208         return ret_ref;
22209 }
22210
22211 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1MonitorEventZ_1none(JNIEnv *env, jclass clz) {
22212         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
22213         *ret_copy = COption_MonitorEventZ_none();
22214         int64_t ret_ref = tag_ptr(ret_copy, true);
22215         return ret_ref;
22216 }
22217
22218 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1MonitorEventZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22219         if (!ptr_is_owned(_res)) return;
22220         void* _res_ptr = untag_ptr(_res);
22221         CHECK_ACCESS(_res_ptr);
22222         LDKCOption_MonitorEventZ _res_conv = *(LDKCOption_MonitorEventZ*)(_res_ptr);
22223         FREE(untag_ptr(_res));
22224         COption_MonitorEventZ_free(_res_conv);
22225 }
22226
22227 static inline uint64_t COption_MonitorEventZ_clone_ptr(LDKCOption_MonitorEventZ *NONNULL_PTR arg) {
22228         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
22229         *ret_copy = COption_MonitorEventZ_clone(arg);
22230         int64_t ret_ref = tag_ptr(ret_copy, true);
22231         return ret_ref;
22232 }
22233 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1MonitorEventZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22234         LDKCOption_MonitorEventZ* arg_conv = (LDKCOption_MonitorEventZ*)untag_ptr(arg);
22235         int64_t ret_conv = COption_MonitorEventZ_clone_ptr(arg_conv);
22236         return ret_conv;
22237 }
22238
22239 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1MonitorEventZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22240         LDKCOption_MonitorEventZ* orig_conv = (LDKCOption_MonitorEventZ*)untag_ptr(orig);
22241         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
22242         *ret_copy = COption_MonitorEventZ_clone(orig_conv);
22243         int64_t ret_ref = tag_ptr(ret_copy, true);
22244         return ret_ref;
22245 }
22246
22247 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1MonitorEventZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22248         void* o_ptr = untag_ptr(o);
22249         CHECK_ACCESS(o_ptr);
22250         LDKCOption_MonitorEventZ o_conv = *(LDKCOption_MonitorEventZ*)(o_ptr);
22251         o_conv = COption_MonitorEventZ_clone((LDKCOption_MonitorEventZ*)untag_ptr(o));
22252         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
22253         *ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_ok(o_conv);
22254         return tag_ptr(ret_conv, true);
22255 }
22256
22257 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1MonitorEventZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22258         void* e_ptr = untag_ptr(e);
22259         CHECK_ACCESS(e_ptr);
22260         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
22261         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
22262         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
22263         *ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_err(e_conv);
22264         return tag_ptr(ret_conv, true);
22265 }
22266
22267 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1MonitorEventZDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22268         LDKCResult_COption_MonitorEventZDecodeErrorZ* o_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)untag_ptr(o);
22269         jboolean ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_is_ok(o_conv);
22270         return ret_conv;
22271 }
22272
22273 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1MonitorEventZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22274         if (!ptr_is_owned(_res)) return;
22275         void* _res_ptr = untag_ptr(_res);
22276         CHECK_ACCESS(_res_ptr);
22277         LDKCResult_COption_MonitorEventZDecodeErrorZ _res_conv = *(LDKCResult_COption_MonitorEventZDecodeErrorZ*)(_res_ptr);
22278         FREE(untag_ptr(_res));
22279         CResult_COption_MonitorEventZDecodeErrorZ_free(_res_conv);
22280 }
22281
22282 static inline uint64_t CResult_COption_MonitorEventZDecodeErrorZ_clone_ptr(LDKCResult_COption_MonitorEventZDecodeErrorZ *NONNULL_PTR arg) {
22283         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
22284         *ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_clone(arg);
22285         return tag_ptr(ret_conv, true);
22286 }
22287 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1MonitorEventZDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22288         LDKCResult_COption_MonitorEventZDecodeErrorZ* arg_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)untag_ptr(arg);
22289         int64_t ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_clone_ptr(arg_conv);
22290         return ret_conv;
22291 }
22292
22293 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1MonitorEventZDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22294         LDKCResult_COption_MonitorEventZDecodeErrorZ* orig_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)untag_ptr(orig);
22295         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
22296         *ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_clone(orig_conv);
22297         return tag_ptr(ret_conv, true);
22298 }
22299
22300 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22301         LDKHTLCUpdate o_conv;
22302         o_conv.inner = untag_ptr(o);
22303         o_conv.is_owned = ptr_is_owned(o);
22304         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22305         o_conv = HTLCUpdate_clone(&o_conv);
22306         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
22307         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_ok(o_conv);
22308         return tag_ptr(ret_conv, true);
22309 }
22310
22311 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22312         void* e_ptr = untag_ptr(e);
22313         CHECK_ACCESS(e_ptr);
22314         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
22315         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
22316         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
22317         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_err(e_conv);
22318         return tag_ptr(ret_conv, true);
22319 }
22320
22321 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22322         LDKCResult_HTLCUpdateDecodeErrorZ* o_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)untag_ptr(o);
22323         jboolean ret_conv = CResult_HTLCUpdateDecodeErrorZ_is_ok(o_conv);
22324         return ret_conv;
22325 }
22326
22327 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22328         if (!ptr_is_owned(_res)) return;
22329         void* _res_ptr = untag_ptr(_res);
22330         CHECK_ACCESS(_res_ptr);
22331         LDKCResult_HTLCUpdateDecodeErrorZ _res_conv = *(LDKCResult_HTLCUpdateDecodeErrorZ*)(_res_ptr);
22332         FREE(untag_ptr(_res));
22333         CResult_HTLCUpdateDecodeErrorZ_free(_res_conv);
22334 }
22335
22336 static inline uint64_t CResult_HTLCUpdateDecodeErrorZ_clone_ptr(LDKCResult_HTLCUpdateDecodeErrorZ *NONNULL_PTR arg) {
22337         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
22338         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_clone(arg);
22339         return tag_ptr(ret_conv, true);
22340 }
22341 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22342         LDKCResult_HTLCUpdateDecodeErrorZ* arg_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)untag_ptr(arg);
22343         int64_t ret_conv = CResult_HTLCUpdateDecodeErrorZ_clone_ptr(arg_conv);
22344         return ret_conv;
22345 }
22346
22347 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22348         LDKCResult_HTLCUpdateDecodeErrorZ* orig_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)untag_ptr(orig);
22349         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
22350         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_clone(orig_conv);
22351         return tag_ptr(ret_conv, true);
22352 }
22353
22354 static inline uint64_t C2Tuple_OutPointScriptZ_clone_ptr(LDKC2Tuple_OutPointScriptZ *NONNULL_PTR arg) {
22355         LDKC2Tuple_OutPointScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
22356         *ret_conv = C2Tuple_OutPointScriptZ_clone(arg);
22357         return tag_ptr(ret_conv, true);
22358 }
22359 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22360         LDKC2Tuple_OutPointScriptZ* arg_conv = (LDKC2Tuple_OutPointScriptZ*)untag_ptr(arg);
22361         int64_t ret_conv = C2Tuple_OutPointScriptZ_clone_ptr(arg_conv);
22362         return ret_conv;
22363 }
22364
22365 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22366         LDKC2Tuple_OutPointScriptZ* orig_conv = (LDKC2Tuple_OutPointScriptZ*)untag_ptr(orig);
22367         LDKC2Tuple_OutPointScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
22368         *ret_conv = C2Tuple_OutPointScriptZ_clone(orig_conv);
22369         return tag_ptr(ret_conv, true);
22370 }
22371
22372 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1new(JNIEnv *env, jclass clz, int64_t a, int8_tArray b) {
22373         LDKOutPoint a_conv;
22374         a_conv.inner = untag_ptr(a);
22375         a_conv.is_owned = ptr_is_owned(a);
22376         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
22377         a_conv = OutPoint_clone(&a_conv);
22378         LDKCVec_u8Z b_ref;
22379         b_ref.datalen = (*env)->GetArrayLength(env, b);
22380         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
22381         (*env)->GetByteArrayRegion(env, b, 0, b_ref.datalen, b_ref.data);
22382         LDKC2Tuple_OutPointScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
22383         *ret_conv = C2Tuple_OutPointScriptZ_new(a_conv, b_ref);
22384         return tag_ptr(ret_conv, true);
22385 }
22386
22387 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22388         if (!ptr_is_owned(_res)) return;
22389         void* _res_ptr = untag_ptr(_res);
22390         CHECK_ACCESS(_res_ptr);
22391         LDKC2Tuple_OutPointScriptZ _res_conv = *(LDKC2Tuple_OutPointScriptZ*)(_res_ptr);
22392         FREE(untag_ptr(_res));
22393         C2Tuple_OutPointScriptZ_free(_res_conv);
22394 }
22395
22396 static inline uint64_t C2Tuple_u32ScriptZ_clone_ptr(LDKC2Tuple_u32ScriptZ *NONNULL_PTR arg) {
22397         LDKC2Tuple_u32ScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
22398         *ret_conv = C2Tuple_u32ScriptZ_clone(arg);
22399         return tag_ptr(ret_conv, true);
22400 }
22401 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32ScriptZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22402         LDKC2Tuple_u32ScriptZ* arg_conv = (LDKC2Tuple_u32ScriptZ*)untag_ptr(arg);
22403         int64_t ret_conv = C2Tuple_u32ScriptZ_clone_ptr(arg_conv);
22404         return ret_conv;
22405 }
22406
22407 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32ScriptZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22408         LDKC2Tuple_u32ScriptZ* orig_conv = (LDKC2Tuple_u32ScriptZ*)untag_ptr(orig);
22409         LDKC2Tuple_u32ScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
22410         *ret_conv = C2Tuple_u32ScriptZ_clone(orig_conv);
22411         return tag_ptr(ret_conv, true);
22412 }
22413
22414 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32ScriptZ_1new(JNIEnv *env, jclass clz, int32_t a, int8_tArray b) {
22415         LDKCVec_u8Z b_ref;
22416         b_ref.datalen = (*env)->GetArrayLength(env, b);
22417         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
22418         (*env)->GetByteArrayRegion(env, b, 0, b_ref.datalen, b_ref.data);
22419         LDKC2Tuple_u32ScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
22420         *ret_conv = C2Tuple_u32ScriptZ_new(a, b_ref);
22421         return tag_ptr(ret_conv, true);
22422 }
22423
22424 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32ScriptZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22425         if (!ptr_is_owned(_res)) return;
22426         void* _res_ptr = untag_ptr(_res);
22427         CHECK_ACCESS(_res_ptr);
22428         LDKC2Tuple_u32ScriptZ _res_conv = *(LDKC2Tuple_u32ScriptZ*)(_res_ptr);
22429         FREE(untag_ptr(_res));
22430         C2Tuple_u32ScriptZ_free(_res_conv);
22431 }
22432
22433 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1u32ScriptZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
22434         LDKCVec_C2Tuple_u32ScriptZZ _res_constr;
22435         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
22436         if (_res_constr.datalen > 0)
22437                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_u32ScriptZ), "LDKCVec_C2Tuple_u32ScriptZZ Elements");
22438         else
22439                 _res_constr.data = NULL;
22440         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
22441         for (size_t v = 0; v < _res_constr.datalen; v++) {
22442                 int64_t _res_conv_21 = _res_vals[v];
22443                 void* _res_conv_21_ptr = untag_ptr(_res_conv_21);
22444                 CHECK_ACCESS(_res_conv_21_ptr);
22445                 LDKC2Tuple_u32ScriptZ _res_conv_21_conv = *(LDKC2Tuple_u32ScriptZ*)(_res_conv_21_ptr);
22446                 FREE(untag_ptr(_res_conv_21));
22447                 _res_constr.data[v] = _res_conv_21_conv;
22448         }
22449         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
22450         CVec_C2Tuple_u32ScriptZZ_free(_res_constr);
22451 }
22452
22453 static inline uint64_t C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone_ptr(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ *NONNULL_PTR arg) {
22454         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
22455         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone(arg);
22456         return tag_ptr(ret_conv, true);
22457 }
22458 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22459         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* arg_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)untag_ptr(arg);
22460         int64_t ret_conv = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone_ptr(arg_conv);
22461         return ret_conv;
22462 }
22463
22464 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22465         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* orig_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)untag_ptr(orig);
22466         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
22467         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone(orig_conv);
22468         return tag_ptr(ret_conv, true);
22469 }
22470
22471 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_tArray b) {
22472         LDKThirtyTwoBytes a_ref;
22473         CHECK((*env)->GetArrayLength(env, a) == 32);
22474         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
22475         LDKCVec_C2Tuple_u32ScriptZZ b_constr;
22476         b_constr.datalen = (*env)->GetArrayLength(env, b);
22477         if (b_constr.datalen > 0)
22478                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32ScriptZ), "LDKCVec_C2Tuple_u32ScriptZZ Elements");
22479         else
22480                 b_constr.data = NULL;
22481         int64_t* b_vals = (*env)->GetLongArrayElements (env, b, NULL);
22482         for (size_t v = 0; v < b_constr.datalen; v++) {
22483                 int64_t b_conv_21 = b_vals[v];
22484                 void* b_conv_21_ptr = untag_ptr(b_conv_21);
22485                 CHECK_ACCESS(b_conv_21_ptr);
22486                 LDKC2Tuple_u32ScriptZ b_conv_21_conv = *(LDKC2Tuple_u32ScriptZ*)(b_conv_21_ptr);
22487                 b_conv_21_conv = C2Tuple_u32ScriptZ_clone((LDKC2Tuple_u32ScriptZ*)untag_ptr(b_conv_21));
22488                 b_constr.data[v] = b_conv_21_conv;
22489         }
22490         (*env)->ReleaseLongArrayElements(env, b, b_vals, 0);
22491         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
22492         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_new(a_ref, b_constr);
22493         return tag_ptr(ret_conv, true);
22494 }
22495
22496 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22497         if (!ptr_is_owned(_res)) return;
22498         void* _res_ptr = untag_ptr(_res);
22499         CHECK_ACCESS(_res_ptr);
22500         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ _res_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(_res_ptr);
22501         FREE(untag_ptr(_res));
22502         C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_free(_res_conv);
22503 }
22504
22505 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
22506         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ _res_constr;
22507         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
22508         if (_res_constr.datalen > 0)
22509                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ Elements");
22510         else
22511                 _res_constr.data = NULL;
22512         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
22513         for (size_t o = 0; o < _res_constr.datalen; o++) {
22514                 int64_t _res_conv_40 = _res_vals[o];
22515                 void* _res_conv_40_ptr = untag_ptr(_res_conv_40);
22516                 CHECK_ACCESS(_res_conv_40_ptr);
22517                 LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ _res_conv_40_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(_res_conv_40_ptr);
22518                 FREE(untag_ptr(_res_conv_40));
22519                 _res_constr.data[o] = _res_conv_40_conv;
22520         }
22521         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
22522         CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ_free(_res_constr);
22523 }
22524
22525 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1EventZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
22526         LDKCVec_EventZ _res_constr;
22527         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
22528         if (_res_constr.datalen > 0)
22529                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKEvent), "LDKCVec_EventZ Elements");
22530         else
22531                 _res_constr.data = NULL;
22532         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
22533         for (size_t h = 0; h < _res_constr.datalen; h++) {
22534                 int64_t _res_conv_7 = _res_vals[h];
22535                 void* _res_conv_7_ptr = untag_ptr(_res_conv_7);
22536                 CHECK_ACCESS(_res_conv_7_ptr);
22537                 LDKEvent _res_conv_7_conv = *(LDKEvent*)(_res_conv_7_ptr);
22538                 FREE(untag_ptr(_res_conv_7));
22539                 _res_constr.data[h] = _res_conv_7_conv;
22540         }
22541         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
22542         CVec_EventZ_free(_res_constr);
22543 }
22544
22545 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1TransactionZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
22546         LDKCVec_TransactionZ _res_constr;
22547         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
22548         if (_res_constr.datalen > 0)
22549                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKTransaction), "LDKCVec_TransactionZ Elements");
22550         else
22551                 _res_constr.data = NULL;
22552         for (size_t i = 0; i < _res_constr.datalen; i++) {
22553                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
22554                 LDKTransaction _res_conv_8_ref;
22555                 _res_conv_8_ref.datalen = (*env)->GetArrayLength(env, _res_conv_8);
22556                 _res_conv_8_ref.data = MALLOC(_res_conv_8_ref.datalen, "LDKTransaction Bytes");
22557                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, _res_conv_8_ref.datalen, _res_conv_8_ref.data);
22558                 _res_conv_8_ref.data_is_owned = true;
22559                 _res_constr.data[i] = _res_conv_8_ref;
22560         }
22561         CVec_TransactionZ_free(_res_constr);
22562 }
22563
22564 static inline uint64_t C2Tuple_u32TxOutZ_clone_ptr(LDKC2Tuple_u32TxOutZ *NONNULL_PTR arg) {
22565         LDKC2Tuple_u32TxOutZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
22566         *ret_conv = C2Tuple_u32TxOutZ_clone(arg);
22567         return tag_ptr(ret_conv, true);
22568 }
22569 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22570         LDKC2Tuple_u32TxOutZ* arg_conv = (LDKC2Tuple_u32TxOutZ*)untag_ptr(arg);
22571         int64_t ret_conv = C2Tuple_u32TxOutZ_clone_ptr(arg_conv);
22572         return ret_conv;
22573 }
22574
22575 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22576         LDKC2Tuple_u32TxOutZ* orig_conv = (LDKC2Tuple_u32TxOutZ*)untag_ptr(orig);
22577         LDKC2Tuple_u32TxOutZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
22578         *ret_conv = C2Tuple_u32TxOutZ_clone(orig_conv);
22579         return tag_ptr(ret_conv, true);
22580 }
22581
22582 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1new(JNIEnv *env, jclass clz, int32_t a, int64_t b) {
22583         void* b_ptr = untag_ptr(b);
22584         CHECK_ACCESS(b_ptr);
22585         LDKTxOut b_conv = *(LDKTxOut*)(b_ptr);
22586         b_conv = TxOut_clone((LDKTxOut*)untag_ptr(b));
22587         LDKC2Tuple_u32TxOutZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
22588         *ret_conv = C2Tuple_u32TxOutZ_new(a, b_conv);
22589         return tag_ptr(ret_conv, true);
22590 }
22591
22592 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22593         if (!ptr_is_owned(_res)) return;
22594         void* _res_ptr = untag_ptr(_res);
22595         CHECK_ACCESS(_res_ptr);
22596         LDKC2Tuple_u32TxOutZ _res_conv = *(LDKC2Tuple_u32TxOutZ*)(_res_ptr);
22597         FREE(untag_ptr(_res));
22598         C2Tuple_u32TxOutZ_free(_res_conv);
22599 }
22600
22601 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1u32TxOutZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
22602         LDKCVec_C2Tuple_u32TxOutZZ _res_constr;
22603         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
22604         if (_res_constr.datalen > 0)
22605                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_u32TxOutZ), "LDKCVec_C2Tuple_u32TxOutZZ Elements");
22606         else
22607                 _res_constr.data = NULL;
22608         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
22609         for (size_t u = 0; u < _res_constr.datalen; u++) {
22610                 int64_t _res_conv_20 = _res_vals[u];
22611                 void* _res_conv_20_ptr = untag_ptr(_res_conv_20);
22612                 CHECK_ACCESS(_res_conv_20_ptr);
22613                 LDKC2Tuple_u32TxOutZ _res_conv_20_conv = *(LDKC2Tuple_u32TxOutZ*)(_res_conv_20_ptr);
22614                 FREE(untag_ptr(_res_conv_20));
22615                 _res_constr.data[u] = _res_conv_20_conv;
22616         }
22617         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
22618         CVec_C2Tuple_u32TxOutZZ_free(_res_constr);
22619 }
22620
22621 static inline uint64_t C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone_ptr(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *NONNULL_PTR arg) {
22622         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
22623         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(arg);
22624         return tag_ptr(ret_conv, true);
22625 }
22626 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22627         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* arg_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)untag_ptr(arg);
22628         int64_t ret_conv = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone_ptr(arg_conv);
22629         return ret_conv;
22630 }
22631
22632 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22633         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* orig_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)untag_ptr(orig);
22634         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
22635         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(orig_conv);
22636         return tag_ptr(ret_conv, true);
22637 }
22638
22639 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_tArray b) {
22640         LDKThirtyTwoBytes a_ref;
22641         CHECK((*env)->GetArrayLength(env, a) == 32);
22642         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
22643         LDKCVec_C2Tuple_u32TxOutZZ b_constr;
22644         b_constr.datalen = (*env)->GetArrayLength(env, b);
22645         if (b_constr.datalen > 0)
22646                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32TxOutZ), "LDKCVec_C2Tuple_u32TxOutZZ Elements");
22647         else
22648                 b_constr.data = NULL;
22649         int64_t* b_vals = (*env)->GetLongArrayElements (env, b, NULL);
22650         for (size_t u = 0; u < b_constr.datalen; u++) {
22651                 int64_t b_conv_20 = b_vals[u];
22652                 void* b_conv_20_ptr = untag_ptr(b_conv_20);
22653                 CHECK_ACCESS(b_conv_20_ptr);
22654                 LDKC2Tuple_u32TxOutZ b_conv_20_conv = *(LDKC2Tuple_u32TxOutZ*)(b_conv_20_ptr);
22655                 b_conv_20_conv = C2Tuple_u32TxOutZ_clone((LDKC2Tuple_u32TxOutZ*)untag_ptr(b_conv_20));
22656                 b_constr.data[u] = b_conv_20_conv;
22657         }
22658         (*env)->ReleaseLongArrayElements(env, b, b_vals, 0);
22659         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
22660         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_new(a_ref, b_constr);
22661         return tag_ptr(ret_conv, true);
22662 }
22663
22664 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22665         if (!ptr_is_owned(_res)) return;
22666         void* _res_ptr = untag_ptr(_res);
22667         CHECK_ACCESS(_res_ptr);
22668         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ _res_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(_res_ptr);
22669         FREE(untag_ptr(_res));
22670         C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_free(_res_conv);
22671 }
22672
22673 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
22674         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ _res_constr;
22675         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
22676         if (_res_constr.datalen > 0)
22677                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ Elements");
22678         else
22679                 _res_constr.data = NULL;
22680         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
22681         for (size_t n = 0; n < _res_constr.datalen; n++) {
22682                 int64_t _res_conv_39 = _res_vals[n];
22683                 void* _res_conv_39_ptr = untag_ptr(_res_conv_39);
22684                 CHECK_ACCESS(_res_conv_39_ptr);
22685                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ _res_conv_39_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(_res_conv_39_ptr);
22686                 FREE(untag_ptr(_res_conv_39));
22687                 _res_constr.data[n] = _res_conv_39_conv;
22688         }
22689         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
22690         CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_free(_res_constr);
22691 }
22692
22693 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1BalanceZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
22694         LDKCVec_BalanceZ _res_constr;
22695         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
22696         if (_res_constr.datalen > 0)
22697                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKBalance), "LDKCVec_BalanceZ Elements");
22698         else
22699                 _res_constr.data = NULL;
22700         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
22701         for (size_t j = 0; j < _res_constr.datalen; j++) {
22702                 int64_t _res_conv_9 = _res_vals[j];
22703                 void* _res_conv_9_ptr = untag_ptr(_res_conv_9);
22704                 CHECK_ACCESS(_res_conv_9_ptr);
22705                 LDKBalance _res_conv_9_conv = *(LDKBalance*)(_res_conv_9_ptr);
22706                 FREE(untag_ptr(_res_conv_9));
22707                 _res_constr.data[j] = _res_conv_9_conv;
22708         }
22709         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
22710         CVec_BalanceZ_free(_res_constr);
22711 }
22712
22713 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22714         void* o_ptr = untag_ptr(o);
22715         CHECK_ACCESS(o_ptr);
22716         LDKC2Tuple_BlockHashChannelMonitorZ o_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(o_ptr);
22717         o_conv = C2Tuple_BlockHashChannelMonitorZ_clone((LDKC2Tuple_BlockHashChannelMonitorZ*)untag_ptr(o));
22718         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
22719         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_ok(o_conv);
22720         return tag_ptr(ret_conv, true);
22721 }
22722
22723 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22724         void* e_ptr = untag_ptr(e);
22725         CHECK_ACCESS(e_ptr);
22726         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
22727         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
22728         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
22729         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_err(e_conv);
22730         return tag_ptr(ret_conv, true);
22731 }
22732
22733 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22734         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* o_conv = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)untag_ptr(o);
22735         jboolean ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_is_ok(o_conv);
22736         return ret_conv;
22737 }
22738
22739 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22740         if (!ptr_is_owned(_res)) return;
22741         void* _res_ptr = untag_ptr(_res);
22742         CHECK_ACCESS(_res_ptr);
22743         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ _res_conv = *(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(_res_ptr);
22744         FREE(untag_ptr(_res));
22745         CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_free(_res_conv);
22746 }
22747
22748 static inline uint64_t CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone_ptr(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *NONNULL_PTR arg) {
22749         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
22750         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone(arg);
22751         return tag_ptr(ret_conv, true);
22752 }
22753 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22754         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* arg_conv = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)untag_ptr(arg);
22755         int64_t ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone_ptr(arg_conv);
22756         return ret_conv;
22757 }
22758
22759 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22760         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* orig_conv = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)untag_ptr(orig);
22761         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
22762         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone(orig_conv);
22763         return tag_ptr(ret_conv, true);
22764 }
22765
22766 static inline uint64_t C2Tuple_PublicKeyTypeZ_clone_ptr(LDKC2Tuple_PublicKeyTypeZ *NONNULL_PTR arg) {
22767         LDKC2Tuple_PublicKeyTypeZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ");
22768         *ret_conv = C2Tuple_PublicKeyTypeZ_clone(arg);
22769         return tag_ptr(ret_conv, true);
22770 }
22771 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PublicKeyTypeZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22772         LDKC2Tuple_PublicKeyTypeZ* arg_conv = (LDKC2Tuple_PublicKeyTypeZ*)untag_ptr(arg);
22773         int64_t ret_conv = C2Tuple_PublicKeyTypeZ_clone_ptr(arg_conv);
22774         return ret_conv;
22775 }
22776
22777 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PublicKeyTypeZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22778         LDKC2Tuple_PublicKeyTypeZ* orig_conv = (LDKC2Tuple_PublicKeyTypeZ*)untag_ptr(orig);
22779         LDKC2Tuple_PublicKeyTypeZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ");
22780         *ret_conv = C2Tuple_PublicKeyTypeZ_clone(orig_conv);
22781         return tag_ptr(ret_conv, true);
22782 }
22783
22784 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PublicKeyTypeZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_t b) {
22785         LDKPublicKey a_ref;
22786         CHECK((*env)->GetArrayLength(env, a) == 33);
22787         (*env)->GetByteArrayRegion(env, a, 0, 33, a_ref.compressed_form);
22788         void* b_ptr = untag_ptr(b);
22789         CHECK_ACCESS(b_ptr);
22790         LDKType b_conv = *(LDKType*)(b_ptr);
22791         if (b_conv.free == LDKType_JCalls_free) {
22792                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
22793                 LDKType_JCalls_cloned(&b_conv);
22794         }
22795         LDKC2Tuple_PublicKeyTypeZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ");
22796         *ret_conv = C2Tuple_PublicKeyTypeZ_new(a_ref, b_conv);
22797         return tag_ptr(ret_conv, true);
22798 }
22799
22800 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PublicKeyTypeZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22801         if (!ptr_is_owned(_res)) return;
22802         void* _res_ptr = untag_ptr(_res);
22803         CHECK_ACCESS(_res_ptr);
22804         LDKC2Tuple_PublicKeyTypeZ _res_conv = *(LDKC2Tuple_PublicKeyTypeZ*)(_res_ptr);
22805         FREE(untag_ptr(_res));
22806         C2Tuple_PublicKeyTypeZ_free(_res_conv);
22807 }
22808
22809 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1PublicKeyTypeZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
22810         LDKCVec_C2Tuple_PublicKeyTypeZZ _res_constr;
22811         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
22812         if (_res_constr.datalen > 0)
22813                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKCVec_C2Tuple_PublicKeyTypeZZ Elements");
22814         else
22815                 _res_constr.data = NULL;
22816         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
22817         for (size_t z = 0; z < _res_constr.datalen; z++) {
22818                 int64_t _res_conv_25 = _res_vals[z];
22819                 void* _res_conv_25_ptr = untag_ptr(_res_conv_25);
22820                 CHECK_ACCESS(_res_conv_25_ptr);
22821                 LDKC2Tuple_PublicKeyTypeZ _res_conv_25_conv = *(LDKC2Tuple_PublicKeyTypeZ*)(_res_conv_25_ptr);
22822                 FREE(untag_ptr(_res_conv_25));
22823                 _res_constr.data[z] = _res_conv_25_conv;
22824         }
22825         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
22826         CVec_C2Tuple_PublicKeyTypeZZ_free(_res_constr);
22827 }
22828
22829 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1CustomOnionMessageContentsZ_1some(JNIEnv *env, jclass clz, int64_t o) {
22830         void* o_ptr = untag_ptr(o);
22831         CHECK_ACCESS(o_ptr);
22832         LDKCustomOnionMessageContents o_conv = *(LDKCustomOnionMessageContents*)(o_ptr);
22833         if (o_conv.free == LDKCustomOnionMessageContents_JCalls_free) {
22834                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
22835                 LDKCustomOnionMessageContents_JCalls_cloned(&o_conv);
22836         }
22837         LDKCOption_CustomOnionMessageContentsZ *ret_copy = MALLOC(sizeof(LDKCOption_CustomOnionMessageContentsZ), "LDKCOption_CustomOnionMessageContentsZ");
22838         *ret_copy = COption_CustomOnionMessageContentsZ_some(o_conv);
22839         int64_t ret_ref = tag_ptr(ret_copy, true);
22840         return ret_ref;
22841 }
22842
22843 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1CustomOnionMessageContentsZ_1none(JNIEnv *env, jclass clz) {
22844         LDKCOption_CustomOnionMessageContentsZ *ret_copy = MALLOC(sizeof(LDKCOption_CustomOnionMessageContentsZ), "LDKCOption_CustomOnionMessageContentsZ");
22845         *ret_copy = COption_CustomOnionMessageContentsZ_none();
22846         int64_t ret_ref = tag_ptr(ret_copy, true);
22847         return ret_ref;
22848 }
22849
22850 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1CustomOnionMessageContentsZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22851         if (!ptr_is_owned(_res)) return;
22852         void* _res_ptr = untag_ptr(_res);
22853         CHECK_ACCESS(_res_ptr);
22854         LDKCOption_CustomOnionMessageContentsZ _res_conv = *(LDKCOption_CustomOnionMessageContentsZ*)(_res_ptr);
22855         FREE(untag_ptr(_res));
22856         COption_CustomOnionMessageContentsZ_free(_res_conv);
22857 }
22858
22859 static inline uint64_t COption_CustomOnionMessageContentsZ_clone_ptr(LDKCOption_CustomOnionMessageContentsZ *NONNULL_PTR arg) {
22860         LDKCOption_CustomOnionMessageContentsZ *ret_copy = MALLOC(sizeof(LDKCOption_CustomOnionMessageContentsZ), "LDKCOption_CustomOnionMessageContentsZ");
22861         *ret_copy = COption_CustomOnionMessageContentsZ_clone(arg);
22862         int64_t ret_ref = tag_ptr(ret_copy, true);
22863         return ret_ref;
22864 }
22865 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1CustomOnionMessageContentsZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22866         LDKCOption_CustomOnionMessageContentsZ* arg_conv = (LDKCOption_CustomOnionMessageContentsZ*)untag_ptr(arg);
22867         int64_t ret_conv = COption_CustomOnionMessageContentsZ_clone_ptr(arg_conv);
22868         return ret_conv;
22869 }
22870
22871 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1CustomOnionMessageContentsZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22872         LDKCOption_CustomOnionMessageContentsZ* orig_conv = (LDKCOption_CustomOnionMessageContentsZ*)untag_ptr(orig);
22873         LDKCOption_CustomOnionMessageContentsZ *ret_copy = MALLOC(sizeof(LDKCOption_CustomOnionMessageContentsZ), "LDKCOption_CustomOnionMessageContentsZ");
22874         *ret_copy = COption_CustomOnionMessageContentsZ_clone(orig_conv);
22875         int64_t ret_ref = tag_ptr(ret_copy, true);
22876         return ret_ref;
22877 }
22878
22879 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1CustomOnionMessageContentsZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
22880         void* o_ptr = untag_ptr(o);
22881         CHECK_ACCESS(o_ptr);
22882         LDKCOption_CustomOnionMessageContentsZ o_conv = *(LDKCOption_CustomOnionMessageContentsZ*)(o_ptr);
22883         o_conv = COption_CustomOnionMessageContentsZ_clone((LDKCOption_CustomOnionMessageContentsZ*)untag_ptr(o));
22884         LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ), "LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ");
22885         *ret_conv = CResult_COption_CustomOnionMessageContentsZDecodeErrorZ_ok(o_conv);
22886         return tag_ptr(ret_conv, true);
22887 }
22888
22889 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1CustomOnionMessageContentsZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22890         void* e_ptr = untag_ptr(e);
22891         CHECK_ACCESS(e_ptr);
22892         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
22893         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
22894         LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ), "LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ");
22895         *ret_conv = CResult_COption_CustomOnionMessageContentsZDecodeErrorZ_err(e_conv);
22896         return tag_ptr(ret_conv, true);
22897 }
22898
22899 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1CustomOnionMessageContentsZDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
22900         LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ* o_conv = (LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ*)untag_ptr(o);
22901         jboolean ret_conv = CResult_COption_CustomOnionMessageContentsZDecodeErrorZ_is_ok(o_conv);
22902         return ret_conv;
22903 }
22904
22905 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1CustomOnionMessageContentsZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22906         if (!ptr_is_owned(_res)) return;
22907         void* _res_ptr = untag_ptr(_res);
22908         CHECK_ACCESS(_res_ptr);
22909         LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ _res_conv = *(LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ*)(_res_ptr);
22910         FREE(untag_ptr(_res));
22911         CResult_COption_CustomOnionMessageContentsZDecodeErrorZ_free(_res_conv);
22912 }
22913
22914 static inline uint64_t CResult_COption_CustomOnionMessageContentsZDecodeErrorZ_clone_ptr(LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ *NONNULL_PTR arg) {
22915         LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ), "LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ");
22916         *ret_conv = CResult_COption_CustomOnionMessageContentsZDecodeErrorZ_clone(arg);
22917         return tag_ptr(ret_conv, true);
22918 }
22919 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1CustomOnionMessageContentsZDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22920         LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ* arg_conv = (LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ*)untag_ptr(arg);
22921         int64_t ret_conv = CResult_COption_CustomOnionMessageContentsZDecodeErrorZ_clone_ptr(arg_conv);
22922         return ret_conv;
22923 }
22924
22925 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1CustomOnionMessageContentsZDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22926         LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ* orig_conv = (LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ*)untag_ptr(orig);
22927         LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ), "LDKCResult_COption_CustomOnionMessageContentsZDecodeErrorZ");
22928         *ret_conv = CResult_COption_CustomOnionMessageContentsZDecodeErrorZ_clone(orig_conv);
22929         return tag_ptr(ret_conv, true);
22930 }
22931
22932 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1NetAddressZ_1some(JNIEnv *env, jclass clz, int64_t o) {
22933         void* o_ptr = untag_ptr(o);
22934         CHECK_ACCESS(o_ptr);
22935         LDKNetAddress o_conv = *(LDKNetAddress*)(o_ptr);
22936         o_conv = NetAddress_clone((LDKNetAddress*)untag_ptr(o));
22937         LDKCOption_NetAddressZ *ret_copy = MALLOC(sizeof(LDKCOption_NetAddressZ), "LDKCOption_NetAddressZ");
22938         *ret_copy = COption_NetAddressZ_some(o_conv);
22939         int64_t ret_ref = tag_ptr(ret_copy, true);
22940         return ret_ref;
22941 }
22942
22943 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1NetAddressZ_1none(JNIEnv *env, jclass clz) {
22944         LDKCOption_NetAddressZ *ret_copy = MALLOC(sizeof(LDKCOption_NetAddressZ), "LDKCOption_NetAddressZ");
22945         *ret_copy = COption_NetAddressZ_none();
22946         int64_t ret_ref = tag_ptr(ret_copy, true);
22947         return ret_ref;
22948 }
22949
22950 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1NetAddressZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
22951         if (!ptr_is_owned(_res)) return;
22952         void* _res_ptr = untag_ptr(_res);
22953         CHECK_ACCESS(_res_ptr);
22954         LDKCOption_NetAddressZ _res_conv = *(LDKCOption_NetAddressZ*)(_res_ptr);
22955         FREE(untag_ptr(_res));
22956         COption_NetAddressZ_free(_res_conv);
22957 }
22958
22959 static inline uint64_t COption_NetAddressZ_clone_ptr(LDKCOption_NetAddressZ *NONNULL_PTR arg) {
22960         LDKCOption_NetAddressZ *ret_copy = MALLOC(sizeof(LDKCOption_NetAddressZ), "LDKCOption_NetAddressZ");
22961         *ret_copy = COption_NetAddressZ_clone(arg);
22962         int64_t ret_ref = tag_ptr(ret_copy, true);
22963         return ret_ref;
22964 }
22965 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1NetAddressZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22966         LDKCOption_NetAddressZ* arg_conv = (LDKCOption_NetAddressZ*)untag_ptr(arg);
22967         int64_t ret_conv = COption_NetAddressZ_clone_ptr(arg_conv);
22968         return ret_conv;
22969 }
22970
22971 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1NetAddressZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22972         LDKCOption_NetAddressZ* orig_conv = (LDKCOption_NetAddressZ*)untag_ptr(orig);
22973         LDKCOption_NetAddressZ *ret_copy = MALLOC(sizeof(LDKCOption_NetAddressZ), "LDKCOption_NetAddressZ");
22974         *ret_copy = COption_NetAddressZ_clone(orig_conv);
22975         int64_t ret_ref = tag_ptr(ret_copy, true);
22976         return ret_ref;
22977 }
22978
22979 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
22980         LDKCVec_u8Z o_ref;
22981         o_ref.datalen = (*env)->GetArrayLength(env, o);
22982         o_ref.data = MALLOC(o_ref.datalen, "LDKCVec_u8Z Bytes");
22983         (*env)->GetByteArrayRegion(env, o, 0, o_ref.datalen, o_ref.data);
22984         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
22985         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_ok(o_ref);
22986         return tag_ptr(ret_conv, true);
22987 }
22988
22989 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
22990         LDKPeerHandleError e_conv;
22991         e_conv.inner = untag_ptr(e);
22992         e_conv.is_owned = ptr_is_owned(e);
22993         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
22994         e_conv = PeerHandleError_clone(&e_conv);
22995         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
22996         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_err(e_conv);
22997         return tag_ptr(ret_conv, true);
22998 }
22999
23000 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23001         LDKCResult_CVec_u8ZPeerHandleErrorZ* o_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)untag_ptr(o);
23002         jboolean ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_is_ok(o_conv);
23003         return ret_conv;
23004 }
23005
23006 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23007         if (!ptr_is_owned(_res)) return;
23008         void* _res_ptr = untag_ptr(_res);
23009         CHECK_ACCESS(_res_ptr);
23010         LDKCResult_CVec_u8ZPeerHandleErrorZ _res_conv = *(LDKCResult_CVec_u8ZPeerHandleErrorZ*)(_res_ptr);
23011         FREE(untag_ptr(_res));
23012         CResult_CVec_u8ZPeerHandleErrorZ_free(_res_conv);
23013 }
23014
23015 static inline uint64_t CResult_CVec_u8ZPeerHandleErrorZ_clone_ptr(LDKCResult_CVec_u8ZPeerHandleErrorZ *NONNULL_PTR arg) {
23016         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
23017         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_clone(arg);
23018         return tag_ptr(ret_conv, true);
23019 }
23020 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23021         LDKCResult_CVec_u8ZPeerHandleErrorZ* arg_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)untag_ptr(arg);
23022         int64_t ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_clone_ptr(arg_conv);
23023         return ret_conv;
23024 }
23025
23026 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23027         LDKCResult_CVec_u8ZPeerHandleErrorZ* orig_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)untag_ptr(orig);
23028         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
23029         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_clone(orig_conv);
23030         return tag_ptr(ret_conv, true);
23031 }
23032
23033 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1ok(JNIEnv *env, jclass clz) {
23034         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
23035         *ret_conv = CResult_NonePeerHandleErrorZ_ok();
23036         return tag_ptr(ret_conv, true);
23037 }
23038
23039 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
23040         LDKPeerHandleError e_conv;
23041         e_conv.inner = untag_ptr(e);
23042         e_conv.is_owned = ptr_is_owned(e);
23043         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
23044         e_conv = PeerHandleError_clone(&e_conv);
23045         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
23046         *ret_conv = CResult_NonePeerHandleErrorZ_err(e_conv);
23047         return tag_ptr(ret_conv, true);
23048 }
23049
23050 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23051         LDKCResult_NonePeerHandleErrorZ* o_conv = (LDKCResult_NonePeerHandleErrorZ*)untag_ptr(o);
23052         jboolean ret_conv = CResult_NonePeerHandleErrorZ_is_ok(o_conv);
23053         return ret_conv;
23054 }
23055
23056 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23057         if (!ptr_is_owned(_res)) return;
23058         void* _res_ptr = untag_ptr(_res);
23059         CHECK_ACCESS(_res_ptr);
23060         LDKCResult_NonePeerHandleErrorZ _res_conv = *(LDKCResult_NonePeerHandleErrorZ*)(_res_ptr);
23061         FREE(untag_ptr(_res));
23062         CResult_NonePeerHandleErrorZ_free(_res_conv);
23063 }
23064
23065 static inline uint64_t CResult_NonePeerHandleErrorZ_clone_ptr(LDKCResult_NonePeerHandleErrorZ *NONNULL_PTR arg) {
23066         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
23067         *ret_conv = CResult_NonePeerHandleErrorZ_clone(arg);
23068         return tag_ptr(ret_conv, true);
23069 }
23070 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23071         LDKCResult_NonePeerHandleErrorZ* arg_conv = (LDKCResult_NonePeerHandleErrorZ*)untag_ptr(arg);
23072         int64_t ret_conv = CResult_NonePeerHandleErrorZ_clone_ptr(arg_conv);
23073         return ret_conv;
23074 }
23075
23076 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23077         LDKCResult_NonePeerHandleErrorZ* orig_conv = (LDKCResult_NonePeerHandleErrorZ*)untag_ptr(orig);
23078         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
23079         *ret_conv = CResult_NonePeerHandleErrorZ_clone(orig_conv);
23080         return tag_ptr(ret_conv, true);
23081 }
23082
23083 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1ok(JNIEnv *env, jclass clz, jboolean o) {
23084         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
23085         *ret_conv = CResult_boolPeerHandleErrorZ_ok(o);
23086         return tag_ptr(ret_conv, true);
23087 }
23088
23089 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
23090         LDKPeerHandleError e_conv;
23091         e_conv.inner = untag_ptr(e);
23092         e_conv.is_owned = ptr_is_owned(e);
23093         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
23094         e_conv = PeerHandleError_clone(&e_conv);
23095         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
23096         *ret_conv = CResult_boolPeerHandleErrorZ_err(e_conv);
23097         return tag_ptr(ret_conv, true);
23098 }
23099
23100 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23101         LDKCResult_boolPeerHandleErrorZ* o_conv = (LDKCResult_boolPeerHandleErrorZ*)untag_ptr(o);
23102         jboolean ret_conv = CResult_boolPeerHandleErrorZ_is_ok(o_conv);
23103         return ret_conv;
23104 }
23105
23106 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23107         if (!ptr_is_owned(_res)) return;
23108         void* _res_ptr = untag_ptr(_res);
23109         CHECK_ACCESS(_res_ptr);
23110         LDKCResult_boolPeerHandleErrorZ _res_conv = *(LDKCResult_boolPeerHandleErrorZ*)(_res_ptr);
23111         FREE(untag_ptr(_res));
23112         CResult_boolPeerHandleErrorZ_free(_res_conv);
23113 }
23114
23115 static inline uint64_t CResult_boolPeerHandleErrorZ_clone_ptr(LDKCResult_boolPeerHandleErrorZ *NONNULL_PTR arg) {
23116         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
23117         *ret_conv = CResult_boolPeerHandleErrorZ_clone(arg);
23118         return tag_ptr(ret_conv, true);
23119 }
23120 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23121         LDKCResult_boolPeerHandleErrorZ* arg_conv = (LDKCResult_boolPeerHandleErrorZ*)untag_ptr(arg);
23122         int64_t ret_conv = CResult_boolPeerHandleErrorZ_clone_ptr(arg_conv);
23123         return ret_conv;
23124 }
23125
23126 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23127         LDKCResult_boolPeerHandleErrorZ* orig_conv = (LDKCResult_boolPeerHandleErrorZ*)untag_ptr(orig);
23128         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
23129         *ret_conv = CResult_boolPeerHandleErrorZ_clone(orig_conv);
23130         return tag_ptr(ret_conv, true);
23131 }
23132
23133 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSendErrorZ_1ok(JNIEnv *env, jclass clz) {
23134         LDKCResult_NoneSendErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSendErrorZ), "LDKCResult_NoneSendErrorZ");
23135         *ret_conv = CResult_NoneSendErrorZ_ok();
23136         return tag_ptr(ret_conv, true);
23137 }
23138
23139 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSendErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
23140         void* e_ptr = untag_ptr(e);
23141         CHECK_ACCESS(e_ptr);
23142         LDKSendError e_conv = *(LDKSendError*)(e_ptr);
23143         e_conv = SendError_clone((LDKSendError*)untag_ptr(e));
23144         LDKCResult_NoneSendErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSendErrorZ), "LDKCResult_NoneSendErrorZ");
23145         *ret_conv = CResult_NoneSendErrorZ_err(e_conv);
23146         return tag_ptr(ret_conv, true);
23147 }
23148
23149 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSendErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23150         LDKCResult_NoneSendErrorZ* o_conv = (LDKCResult_NoneSendErrorZ*)untag_ptr(o);
23151         jboolean ret_conv = CResult_NoneSendErrorZ_is_ok(o_conv);
23152         return ret_conv;
23153 }
23154
23155 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSendErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23156         if (!ptr_is_owned(_res)) return;
23157         void* _res_ptr = untag_ptr(_res);
23158         CHECK_ACCESS(_res_ptr);
23159         LDKCResult_NoneSendErrorZ _res_conv = *(LDKCResult_NoneSendErrorZ*)(_res_ptr);
23160         FREE(untag_ptr(_res));
23161         CResult_NoneSendErrorZ_free(_res_conv);
23162 }
23163
23164 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixParseErrorZ_1ok(JNIEnv *env, jclass clz, jclass o) {
23165         LDKSiPrefix o_conv = LDKSiPrefix_from_java(env, o);
23166         LDKCResult_SiPrefixParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixParseErrorZ), "LDKCResult_SiPrefixParseErrorZ");
23167         *ret_conv = CResult_SiPrefixParseErrorZ_ok(o_conv);
23168         return tag_ptr(ret_conv, true);
23169 }
23170
23171 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixParseErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
23172         void* e_ptr = untag_ptr(e);
23173         CHECK_ACCESS(e_ptr);
23174         LDKParseError e_conv = *(LDKParseError*)(e_ptr);
23175         e_conv = ParseError_clone((LDKParseError*)untag_ptr(e));
23176         LDKCResult_SiPrefixParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixParseErrorZ), "LDKCResult_SiPrefixParseErrorZ");
23177         *ret_conv = CResult_SiPrefixParseErrorZ_err(e_conv);
23178         return tag_ptr(ret_conv, true);
23179 }
23180
23181 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixParseErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23182         LDKCResult_SiPrefixParseErrorZ* o_conv = (LDKCResult_SiPrefixParseErrorZ*)untag_ptr(o);
23183         jboolean ret_conv = CResult_SiPrefixParseErrorZ_is_ok(o_conv);
23184         return ret_conv;
23185 }
23186
23187 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixParseErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23188         if (!ptr_is_owned(_res)) return;
23189         void* _res_ptr = untag_ptr(_res);
23190         CHECK_ACCESS(_res_ptr);
23191         LDKCResult_SiPrefixParseErrorZ _res_conv = *(LDKCResult_SiPrefixParseErrorZ*)(_res_ptr);
23192         FREE(untag_ptr(_res));
23193         CResult_SiPrefixParseErrorZ_free(_res_conv);
23194 }
23195
23196 static inline uint64_t CResult_SiPrefixParseErrorZ_clone_ptr(LDKCResult_SiPrefixParseErrorZ *NONNULL_PTR arg) {
23197         LDKCResult_SiPrefixParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixParseErrorZ), "LDKCResult_SiPrefixParseErrorZ");
23198         *ret_conv = CResult_SiPrefixParseErrorZ_clone(arg);
23199         return tag_ptr(ret_conv, true);
23200 }
23201 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixParseErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23202         LDKCResult_SiPrefixParseErrorZ* arg_conv = (LDKCResult_SiPrefixParseErrorZ*)untag_ptr(arg);
23203         int64_t ret_conv = CResult_SiPrefixParseErrorZ_clone_ptr(arg_conv);
23204         return ret_conv;
23205 }
23206
23207 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixParseErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23208         LDKCResult_SiPrefixParseErrorZ* orig_conv = (LDKCResult_SiPrefixParseErrorZ*)untag_ptr(orig);
23209         LDKCResult_SiPrefixParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixParseErrorZ), "LDKCResult_SiPrefixParseErrorZ");
23210         *ret_conv = CResult_SiPrefixParseErrorZ_clone(orig_conv);
23211         return tag_ptr(ret_conv, true);
23212 }
23213
23214 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceParseOrSemanticErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
23215         LDKInvoice o_conv;
23216         o_conv.inner = untag_ptr(o);
23217         o_conv.is_owned = ptr_is_owned(o);
23218         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
23219         o_conv = Invoice_clone(&o_conv);
23220         LDKCResult_InvoiceParseOrSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceParseOrSemanticErrorZ), "LDKCResult_InvoiceParseOrSemanticErrorZ");
23221         *ret_conv = CResult_InvoiceParseOrSemanticErrorZ_ok(o_conv);
23222         return tag_ptr(ret_conv, true);
23223 }
23224
23225 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceParseOrSemanticErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
23226         void* e_ptr = untag_ptr(e);
23227         CHECK_ACCESS(e_ptr);
23228         LDKParseOrSemanticError e_conv = *(LDKParseOrSemanticError*)(e_ptr);
23229         e_conv = ParseOrSemanticError_clone((LDKParseOrSemanticError*)untag_ptr(e));
23230         LDKCResult_InvoiceParseOrSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceParseOrSemanticErrorZ), "LDKCResult_InvoiceParseOrSemanticErrorZ");
23231         *ret_conv = CResult_InvoiceParseOrSemanticErrorZ_err(e_conv);
23232         return tag_ptr(ret_conv, true);
23233 }
23234
23235 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceParseOrSemanticErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23236         LDKCResult_InvoiceParseOrSemanticErrorZ* o_conv = (LDKCResult_InvoiceParseOrSemanticErrorZ*)untag_ptr(o);
23237         jboolean ret_conv = CResult_InvoiceParseOrSemanticErrorZ_is_ok(o_conv);
23238         return ret_conv;
23239 }
23240
23241 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceParseOrSemanticErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23242         if (!ptr_is_owned(_res)) return;
23243         void* _res_ptr = untag_ptr(_res);
23244         CHECK_ACCESS(_res_ptr);
23245         LDKCResult_InvoiceParseOrSemanticErrorZ _res_conv = *(LDKCResult_InvoiceParseOrSemanticErrorZ*)(_res_ptr);
23246         FREE(untag_ptr(_res));
23247         CResult_InvoiceParseOrSemanticErrorZ_free(_res_conv);
23248 }
23249
23250 static inline uint64_t CResult_InvoiceParseOrSemanticErrorZ_clone_ptr(LDKCResult_InvoiceParseOrSemanticErrorZ *NONNULL_PTR arg) {
23251         LDKCResult_InvoiceParseOrSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceParseOrSemanticErrorZ), "LDKCResult_InvoiceParseOrSemanticErrorZ");
23252         *ret_conv = CResult_InvoiceParseOrSemanticErrorZ_clone(arg);
23253         return tag_ptr(ret_conv, true);
23254 }
23255 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceParseOrSemanticErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23256         LDKCResult_InvoiceParseOrSemanticErrorZ* arg_conv = (LDKCResult_InvoiceParseOrSemanticErrorZ*)untag_ptr(arg);
23257         int64_t ret_conv = CResult_InvoiceParseOrSemanticErrorZ_clone_ptr(arg_conv);
23258         return ret_conv;
23259 }
23260
23261 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceParseOrSemanticErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23262         LDKCResult_InvoiceParseOrSemanticErrorZ* orig_conv = (LDKCResult_InvoiceParseOrSemanticErrorZ*)untag_ptr(orig);
23263         LDKCResult_InvoiceParseOrSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceParseOrSemanticErrorZ), "LDKCResult_InvoiceParseOrSemanticErrorZ");
23264         *ret_conv = CResult_InvoiceParseOrSemanticErrorZ_clone(orig_conv);
23265         return tag_ptr(ret_conv, true);
23266 }
23267
23268 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceParseErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
23269         LDKSignedRawInvoice o_conv;
23270         o_conv.inner = untag_ptr(o);
23271         o_conv.is_owned = ptr_is_owned(o);
23272         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
23273         o_conv = SignedRawInvoice_clone(&o_conv);
23274         LDKCResult_SignedRawInvoiceParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceParseErrorZ), "LDKCResult_SignedRawInvoiceParseErrorZ");
23275         *ret_conv = CResult_SignedRawInvoiceParseErrorZ_ok(o_conv);
23276         return tag_ptr(ret_conv, true);
23277 }
23278
23279 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceParseErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
23280         void* e_ptr = untag_ptr(e);
23281         CHECK_ACCESS(e_ptr);
23282         LDKParseError e_conv = *(LDKParseError*)(e_ptr);
23283         e_conv = ParseError_clone((LDKParseError*)untag_ptr(e));
23284         LDKCResult_SignedRawInvoiceParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceParseErrorZ), "LDKCResult_SignedRawInvoiceParseErrorZ");
23285         *ret_conv = CResult_SignedRawInvoiceParseErrorZ_err(e_conv);
23286         return tag_ptr(ret_conv, true);
23287 }
23288
23289 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceParseErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23290         LDKCResult_SignedRawInvoiceParseErrorZ* o_conv = (LDKCResult_SignedRawInvoiceParseErrorZ*)untag_ptr(o);
23291         jboolean ret_conv = CResult_SignedRawInvoiceParseErrorZ_is_ok(o_conv);
23292         return ret_conv;
23293 }
23294
23295 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceParseErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23296         if (!ptr_is_owned(_res)) return;
23297         void* _res_ptr = untag_ptr(_res);
23298         CHECK_ACCESS(_res_ptr);
23299         LDKCResult_SignedRawInvoiceParseErrorZ _res_conv = *(LDKCResult_SignedRawInvoiceParseErrorZ*)(_res_ptr);
23300         FREE(untag_ptr(_res));
23301         CResult_SignedRawInvoiceParseErrorZ_free(_res_conv);
23302 }
23303
23304 static inline uint64_t CResult_SignedRawInvoiceParseErrorZ_clone_ptr(LDKCResult_SignedRawInvoiceParseErrorZ *NONNULL_PTR arg) {
23305         LDKCResult_SignedRawInvoiceParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceParseErrorZ), "LDKCResult_SignedRawInvoiceParseErrorZ");
23306         *ret_conv = CResult_SignedRawInvoiceParseErrorZ_clone(arg);
23307         return tag_ptr(ret_conv, true);
23308 }
23309 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceParseErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23310         LDKCResult_SignedRawInvoiceParseErrorZ* arg_conv = (LDKCResult_SignedRawInvoiceParseErrorZ*)untag_ptr(arg);
23311         int64_t ret_conv = CResult_SignedRawInvoiceParseErrorZ_clone_ptr(arg_conv);
23312         return ret_conv;
23313 }
23314
23315 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceParseErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23316         LDKCResult_SignedRawInvoiceParseErrorZ* orig_conv = (LDKCResult_SignedRawInvoiceParseErrorZ*)untag_ptr(orig);
23317         LDKCResult_SignedRawInvoiceParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceParseErrorZ), "LDKCResult_SignedRawInvoiceParseErrorZ");
23318         *ret_conv = CResult_SignedRawInvoiceParseErrorZ_clone(orig_conv);
23319         return tag_ptr(ret_conv, true);
23320 }
23321
23322 static inline uint64_t C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone_ptr(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *NONNULL_PTR arg) {
23323         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
23324         *ret_conv = C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone(arg);
23325         return tag_ptr(ret_conv, true);
23326 }
23327 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23328         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* arg_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)untag_ptr(arg);
23329         int64_t ret_conv = C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone_ptr(arg_conv);
23330         return ret_conv;
23331 }
23332
23333 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23334         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* orig_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)untag_ptr(orig);
23335         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
23336         *ret_conv = C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone(orig_conv);
23337         return tag_ptr(ret_conv, true);
23338 }
23339
23340 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) {
23341         LDKRawInvoice a_conv;
23342         a_conv.inner = untag_ptr(a);
23343         a_conv.is_owned = ptr_is_owned(a);
23344         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
23345         a_conv = RawInvoice_clone(&a_conv);
23346         LDKThirtyTwoBytes b_ref;
23347         CHECK((*env)->GetArrayLength(env, b) == 32);
23348         (*env)->GetByteArrayRegion(env, b, 0, 32, b_ref.data);
23349         LDKInvoiceSignature c_conv;
23350         c_conv.inner = untag_ptr(c);
23351         c_conv.is_owned = ptr_is_owned(c);
23352         CHECK_INNER_FIELD_ACCESS_OR_NULL(c_conv);
23353         c_conv = InvoiceSignature_clone(&c_conv);
23354         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
23355         *ret_conv = C3Tuple_RawInvoice_u832InvoiceSignatureZ_new(a_conv, b_ref, c_conv);
23356         return tag_ptr(ret_conv, true);
23357 }
23358
23359 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23360         if (!ptr_is_owned(_res)) return;
23361         void* _res_ptr = untag_ptr(_res);
23362         CHECK_ACCESS(_res_ptr);
23363         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ _res_conv = *(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(_res_ptr);
23364         FREE(untag_ptr(_res));
23365         C3Tuple_RawInvoice_u832InvoiceSignatureZ_free(_res_conv);
23366 }
23367
23368 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
23369         LDKPayeePubKey o_conv;
23370         o_conv.inner = untag_ptr(o);
23371         o_conv.is_owned = ptr_is_owned(o);
23372         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
23373         o_conv = PayeePubKey_clone(&o_conv);
23374         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
23375         *ret_conv = CResult_PayeePubKeyErrorZ_ok(o_conv);
23376         return tag_ptr(ret_conv, true);
23377 }
23378
23379 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
23380         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_java(env, e);
23381         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
23382         *ret_conv = CResult_PayeePubKeyErrorZ_err(e_conv);
23383         return tag_ptr(ret_conv, true);
23384 }
23385
23386 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23387         LDKCResult_PayeePubKeyErrorZ* o_conv = (LDKCResult_PayeePubKeyErrorZ*)untag_ptr(o);
23388         jboolean ret_conv = CResult_PayeePubKeyErrorZ_is_ok(o_conv);
23389         return ret_conv;
23390 }
23391
23392 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23393         if (!ptr_is_owned(_res)) return;
23394         void* _res_ptr = untag_ptr(_res);
23395         CHECK_ACCESS(_res_ptr);
23396         LDKCResult_PayeePubKeyErrorZ _res_conv = *(LDKCResult_PayeePubKeyErrorZ*)(_res_ptr);
23397         FREE(untag_ptr(_res));
23398         CResult_PayeePubKeyErrorZ_free(_res_conv);
23399 }
23400
23401 static inline uint64_t CResult_PayeePubKeyErrorZ_clone_ptr(LDKCResult_PayeePubKeyErrorZ *NONNULL_PTR arg) {
23402         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
23403         *ret_conv = CResult_PayeePubKeyErrorZ_clone(arg);
23404         return tag_ptr(ret_conv, true);
23405 }
23406 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23407         LDKCResult_PayeePubKeyErrorZ* arg_conv = (LDKCResult_PayeePubKeyErrorZ*)untag_ptr(arg);
23408         int64_t ret_conv = CResult_PayeePubKeyErrorZ_clone_ptr(arg_conv);
23409         return ret_conv;
23410 }
23411
23412 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23413         LDKCResult_PayeePubKeyErrorZ* orig_conv = (LDKCResult_PayeePubKeyErrorZ*)untag_ptr(orig);
23414         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
23415         *ret_conv = CResult_PayeePubKeyErrorZ_clone(orig_conv);
23416         return tag_ptr(ret_conv, true);
23417 }
23418
23419 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1PrivateRouteZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
23420         LDKCVec_PrivateRouteZ _res_constr;
23421         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
23422         if (_res_constr.datalen > 0)
23423                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKPrivateRoute), "LDKCVec_PrivateRouteZ Elements");
23424         else
23425                 _res_constr.data = NULL;
23426         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
23427         for (size_t o = 0; o < _res_constr.datalen; o++) {
23428                 int64_t _res_conv_14 = _res_vals[o];
23429                 LDKPrivateRoute _res_conv_14_conv;
23430                 _res_conv_14_conv.inner = untag_ptr(_res_conv_14);
23431                 _res_conv_14_conv.is_owned = ptr_is_owned(_res_conv_14);
23432                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_14_conv);
23433                 _res_constr.data[o] = _res_conv_14_conv;
23434         }
23435         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
23436         CVec_PrivateRouteZ_free(_res_constr);
23437 }
23438
23439 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
23440         LDKPositiveTimestamp o_conv;
23441         o_conv.inner = untag_ptr(o);
23442         o_conv.is_owned = ptr_is_owned(o);
23443         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
23444         o_conv = PositiveTimestamp_clone(&o_conv);
23445         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
23446         *ret_conv = CResult_PositiveTimestampCreationErrorZ_ok(o_conv);
23447         return tag_ptr(ret_conv, true);
23448 }
23449
23450 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
23451         LDKCreationError e_conv = LDKCreationError_from_java(env, e);
23452         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
23453         *ret_conv = CResult_PositiveTimestampCreationErrorZ_err(e_conv);
23454         return tag_ptr(ret_conv, true);
23455 }
23456
23457 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23458         LDKCResult_PositiveTimestampCreationErrorZ* o_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)untag_ptr(o);
23459         jboolean ret_conv = CResult_PositiveTimestampCreationErrorZ_is_ok(o_conv);
23460         return ret_conv;
23461 }
23462
23463 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23464         if (!ptr_is_owned(_res)) return;
23465         void* _res_ptr = untag_ptr(_res);
23466         CHECK_ACCESS(_res_ptr);
23467         LDKCResult_PositiveTimestampCreationErrorZ _res_conv = *(LDKCResult_PositiveTimestampCreationErrorZ*)(_res_ptr);
23468         FREE(untag_ptr(_res));
23469         CResult_PositiveTimestampCreationErrorZ_free(_res_conv);
23470 }
23471
23472 static inline uint64_t CResult_PositiveTimestampCreationErrorZ_clone_ptr(LDKCResult_PositiveTimestampCreationErrorZ *NONNULL_PTR arg) {
23473         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
23474         *ret_conv = CResult_PositiveTimestampCreationErrorZ_clone(arg);
23475         return tag_ptr(ret_conv, true);
23476 }
23477 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23478         LDKCResult_PositiveTimestampCreationErrorZ* arg_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)untag_ptr(arg);
23479         int64_t ret_conv = CResult_PositiveTimestampCreationErrorZ_clone_ptr(arg_conv);
23480         return ret_conv;
23481 }
23482
23483 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23484         LDKCResult_PositiveTimestampCreationErrorZ* orig_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)untag_ptr(orig);
23485         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
23486         *ret_conv = CResult_PositiveTimestampCreationErrorZ_clone(orig_conv);
23487         return tag_ptr(ret_conv, true);
23488 }
23489
23490 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1ok(JNIEnv *env, jclass clz) {
23491         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
23492         *ret_conv = CResult_NoneSemanticErrorZ_ok();
23493         return tag_ptr(ret_conv, true);
23494 }
23495
23496 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
23497         LDKSemanticError e_conv = LDKSemanticError_from_java(env, e);
23498         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
23499         *ret_conv = CResult_NoneSemanticErrorZ_err(e_conv);
23500         return tag_ptr(ret_conv, true);
23501 }
23502
23503 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23504         LDKCResult_NoneSemanticErrorZ* o_conv = (LDKCResult_NoneSemanticErrorZ*)untag_ptr(o);
23505         jboolean ret_conv = CResult_NoneSemanticErrorZ_is_ok(o_conv);
23506         return ret_conv;
23507 }
23508
23509 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23510         if (!ptr_is_owned(_res)) return;
23511         void* _res_ptr = untag_ptr(_res);
23512         CHECK_ACCESS(_res_ptr);
23513         LDKCResult_NoneSemanticErrorZ _res_conv = *(LDKCResult_NoneSemanticErrorZ*)(_res_ptr);
23514         FREE(untag_ptr(_res));
23515         CResult_NoneSemanticErrorZ_free(_res_conv);
23516 }
23517
23518 static inline uint64_t CResult_NoneSemanticErrorZ_clone_ptr(LDKCResult_NoneSemanticErrorZ *NONNULL_PTR arg) {
23519         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
23520         *ret_conv = CResult_NoneSemanticErrorZ_clone(arg);
23521         return tag_ptr(ret_conv, true);
23522 }
23523 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23524         LDKCResult_NoneSemanticErrorZ* arg_conv = (LDKCResult_NoneSemanticErrorZ*)untag_ptr(arg);
23525         int64_t ret_conv = CResult_NoneSemanticErrorZ_clone_ptr(arg_conv);
23526         return ret_conv;
23527 }
23528
23529 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23530         LDKCResult_NoneSemanticErrorZ* orig_conv = (LDKCResult_NoneSemanticErrorZ*)untag_ptr(orig);
23531         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
23532         *ret_conv = CResult_NoneSemanticErrorZ_clone(orig_conv);
23533         return tag_ptr(ret_conv, true);
23534 }
23535
23536 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
23537         LDKInvoice o_conv;
23538         o_conv.inner = untag_ptr(o);
23539         o_conv.is_owned = ptr_is_owned(o);
23540         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
23541         o_conv = Invoice_clone(&o_conv);
23542         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
23543         *ret_conv = CResult_InvoiceSemanticErrorZ_ok(o_conv);
23544         return tag_ptr(ret_conv, true);
23545 }
23546
23547 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
23548         LDKSemanticError e_conv = LDKSemanticError_from_java(env, e);
23549         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
23550         *ret_conv = CResult_InvoiceSemanticErrorZ_err(e_conv);
23551         return tag_ptr(ret_conv, true);
23552 }
23553
23554 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23555         LDKCResult_InvoiceSemanticErrorZ* o_conv = (LDKCResult_InvoiceSemanticErrorZ*)untag_ptr(o);
23556         jboolean ret_conv = CResult_InvoiceSemanticErrorZ_is_ok(o_conv);
23557         return ret_conv;
23558 }
23559
23560 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23561         if (!ptr_is_owned(_res)) return;
23562         void* _res_ptr = untag_ptr(_res);
23563         CHECK_ACCESS(_res_ptr);
23564         LDKCResult_InvoiceSemanticErrorZ _res_conv = *(LDKCResult_InvoiceSemanticErrorZ*)(_res_ptr);
23565         FREE(untag_ptr(_res));
23566         CResult_InvoiceSemanticErrorZ_free(_res_conv);
23567 }
23568
23569 static inline uint64_t CResult_InvoiceSemanticErrorZ_clone_ptr(LDKCResult_InvoiceSemanticErrorZ *NONNULL_PTR arg) {
23570         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
23571         *ret_conv = CResult_InvoiceSemanticErrorZ_clone(arg);
23572         return tag_ptr(ret_conv, true);
23573 }
23574 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23575         LDKCResult_InvoiceSemanticErrorZ* arg_conv = (LDKCResult_InvoiceSemanticErrorZ*)untag_ptr(arg);
23576         int64_t ret_conv = CResult_InvoiceSemanticErrorZ_clone_ptr(arg_conv);
23577         return ret_conv;
23578 }
23579
23580 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23581         LDKCResult_InvoiceSemanticErrorZ* orig_conv = (LDKCResult_InvoiceSemanticErrorZ*)untag_ptr(orig);
23582         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
23583         *ret_conv = CResult_InvoiceSemanticErrorZ_clone(orig_conv);
23584         return tag_ptr(ret_conv, true);
23585 }
23586
23587 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
23588         LDKDescription o_conv;
23589         o_conv.inner = untag_ptr(o);
23590         o_conv.is_owned = ptr_is_owned(o);
23591         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
23592         o_conv = Description_clone(&o_conv);
23593         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
23594         *ret_conv = CResult_DescriptionCreationErrorZ_ok(o_conv);
23595         return tag_ptr(ret_conv, true);
23596 }
23597
23598 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
23599         LDKCreationError e_conv = LDKCreationError_from_java(env, e);
23600         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
23601         *ret_conv = CResult_DescriptionCreationErrorZ_err(e_conv);
23602         return tag_ptr(ret_conv, true);
23603 }
23604
23605 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23606         LDKCResult_DescriptionCreationErrorZ* o_conv = (LDKCResult_DescriptionCreationErrorZ*)untag_ptr(o);
23607         jboolean ret_conv = CResult_DescriptionCreationErrorZ_is_ok(o_conv);
23608         return ret_conv;
23609 }
23610
23611 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23612         if (!ptr_is_owned(_res)) return;
23613         void* _res_ptr = untag_ptr(_res);
23614         CHECK_ACCESS(_res_ptr);
23615         LDKCResult_DescriptionCreationErrorZ _res_conv = *(LDKCResult_DescriptionCreationErrorZ*)(_res_ptr);
23616         FREE(untag_ptr(_res));
23617         CResult_DescriptionCreationErrorZ_free(_res_conv);
23618 }
23619
23620 static inline uint64_t CResult_DescriptionCreationErrorZ_clone_ptr(LDKCResult_DescriptionCreationErrorZ *NONNULL_PTR arg) {
23621         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
23622         *ret_conv = CResult_DescriptionCreationErrorZ_clone(arg);
23623         return tag_ptr(ret_conv, true);
23624 }
23625 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23626         LDKCResult_DescriptionCreationErrorZ* arg_conv = (LDKCResult_DescriptionCreationErrorZ*)untag_ptr(arg);
23627         int64_t ret_conv = CResult_DescriptionCreationErrorZ_clone_ptr(arg_conv);
23628         return ret_conv;
23629 }
23630
23631 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23632         LDKCResult_DescriptionCreationErrorZ* orig_conv = (LDKCResult_DescriptionCreationErrorZ*)untag_ptr(orig);
23633         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
23634         *ret_conv = CResult_DescriptionCreationErrorZ_clone(orig_conv);
23635         return tag_ptr(ret_conv, true);
23636 }
23637
23638 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
23639         LDKPrivateRoute o_conv;
23640         o_conv.inner = untag_ptr(o);
23641         o_conv.is_owned = ptr_is_owned(o);
23642         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
23643         o_conv = PrivateRoute_clone(&o_conv);
23644         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
23645         *ret_conv = CResult_PrivateRouteCreationErrorZ_ok(o_conv);
23646         return tag_ptr(ret_conv, true);
23647 }
23648
23649 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
23650         LDKCreationError e_conv = LDKCreationError_from_java(env, e);
23651         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
23652         *ret_conv = CResult_PrivateRouteCreationErrorZ_err(e_conv);
23653         return tag_ptr(ret_conv, true);
23654 }
23655
23656 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23657         LDKCResult_PrivateRouteCreationErrorZ* o_conv = (LDKCResult_PrivateRouteCreationErrorZ*)untag_ptr(o);
23658         jboolean ret_conv = CResult_PrivateRouteCreationErrorZ_is_ok(o_conv);
23659         return ret_conv;
23660 }
23661
23662 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23663         if (!ptr_is_owned(_res)) return;
23664         void* _res_ptr = untag_ptr(_res);
23665         CHECK_ACCESS(_res_ptr);
23666         LDKCResult_PrivateRouteCreationErrorZ _res_conv = *(LDKCResult_PrivateRouteCreationErrorZ*)(_res_ptr);
23667         FREE(untag_ptr(_res));
23668         CResult_PrivateRouteCreationErrorZ_free(_res_conv);
23669 }
23670
23671 static inline uint64_t CResult_PrivateRouteCreationErrorZ_clone_ptr(LDKCResult_PrivateRouteCreationErrorZ *NONNULL_PTR arg) {
23672         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
23673         *ret_conv = CResult_PrivateRouteCreationErrorZ_clone(arg);
23674         return tag_ptr(ret_conv, true);
23675 }
23676 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23677         LDKCResult_PrivateRouteCreationErrorZ* arg_conv = (LDKCResult_PrivateRouteCreationErrorZ*)untag_ptr(arg);
23678         int64_t ret_conv = CResult_PrivateRouteCreationErrorZ_clone_ptr(arg_conv);
23679         return ret_conv;
23680 }
23681
23682 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23683         LDKCResult_PrivateRouteCreationErrorZ* orig_conv = (LDKCResult_PrivateRouteCreationErrorZ*)untag_ptr(orig);
23684         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
23685         *ret_conv = CResult_PrivateRouteCreationErrorZ_clone(orig_conv);
23686         return tag_ptr(ret_conv, true);
23687 }
23688
23689 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1u32GraphSyncErrorZ_1ok(JNIEnv *env, jclass clz, int32_t o) {
23690         LDKCResult_u32GraphSyncErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_u32GraphSyncErrorZ), "LDKCResult_u32GraphSyncErrorZ");
23691         *ret_conv = CResult_u32GraphSyncErrorZ_ok(o);
23692         return tag_ptr(ret_conv, true);
23693 }
23694
23695 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1u32GraphSyncErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
23696         void* e_ptr = untag_ptr(e);
23697         CHECK_ACCESS(e_ptr);
23698         LDKGraphSyncError e_conv = *(LDKGraphSyncError*)(e_ptr);
23699         e_conv = GraphSyncError_clone((LDKGraphSyncError*)untag_ptr(e));
23700         LDKCResult_u32GraphSyncErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_u32GraphSyncErrorZ), "LDKCResult_u32GraphSyncErrorZ");
23701         *ret_conv = CResult_u32GraphSyncErrorZ_err(e_conv);
23702         return tag_ptr(ret_conv, true);
23703 }
23704
23705 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1u32GraphSyncErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23706         LDKCResult_u32GraphSyncErrorZ* o_conv = (LDKCResult_u32GraphSyncErrorZ*)untag_ptr(o);
23707         jboolean ret_conv = CResult_u32GraphSyncErrorZ_is_ok(o_conv);
23708         return ret_conv;
23709 }
23710
23711 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1u32GraphSyncErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23712         if (!ptr_is_owned(_res)) return;
23713         void* _res_ptr = untag_ptr(_res);
23714         CHECK_ACCESS(_res_ptr);
23715         LDKCResult_u32GraphSyncErrorZ _res_conv = *(LDKCResult_u32GraphSyncErrorZ*)(_res_ptr);
23716         FREE(untag_ptr(_res));
23717         CResult_u32GraphSyncErrorZ_free(_res_conv);
23718 }
23719
23720 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
23721         void* o_ptr = untag_ptr(o);
23722         CHECK_ACCESS(o_ptr);
23723         LDKNetAddress o_conv = *(LDKNetAddress*)(o_ptr);
23724         o_conv = NetAddress_clone((LDKNetAddress*)untag_ptr(o));
23725         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
23726         *ret_conv = CResult_NetAddressDecodeErrorZ_ok(o_conv);
23727         return tag_ptr(ret_conv, true);
23728 }
23729
23730 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
23731         void* e_ptr = untag_ptr(e);
23732         CHECK_ACCESS(e_ptr);
23733         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
23734         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
23735         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
23736         *ret_conv = CResult_NetAddressDecodeErrorZ_err(e_conv);
23737         return tag_ptr(ret_conv, true);
23738 }
23739
23740 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23741         LDKCResult_NetAddressDecodeErrorZ* o_conv = (LDKCResult_NetAddressDecodeErrorZ*)untag_ptr(o);
23742         jboolean ret_conv = CResult_NetAddressDecodeErrorZ_is_ok(o_conv);
23743         return ret_conv;
23744 }
23745
23746 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23747         if (!ptr_is_owned(_res)) return;
23748         void* _res_ptr = untag_ptr(_res);
23749         CHECK_ACCESS(_res_ptr);
23750         LDKCResult_NetAddressDecodeErrorZ _res_conv = *(LDKCResult_NetAddressDecodeErrorZ*)(_res_ptr);
23751         FREE(untag_ptr(_res));
23752         CResult_NetAddressDecodeErrorZ_free(_res_conv);
23753 }
23754
23755 static inline uint64_t CResult_NetAddressDecodeErrorZ_clone_ptr(LDKCResult_NetAddressDecodeErrorZ *NONNULL_PTR arg) {
23756         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
23757         *ret_conv = CResult_NetAddressDecodeErrorZ_clone(arg);
23758         return tag_ptr(ret_conv, true);
23759 }
23760 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23761         LDKCResult_NetAddressDecodeErrorZ* arg_conv = (LDKCResult_NetAddressDecodeErrorZ*)untag_ptr(arg);
23762         int64_t ret_conv = CResult_NetAddressDecodeErrorZ_clone_ptr(arg_conv);
23763         return ret_conv;
23764 }
23765
23766 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23767         LDKCResult_NetAddressDecodeErrorZ* orig_conv = (LDKCResult_NetAddressDecodeErrorZ*)untag_ptr(orig);
23768         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
23769         *ret_conv = CResult_NetAddressDecodeErrorZ_clone(orig_conv);
23770         return tag_ptr(ret_conv, true);
23771 }
23772
23773 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateAddHTLCZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
23774         LDKCVec_UpdateAddHTLCZ _res_constr;
23775         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
23776         if (_res_constr.datalen > 0)
23777                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
23778         else
23779                 _res_constr.data = NULL;
23780         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
23781         for (size_t p = 0; p < _res_constr.datalen; p++) {
23782                 int64_t _res_conv_15 = _res_vals[p];
23783                 LDKUpdateAddHTLC _res_conv_15_conv;
23784                 _res_conv_15_conv.inner = untag_ptr(_res_conv_15);
23785                 _res_conv_15_conv.is_owned = ptr_is_owned(_res_conv_15);
23786                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_15_conv);
23787                 _res_constr.data[p] = _res_conv_15_conv;
23788         }
23789         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
23790         CVec_UpdateAddHTLCZ_free(_res_constr);
23791 }
23792
23793 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateFulfillHTLCZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
23794         LDKCVec_UpdateFulfillHTLCZ _res_constr;
23795         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
23796         if (_res_constr.datalen > 0)
23797                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
23798         else
23799                 _res_constr.data = NULL;
23800         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
23801         for (size_t t = 0; t < _res_constr.datalen; t++) {
23802                 int64_t _res_conv_19 = _res_vals[t];
23803                 LDKUpdateFulfillHTLC _res_conv_19_conv;
23804                 _res_conv_19_conv.inner = untag_ptr(_res_conv_19);
23805                 _res_conv_19_conv.is_owned = ptr_is_owned(_res_conv_19);
23806                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_19_conv);
23807                 _res_constr.data[t] = _res_conv_19_conv;
23808         }
23809         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
23810         CVec_UpdateFulfillHTLCZ_free(_res_constr);
23811 }
23812
23813 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateFailHTLCZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
23814         LDKCVec_UpdateFailHTLCZ _res_constr;
23815         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
23816         if (_res_constr.datalen > 0)
23817                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
23818         else
23819                 _res_constr.data = NULL;
23820         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
23821         for (size_t q = 0; q < _res_constr.datalen; q++) {
23822                 int64_t _res_conv_16 = _res_vals[q];
23823                 LDKUpdateFailHTLC _res_conv_16_conv;
23824                 _res_conv_16_conv.inner = untag_ptr(_res_conv_16);
23825                 _res_conv_16_conv.is_owned = ptr_is_owned(_res_conv_16);
23826                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_16_conv);
23827                 _res_constr.data[q] = _res_conv_16_conv;
23828         }
23829         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
23830         CVec_UpdateFailHTLCZ_free(_res_constr);
23831 }
23832
23833 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateFailMalformedHTLCZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
23834         LDKCVec_UpdateFailMalformedHTLCZ _res_constr;
23835         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
23836         if (_res_constr.datalen > 0)
23837                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
23838         else
23839                 _res_constr.data = NULL;
23840         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
23841         for (size_t z = 0; z < _res_constr.datalen; z++) {
23842                 int64_t _res_conv_25 = _res_vals[z];
23843                 LDKUpdateFailMalformedHTLC _res_conv_25_conv;
23844                 _res_conv_25_conv.inner = untag_ptr(_res_conv_25);
23845                 _res_conv_25_conv.is_owned = ptr_is_owned(_res_conv_25);
23846                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_25_conv);
23847                 _res_constr.data[z] = _res_conv_25_conv;
23848         }
23849         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
23850         CVec_UpdateFailMalformedHTLCZ_free(_res_constr);
23851 }
23852
23853 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
23854         LDKAcceptChannel o_conv;
23855         o_conv.inner = untag_ptr(o);
23856         o_conv.is_owned = ptr_is_owned(o);
23857         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
23858         o_conv = AcceptChannel_clone(&o_conv);
23859         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
23860         *ret_conv = CResult_AcceptChannelDecodeErrorZ_ok(o_conv);
23861         return tag_ptr(ret_conv, true);
23862 }
23863
23864 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
23865         void* e_ptr = untag_ptr(e);
23866         CHECK_ACCESS(e_ptr);
23867         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
23868         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
23869         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
23870         *ret_conv = CResult_AcceptChannelDecodeErrorZ_err(e_conv);
23871         return tag_ptr(ret_conv, true);
23872 }
23873
23874 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23875         LDKCResult_AcceptChannelDecodeErrorZ* o_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)untag_ptr(o);
23876         jboolean ret_conv = CResult_AcceptChannelDecodeErrorZ_is_ok(o_conv);
23877         return ret_conv;
23878 }
23879
23880 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23881         if (!ptr_is_owned(_res)) return;
23882         void* _res_ptr = untag_ptr(_res);
23883         CHECK_ACCESS(_res_ptr);
23884         LDKCResult_AcceptChannelDecodeErrorZ _res_conv = *(LDKCResult_AcceptChannelDecodeErrorZ*)(_res_ptr);
23885         FREE(untag_ptr(_res));
23886         CResult_AcceptChannelDecodeErrorZ_free(_res_conv);
23887 }
23888
23889 static inline uint64_t CResult_AcceptChannelDecodeErrorZ_clone_ptr(LDKCResult_AcceptChannelDecodeErrorZ *NONNULL_PTR arg) {
23890         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
23891         *ret_conv = CResult_AcceptChannelDecodeErrorZ_clone(arg);
23892         return tag_ptr(ret_conv, true);
23893 }
23894 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23895         LDKCResult_AcceptChannelDecodeErrorZ* arg_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)untag_ptr(arg);
23896         int64_t ret_conv = CResult_AcceptChannelDecodeErrorZ_clone_ptr(arg_conv);
23897         return ret_conv;
23898 }
23899
23900 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23901         LDKCResult_AcceptChannelDecodeErrorZ* orig_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)untag_ptr(orig);
23902         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
23903         *ret_conv = CResult_AcceptChannelDecodeErrorZ_clone(orig_conv);
23904         return tag_ptr(ret_conv, true);
23905 }
23906
23907 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
23908         LDKAnnouncementSignatures o_conv;
23909         o_conv.inner = untag_ptr(o);
23910         o_conv.is_owned = ptr_is_owned(o);
23911         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
23912         o_conv = AnnouncementSignatures_clone(&o_conv);
23913         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
23914         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_ok(o_conv);
23915         return tag_ptr(ret_conv, true);
23916 }
23917
23918 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
23919         void* e_ptr = untag_ptr(e);
23920         CHECK_ACCESS(e_ptr);
23921         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
23922         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
23923         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
23924         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_err(e_conv);
23925         return tag_ptr(ret_conv, true);
23926 }
23927
23928 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23929         LDKCResult_AnnouncementSignaturesDecodeErrorZ* o_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)untag_ptr(o);
23930         jboolean ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_is_ok(o_conv);
23931         return ret_conv;
23932 }
23933
23934 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23935         if (!ptr_is_owned(_res)) return;
23936         void* _res_ptr = untag_ptr(_res);
23937         CHECK_ACCESS(_res_ptr);
23938         LDKCResult_AnnouncementSignaturesDecodeErrorZ _res_conv = *(LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(_res_ptr);
23939         FREE(untag_ptr(_res));
23940         CResult_AnnouncementSignaturesDecodeErrorZ_free(_res_conv);
23941 }
23942
23943 static inline uint64_t CResult_AnnouncementSignaturesDecodeErrorZ_clone_ptr(LDKCResult_AnnouncementSignaturesDecodeErrorZ *NONNULL_PTR arg) {
23944         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
23945         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_clone(arg);
23946         return tag_ptr(ret_conv, true);
23947 }
23948 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23949         LDKCResult_AnnouncementSignaturesDecodeErrorZ* arg_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)untag_ptr(arg);
23950         int64_t ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_clone_ptr(arg_conv);
23951         return ret_conv;
23952 }
23953
23954 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23955         LDKCResult_AnnouncementSignaturesDecodeErrorZ* orig_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)untag_ptr(orig);
23956         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
23957         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_clone(orig_conv);
23958         return tag_ptr(ret_conv, true);
23959 }
23960
23961 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
23962         LDKChannelReestablish o_conv;
23963         o_conv.inner = untag_ptr(o);
23964         o_conv.is_owned = ptr_is_owned(o);
23965         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
23966         o_conv = ChannelReestablish_clone(&o_conv);
23967         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
23968         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_ok(o_conv);
23969         return tag_ptr(ret_conv, true);
23970 }
23971
23972 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
23973         void* e_ptr = untag_ptr(e);
23974         CHECK_ACCESS(e_ptr);
23975         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
23976         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
23977         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
23978         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_err(e_conv);
23979         return tag_ptr(ret_conv, true);
23980 }
23981
23982 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
23983         LDKCResult_ChannelReestablishDecodeErrorZ* o_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)untag_ptr(o);
23984         jboolean ret_conv = CResult_ChannelReestablishDecodeErrorZ_is_ok(o_conv);
23985         return ret_conv;
23986 }
23987
23988 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
23989         if (!ptr_is_owned(_res)) return;
23990         void* _res_ptr = untag_ptr(_res);
23991         CHECK_ACCESS(_res_ptr);
23992         LDKCResult_ChannelReestablishDecodeErrorZ _res_conv = *(LDKCResult_ChannelReestablishDecodeErrorZ*)(_res_ptr);
23993         FREE(untag_ptr(_res));
23994         CResult_ChannelReestablishDecodeErrorZ_free(_res_conv);
23995 }
23996
23997 static inline uint64_t CResult_ChannelReestablishDecodeErrorZ_clone_ptr(LDKCResult_ChannelReestablishDecodeErrorZ *NONNULL_PTR arg) {
23998         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
23999         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_clone(arg);
24000         return tag_ptr(ret_conv, true);
24001 }
24002 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24003         LDKCResult_ChannelReestablishDecodeErrorZ* arg_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)untag_ptr(arg);
24004         int64_t ret_conv = CResult_ChannelReestablishDecodeErrorZ_clone_ptr(arg_conv);
24005         return ret_conv;
24006 }
24007
24008 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24009         LDKCResult_ChannelReestablishDecodeErrorZ* orig_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)untag_ptr(orig);
24010         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
24011         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_clone(orig_conv);
24012         return tag_ptr(ret_conv, true);
24013 }
24014
24015 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
24016         LDKClosingSigned o_conv;
24017         o_conv.inner = untag_ptr(o);
24018         o_conv.is_owned = ptr_is_owned(o);
24019         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
24020         o_conv = ClosingSigned_clone(&o_conv);
24021         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
24022         *ret_conv = CResult_ClosingSignedDecodeErrorZ_ok(o_conv);
24023         return tag_ptr(ret_conv, true);
24024 }
24025
24026 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
24027         void* e_ptr = untag_ptr(e);
24028         CHECK_ACCESS(e_ptr);
24029         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
24030         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
24031         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
24032         *ret_conv = CResult_ClosingSignedDecodeErrorZ_err(e_conv);
24033         return tag_ptr(ret_conv, true);
24034 }
24035
24036 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
24037         LDKCResult_ClosingSignedDecodeErrorZ* o_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)untag_ptr(o);
24038         jboolean ret_conv = CResult_ClosingSignedDecodeErrorZ_is_ok(o_conv);
24039         return ret_conv;
24040 }
24041
24042 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
24043         if (!ptr_is_owned(_res)) return;
24044         void* _res_ptr = untag_ptr(_res);
24045         CHECK_ACCESS(_res_ptr);
24046         LDKCResult_ClosingSignedDecodeErrorZ _res_conv = *(LDKCResult_ClosingSignedDecodeErrorZ*)(_res_ptr);
24047         FREE(untag_ptr(_res));
24048         CResult_ClosingSignedDecodeErrorZ_free(_res_conv);
24049 }
24050
24051 static inline uint64_t CResult_ClosingSignedDecodeErrorZ_clone_ptr(LDKCResult_ClosingSignedDecodeErrorZ *NONNULL_PTR arg) {
24052         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
24053         *ret_conv = CResult_ClosingSignedDecodeErrorZ_clone(arg);
24054         return tag_ptr(ret_conv, true);
24055 }
24056 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24057         LDKCResult_ClosingSignedDecodeErrorZ* arg_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)untag_ptr(arg);
24058         int64_t ret_conv = CResult_ClosingSignedDecodeErrorZ_clone_ptr(arg_conv);
24059         return ret_conv;
24060 }
24061
24062 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24063         LDKCResult_ClosingSignedDecodeErrorZ* orig_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)untag_ptr(orig);
24064         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
24065         *ret_conv = CResult_ClosingSignedDecodeErrorZ_clone(orig_conv);
24066         return tag_ptr(ret_conv, true);
24067 }
24068
24069 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
24070         LDKClosingSignedFeeRange o_conv;
24071         o_conv.inner = untag_ptr(o);
24072         o_conv.is_owned = ptr_is_owned(o);
24073         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
24074         o_conv = ClosingSignedFeeRange_clone(&o_conv);
24075         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
24076         *ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_ok(o_conv);
24077         return tag_ptr(ret_conv, true);
24078 }
24079
24080 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
24081         void* e_ptr = untag_ptr(e);
24082         CHECK_ACCESS(e_ptr);
24083         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
24084         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
24085         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
24086         *ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_err(e_conv);
24087         return tag_ptr(ret_conv, true);
24088 }
24089
24090 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
24091         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* o_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)untag_ptr(o);
24092         jboolean ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_is_ok(o_conv);
24093         return ret_conv;
24094 }
24095
24096 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
24097         if (!ptr_is_owned(_res)) return;
24098         void* _res_ptr = untag_ptr(_res);
24099         CHECK_ACCESS(_res_ptr);
24100         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ _res_conv = *(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(_res_ptr);
24101         FREE(untag_ptr(_res));
24102         CResult_ClosingSignedFeeRangeDecodeErrorZ_free(_res_conv);
24103 }
24104
24105 static inline uint64_t CResult_ClosingSignedFeeRangeDecodeErrorZ_clone_ptr(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ *NONNULL_PTR arg) {
24106         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
24107         *ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_clone(arg);
24108         return tag_ptr(ret_conv, true);
24109 }
24110 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24111         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* arg_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)untag_ptr(arg);
24112         int64_t ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_clone_ptr(arg_conv);
24113         return ret_conv;
24114 }
24115
24116 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24117         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* orig_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)untag_ptr(orig);
24118         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
24119         *ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_clone(orig_conv);
24120         return tag_ptr(ret_conv, true);
24121 }
24122
24123 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
24124         LDKCommitmentSigned o_conv;
24125         o_conv.inner = untag_ptr(o);
24126         o_conv.is_owned = ptr_is_owned(o);
24127         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
24128         o_conv = CommitmentSigned_clone(&o_conv);
24129         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
24130         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_ok(o_conv);
24131         return tag_ptr(ret_conv, true);
24132 }
24133
24134 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
24135         void* e_ptr = untag_ptr(e);
24136         CHECK_ACCESS(e_ptr);
24137         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
24138         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
24139         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
24140         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_err(e_conv);
24141         return tag_ptr(ret_conv, true);
24142 }
24143
24144 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
24145         LDKCResult_CommitmentSignedDecodeErrorZ* o_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)untag_ptr(o);
24146         jboolean ret_conv = CResult_CommitmentSignedDecodeErrorZ_is_ok(o_conv);
24147         return ret_conv;
24148 }
24149
24150 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
24151         if (!ptr_is_owned(_res)) return;
24152         void* _res_ptr = untag_ptr(_res);
24153         CHECK_ACCESS(_res_ptr);
24154         LDKCResult_CommitmentSignedDecodeErrorZ _res_conv = *(LDKCResult_CommitmentSignedDecodeErrorZ*)(_res_ptr);
24155         FREE(untag_ptr(_res));
24156         CResult_CommitmentSignedDecodeErrorZ_free(_res_conv);
24157 }
24158
24159 static inline uint64_t CResult_CommitmentSignedDecodeErrorZ_clone_ptr(LDKCResult_CommitmentSignedDecodeErrorZ *NONNULL_PTR arg) {
24160         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
24161         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_clone(arg);
24162         return tag_ptr(ret_conv, true);
24163 }
24164 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24165         LDKCResult_CommitmentSignedDecodeErrorZ* arg_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)untag_ptr(arg);
24166         int64_t ret_conv = CResult_CommitmentSignedDecodeErrorZ_clone_ptr(arg_conv);
24167         return ret_conv;
24168 }
24169
24170 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24171         LDKCResult_CommitmentSignedDecodeErrorZ* orig_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)untag_ptr(orig);
24172         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
24173         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_clone(orig_conv);
24174         return tag_ptr(ret_conv, true);
24175 }
24176
24177 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
24178         LDKFundingCreated o_conv;
24179         o_conv.inner = untag_ptr(o);
24180         o_conv.is_owned = ptr_is_owned(o);
24181         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
24182         o_conv = FundingCreated_clone(&o_conv);
24183         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
24184         *ret_conv = CResult_FundingCreatedDecodeErrorZ_ok(o_conv);
24185         return tag_ptr(ret_conv, true);
24186 }
24187
24188 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
24189         void* e_ptr = untag_ptr(e);
24190         CHECK_ACCESS(e_ptr);
24191         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
24192         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
24193         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
24194         *ret_conv = CResult_FundingCreatedDecodeErrorZ_err(e_conv);
24195         return tag_ptr(ret_conv, true);
24196 }
24197
24198 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
24199         LDKCResult_FundingCreatedDecodeErrorZ* o_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)untag_ptr(o);
24200         jboolean ret_conv = CResult_FundingCreatedDecodeErrorZ_is_ok(o_conv);
24201         return ret_conv;
24202 }
24203
24204 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
24205         if (!ptr_is_owned(_res)) return;
24206         void* _res_ptr = untag_ptr(_res);
24207         CHECK_ACCESS(_res_ptr);
24208         LDKCResult_FundingCreatedDecodeErrorZ _res_conv = *(LDKCResult_FundingCreatedDecodeErrorZ*)(_res_ptr);
24209         FREE(untag_ptr(_res));
24210         CResult_FundingCreatedDecodeErrorZ_free(_res_conv);
24211 }
24212
24213 static inline uint64_t CResult_FundingCreatedDecodeErrorZ_clone_ptr(LDKCResult_FundingCreatedDecodeErrorZ *NONNULL_PTR arg) {
24214         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
24215         *ret_conv = CResult_FundingCreatedDecodeErrorZ_clone(arg);
24216         return tag_ptr(ret_conv, true);
24217 }
24218 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24219         LDKCResult_FundingCreatedDecodeErrorZ* arg_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)untag_ptr(arg);
24220         int64_t ret_conv = CResult_FundingCreatedDecodeErrorZ_clone_ptr(arg_conv);
24221         return ret_conv;
24222 }
24223
24224 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24225         LDKCResult_FundingCreatedDecodeErrorZ* orig_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)untag_ptr(orig);
24226         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
24227         *ret_conv = CResult_FundingCreatedDecodeErrorZ_clone(orig_conv);
24228         return tag_ptr(ret_conv, true);
24229 }
24230
24231 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
24232         LDKFundingSigned o_conv;
24233         o_conv.inner = untag_ptr(o);
24234         o_conv.is_owned = ptr_is_owned(o);
24235         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
24236         o_conv = FundingSigned_clone(&o_conv);
24237         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
24238         *ret_conv = CResult_FundingSignedDecodeErrorZ_ok(o_conv);
24239         return tag_ptr(ret_conv, true);
24240 }
24241
24242 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
24243         void* e_ptr = untag_ptr(e);
24244         CHECK_ACCESS(e_ptr);
24245         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
24246         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
24247         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
24248         *ret_conv = CResult_FundingSignedDecodeErrorZ_err(e_conv);
24249         return tag_ptr(ret_conv, true);
24250 }
24251
24252 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
24253         LDKCResult_FundingSignedDecodeErrorZ* o_conv = (LDKCResult_FundingSignedDecodeErrorZ*)untag_ptr(o);
24254         jboolean ret_conv = CResult_FundingSignedDecodeErrorZ_is_ok(o_conv);
24255         return ret_conv;
24256 }
24257
24258 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
24259         if (!ptr_is_owned(_res)) return;
24260         void* _res_ptr = untag_ptr(_res);
24261         CHECK_ACCESS(_res_ptr);
24262         LDKCResult_FundingSignedDecodeErrorZ _res_conv = *(LDKCResult_FundingSignedDecodeErrorZ*)(_res_ptr);
24263         FREE(untag_ptr(_res));
24264         CResult_FundingSignedDecodeErrorZ_free(_res_conv);
24265 }
24266
24267 static inline uint64_t CResult_FundingSignedDecodeErrorZ_clone_ptr(LDKCResult_FundingSignedDecodeErrorZ *NONNULL_PTR arg) {
24268         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
24269         *ret_conv = CResult_FundingSignedDecodeErrorZ_clone(arg);
24270         return tag_ptr(ret_conv, true);
24271 }
24272 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24273         LDKCResult_FundingSignedDecodeErrorZ* arg_conv = (LDKCResult_FundingSignedDecodeErrorZ*)untag_ptr(arg);
24274         int64_t ret_conv = CResult_FundingSignedDecodeErrorZ_clone_ptr(arg_conv);
24275         return ret_conv;
24276 }
24277
24278 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24279         LDKCResult_FundingSignedDecodeErrorZ* orig_conv = (LDKCResult_FundingSignedDecodeErrorZ*)untag_ptr(orig);
24280         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
24281         *ret_conv = CResult_FundingSignedDecodeErrorZ_clone(orig_conv);
24282         return tag_ptr(ret_conv, true);
24283 }
24284
24285 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReadyDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
24286         LDKChannelReady o_conv;
24287         o_conv.inner = untag_ptr(o);
24288         o_conv.is_owned = ptr_is_owned(o);
24289         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
24290         o_conv = ChannelReady_clone(&o_conv);
24291         LDKCResult_ChannelReadyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReadyDecodeErrorZ), "LDKCResult_ChannelReadyDecodeErrorZ");
24292         *ret_conv = CResult_ChannelReadyDecodeErrorZ_ok(o_conv);
24293         return tag_ptr(ret_conv, true);
24294 }
24295
24296 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReadyDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
24297         void* e_ptr = untag_ptr(e);
24298         CHECK_ACCESS(e_ptr);
24299         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
24300         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
24301         LDKCResult_ChannelReadyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReadyDecodeErrorZ), "LDKCResult_ChannelReadyDecodeErrorZ");
24302         *ret_conv = CResult_ChannelReadyDecodeErrorZ_err(e_conv);
24303         return tag_ptr(ret_conv, true);
24304 }
24305
24306 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReadyDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
24307         LDKCResult_ChannelReadyDecodeErrorZ* o_conv = (LDKCResult_ChannelReadyDecodeErrorZ*)untag_ptr(o);
24308         jboolean ret_conv = CResult_ChannelReadyDecodeErrorZ_is_ok(o_conv);
24309         return ret_conv;
24310 }
24311
24312 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReadyDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
24313         if (!ptr_is_owned(_res)) return;
24314         void* _res_ptr = untag_ptr(_res);
24315         CHECK_ACCESS(_res_ptr);
24316         LDKCResult_ChannelReadyDecodeErrorZ _res_conv = *(LDKCResult_ChannelReadyDecodeErrorZ*)(_res_ptr);
24317         FREE(untag_ptr(_res));
24318         CResult_ChannelReadyDecodeErrorZ_free(_res_conv);
24319 }
24320
24321 static inline uint64_t CResult_ChannelReadyDecodeErrorZ_clone_ptr(LDKCResult_ChannelReadyDecodeErrorZ *NONNULL_PTR arg) {
24322         LDKCResult_ChannelReadyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReadyDecodeErrorZ), "LDKCResult_ChannelReadyDecodeErrorZ");
24323         *ret_conv = CResult_ChannelReadyDecodeErrorZ_clone(arg);
24324         return tag_ptr(ret_conv, true);
24325 }
24326 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReadyDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24327         LDKCResult_ChannelReadyDecodeErrorZ* arg_conv = (LDKCResult_ChannelReadyDecodeErrorZ*)untag_ptr(arg);
24328         int64_t ret_conv = CResult_ChannelReadyDecodeErrorZ_clone_ptr(arg_conv);
24329         return ret_conv;
24330 }
24331
24332 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReadyDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24333         LDKCResult_ChannelReadyDecodeErrorZ* orig_conv = (LDKCResult_ChannelReadyDecodeErrorZ*)untag_ptr(orig);
24334         LDKCResult_ChannelReadyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReadyDecodeErrorZ), "LDKCResult_ChannelReadyDecodeErrorZ");
24335         *ret_conv = CResult_ChannelReadyDecodeErrorZ_clone(orig_conv);
24336         return tag_ptr(ret_conv, true);
24337 }
24338
24339 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
24340         LDKInit o_conv;
24341         o_conv.inner = untag_ptr(o);
24342         o_conv.is_owned = ptr_is_owned(o);
24343         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
24344         o_conv = Init_clone(&o_conv);
24345         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
24346         *ret_conv = CResult_InitDecodeErrorZ_ok(o_conv);
24347         return tag_ptr(ret_conv, true);
24348 }
24349
24350 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
24351         void* e_ptr = untag_ptr(e);
24352         CHECK_ACCESS(e_ptr);
24353         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
24354         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
24355         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
24356         *ret_conv = CResult_InitDecodeErrorZ_err(e_conv);
24357         return tag_ptr(ret_conv, true);
24358 }
24359
24360 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
24361         LDKCResult_InitDecodeErrorZ* o_conv = (LDKCResult_InitDecodeErrorZ*)untag_ptr(o);
24362         jboolean ret_conv = CResult_InitDecodeErrorZ_is_ok(o_conv);
24363         return ret_conv;
24364 }
24365
24366 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
24367         if (!ptr_is_owned(_res)) return;
24368         void* _res_ptr = untag_ptr(_res);
24369         CHECK_ACCESS(_res_ptr);
24370         LDKCResult_InitDecodeErrorZ _res_conv = *(LDKCResult_InitDecodeErrorZ*)(_res_ptr);
24371         FREE(untag_ptr(_res));
24372         CResult_InitDecodeErrorZ_free(_res_conv);
24373 }
24374
24375 static inline uint64_t CResult_InitDecodeErrorZ_clone_ptr(LDKCResult_InitDecodeErrorZ *NONNULL_PTR arg) {
24376         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
24377         *ret_conv = CResult_InitDecodeErrorZ_clone(arg);
24378         return tag_ptr(ret_conv, true);
24379 }
24380 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24381         LDKCResult_InitDecodeErrorZ* arg_conv = (LDKCResult_InitDecodeErrorZ*)untag_ptr(arg);
24382         int64_t ret_conv = CResult_InitDecodeErrorZ_clone_ptr(arg_conv);
24383         return ret_conv;
24384 }
24385
24386 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24387         LDKCResult_InitDecodeErrorZ* orig_conv = (LDKCResult_InitDecodeErrorZ*)untag_ptr(orig);
24388         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
24389         *ret_conv = CResult_InitDecodeErrorZ_clone(orig_conv);
24390         return tag_ptr(ret_conv, true);
24391 }
24392
24393 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
24394         LDKOpenChannel o_conv;
24395         o_conv.inner = untag_ptr(o);
24396         o_conv.is_owned = ptr_is_owned(o);
24397         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
24398         o_conv = OpenChannel_clone(&o_conv);
24399         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
24400         *ret_conv = CResult_OpenChannelDecodeErrorZ_ok(o_conv);
24401         return tag_ptr(ret_conv, true);
24402 }
24403
24404 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
24405         void* e_ptr = untag_ptr(e);
24406         CHECK_ACCESS(e_ptr);
24407         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
24408         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
24409         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
24410         *ret_conv = CResult_OpenChannelDecodeErrorZ_err(e_conv);
24411         return tag_ptr(ret_conv, true);
24412 }
24413
24414 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
24415         LDKCResult_OpenChannelDecodeErrorZ* o_conv = (LDKCResult_OpenChannelDecodeErrorZ*)untag_ptr(o);
24416         jboolean ret_conv = CResult_OpenChannelDecodeErrorZ_is_ok(o_conv);
24417         return ret_conv;
24418 }
24419
24420 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
24421         if (!ptr_is_owned(_res)) return;
24422         void* _res_ptr = untag_ptr(_res);
24423         CHECK_ACCESS(_res_ptr);
24424         LDKCResult_OpenChannelDecodeErrorZ _res_conv = *(LDKCResult_OpenChannelDecodeErrorZ*)(_res_ptr);
24425         FREE(untag_ptr(_res));
24426         CResult_OpenChannelDecodeErrorZ_free(_res_conv);
24427 }
24428
24429 static inline uint64_t CResult_OpenChannelDecodeErrorZ_clone_ptr(LDKCResult_OpenChannelDecodeErrorZ *NONNULL_PTR arg) {
24430         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
24431         *ret_conv = CResult_OpenChannelDecodeErrorZ_clone(arg);
24432         return tag_ptr(ret_conv, true);
24433 }
24434 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24435         LDKCResult_OpenChannelDecodeErrorZ* arg_conv = (LDKCResult_OpenChannelDecodeErrorZ*)untag_ptr(arg);
24436         int64_t ret_conv = CResult_OpenChannelDecodeErrorZ_clone_ptr(arg_conv);
24437         return ret_conv;
24438 }
24439
24440 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24441         LDKCResult_OpenChannelDecodeErrorZ* orig_conv = (LDKCResult_OpenChannelDecodeErrorZ*)untag_ptr(orig);
24442         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
24443         *ret_conv = CResult_OpenChannelDecodeErrorZ_clone(orig_conv);
24444         return tag_ptr(ret_conv, true);
24445 }
24446
24447 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
24448         LDKRevokeAndACK o_conv;
24449         o_conv.inner = untag_ptr(o);
24450         o_conv.is_owned = ptr_is_owned(o);
24451         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
24452         o_conv = RevokeAndACK_clone(&o_conv);
24453         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
24454         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_ok(o_conv);
24455         return tag_ptr(ret_conv, true);
24456 }
24457
24458 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
24459         void* e_ptr = untag_ptr(e);
24460         CHECK_ACCESS(e_ptr);
24461         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
24462         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
24463         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
24464         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_err(e_conv);
24465         return tag_ptr(ret_conv, true);
24466 }
24467
24468 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
24469         LDKCResult_RevokeAndACKDecodeErrorZ* o_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)untag_ptr(o);
24470         jboolean ret_conv = CResult_RevokeAndACKDecodeErrorZ_is_ok(o_conv);
24471         return ret_conv;
24472 }
24473
24474 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
24475         if (!ptr_is_owned(_res)) return;
24476         void* _res_ptr = untag_ptr(_res);
24477         CHECK_ACCESS(_res_ptr);
24478         LDKCResult_RevokeAndACKDecodeErrorZ _res_conv = *(LDKCResult_RevokeAndACKDecodeErrorZ*)(_res_ptr);
24479         FREE(untag_ptr(_res));
24480         CResult_RevokeAndACKDecodeErrorZ_free(_res_conv);
24481 }
24482
24483 static inline uint64_t CResult_RevokeAndACKDecodeErrorZ_clone_ptr(LDKCResult_RevokeAndACKDecodeErrorZ *NONNULL_PTR arg) {
24484         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
24485         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_clone(arg);
24486         return tag_ptr(ret_conv, true);
24487 }
24488 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24489         LDKCResult_RevokeAndACKDecodeErrorZ* arg_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)untag_ptr(arg);
24490         int64_t ret_conv = CResult_RevokeAndACKDecodeErrorZ_clone_ptr(arg_conv);
24491         return ret_conv;
24492 }
24493
24494 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24495         LDKCResult_RevokeAndACKDecodeErrorZ* orig_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)untag_ptr(orig);
24496         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
24497         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_clone(orig_conv);
24498         return tag_ptr(ret_conv, true);
24499 }
24500
24501 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
24502         LDKShutdown o_conv;
24503         o_conv.inner = untag_ptr(o);
24504         o_conv.is_owned = ptr_is_owned(o);
24505         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
24506         o_conv = Shutdown_clone(&o_conv);
24507         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
24508         *ret_conv = CResult_ShutdownDecodeErrorZ_ok(o_conv);
24509         return tag_ptr(ret_conv, true);
24510 }
24511
24512 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
24513         void* e_ptr = untag_ptr(e);
24514         CHECK_ACCESS(e_ptr);
24515         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
24516         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
24517         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
24518         *ret_conv = CResult_ShutdownDecodeErrorZ_err(e_conv);
24519         return tag_ptr(ret_conv, true);
24520 }
24521
24522 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
24523         LDKCResult_ShutdownDecodeErrorZ* o_conv = (LDKCResult_ShutdownDecodeErrorZ*)untag_ptr(o);
24524         jboolean ret_conv = CResult_ShutdownDecodeErrorZ_is_ok(o_conv);
24525         return ret_conv;
24526 }
24527
24528 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
24529         if (!ptr_is_owned(_res)) return;
24530         void* _res_ptr = untag_ptr(_res);
24531         CHECK_ACCESS(_res_ptr);
24532         LDKCResult_ShutdownDecodeErrorZ _res_conv = *(LDKCResult_ShutdownDecodeErrorZ*)(_res_ptr);
24533         FREE(untag_ptr(_res));
24534         CResult_ShutdownDecodeErrorZ_free(_res_conv);
24535 }
24536
24537 static inline uint64_t CResult_ShutdownDecodeErrorZ_clone_ptr(LDKCResult_ShutdownDecodeErrorZ *NONNULL_PTR arg) {
24538         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
24539         *ret_conv = CResult_ShutdownDecodeErrorZ_clone(arg);
24540         return tag_ptr(ret_conv, true);
24541 }
24542 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24543         LDKCResult_ShutdownDecodeErrorZ* arg_conv = (LDKCResult_ShutdownDecodeErrorZ*)untag_ptr(arg);
24544         int64_t ret_conv = CResult_ShutdownDecodeErrorZ_clone_ptr(arg_conv);
24545         return ret_conv;
24546 }
24547
24548 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24549         LDKCResult_ShutdownDecodeErrorZ* orig_conv = (LDKCResult_ShutdownDecodeErrorZ*)untag_ptr(orig);
24550         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
24551         *ret_conv = CResult_ShutdownDecodeErrorZ_clone(orig_conv);
24552         return tag_ptr(ret_conv, true);
24553 }
24554
24555 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
24556         LDKUpdateFailHTLC o_conv;
24557         o_conv.inner = untag_ptr(o);
24558         o_conv.is_owned = ptr_is_owned(o);
24559         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
24560         o_conv = UpdateFailHTLC_clone(&o_conv);
24561         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
24562         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_ok(o_conv);
24563         return tag_ptr(ret_conv, true);
24564 }
24565
24566 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
24567         void* e_ptr = untag_ptr(e);
24568         CHECK_ACCESS(e_ptr);
24569         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
24570         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
24571         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
24572         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_err(e_conv);
24573         return tag_ptr(ret_conv, true);
24574 }
24575
24576 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
24577         LDKCResult_UpdateFailHTLCDecodeErrorZ* o_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)untag_ptr(o);
24578         jboolean ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_is_ok(o_conv);
24579         return ret_conv;
24580 }
24581
24582 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
24583         if (!ptr_is_owned(_res)) return;
24584         void* _res_ptr = untag_ptr(_res);
24585         CHECK_ACCESS(_res_ptr);
24586         LDKCResult_UpdateFailHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFailHTLCDecodeErrorZ*)(_res_ptr);
24587         FREE(untag_ptr(_res));
24588         CResult_UpdateFailHTLCDecodeErrorZ_free(_res_conv);
24589 }
24590
24591 static inline uint64_t CResult_UpdateFailHTLCDecodeErrorZ_clone_ptr(LDKCResult_UpdateFailHTLCDecodeErrorZ *NONNULL_PTR arg) {
24592         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
24593         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_clone(arg);
24594         return tag_ptr(ret_conv, true);
24595 }
24596 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24597         LDKCResult_UpdateFailHTLCDecodeErrorZ* arg_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)untag_ptr(arg);
24598         int64_t ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_clone_ptr(arg_conv);
24599         return ret_conv;
24600 }
24601
24602 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24603         LDKCResult_UpdateFailHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)untag_ptr(orig);
24604         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
24605         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_clone(orig_conv);
24606         return tag_ptr(ret_conv, true);
24607 }
24608
24609 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
24610         LDKUpdateFailMalformedHTLC o_conv;
24611         o_conv.inner = untag_ptr(o);
24612         o_conv.is_owned = ptr_is_owned(o);
24613         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
24614         o_conv = UpdateFailMalformedHTLC_clone(&o_conv);
24615         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
24616         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_ok(o_conv);
24617         return tag_ptr(ret_conv, true);
24618 }
24619
24620 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
24621         void* e_ptr = untag_ptr(e);
24622         CHECK_ACCESS(e_ptr);
24623         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
24624         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
24625         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
24626         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_err(e_conv);
24627         return tag_ptr(ret_conv, true);
24628 }
24629
24630 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
24631         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* o_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)untag_ptr(o);
24632         jboolean ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_is_ok(o_conv);
24633         return ret_conv;
24634 }
24635
24636 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
24637         if (!ptr_is_owned(_res)) return;
24638         void* _res_ptr = untag_ptr(_res);
24639         CHECK_ACCESS(_res_ptr);
24640         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(_res_ptr);
24641         FREE(untag_ptr(_res));
24642         CResult_UpdateFailMalformedHTLCDecodeErrorZ_free(_res_conv);
24643 }
24644
24645 static inline uint64_t CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone_ptr(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *NONNULL_PTR arg) {
24646         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
24647         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone(arg);
24648         return tag_ptr(ret_conv, true);
24649 }
24650 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24651         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* arg_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)untag_ptr(arg);
24652         int64_t ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone_ptr(arg_conv);
24653         return ret_conv;
24654 }
24655
24656 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24657         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)untag_ptr(orig);
24658         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
24659         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone(orig_conv);
24660         return tag_ptr(ret_conv, true);
24661 }
24662
24663 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
24664         LDKUpdateFee o_conv;
24665         o_conv.inner = untag_ptr(o);
24666         o_conv.is_owned = ptr_is_owned(o);
24667         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
24668         o_conv = UpdateFee_clone(&o_conv);
24669         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
24670         *ret_conv = CResult_UpdateFeeDecodeErrorZ_ok(o_conv);
24671         return tag_ptr(ret_conv, true);
24672 }
24673
24674 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
24675         void* e_ptr = untag_ptr(e);
24676         CHECK_ACCESS(e_ptr);
24677         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
24678         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
24679         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
24680         *ret_conv = CResult_UpdateFeeDecodeErrorZ_err(e_conv);
24681         return tag_ptr(ret_conv, true);
24682 }
24683
24684 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
24685         LDKCResult_UpdateFeeDecodeErrorZ* o_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)untag_ptr(o);
24686         jboolean ret_conv = CResult_UpdateFeeDecodeErrorZ_is_ok(o_conv);
24687         return ret_conv;
24688 }
24689
24690 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
24691         if (!ptr_is_owned(_res)) return;
24692         void* _res_ptr = untag_ptr(_res);
24693         CHECK_ACCESS(_res_ptr);
24694         LDKCResult_UpdateFeeDecodeErrorZ _res_conv = *(LDKCResult_UpdateFeeDecodeErrorZ*)(_res_ptr);
24695         FREE(untag_ptr(_res));
24696         CResult_UpdateFeeDecodeErrorZ_free(_res_conv);
24697 }
24698
24699 static inline uint64_t CResult_UpdateFeeDecodeErrorZ_clone_ptr(LDKCResult_UpdateFeeDecodeErrorZ *NONNULL_PTR arg) {
24700         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
24701         *ret_conv = CResult_UpdateFeeDecodeErrorZ_clone(arg);
24702         return tag_ptr(ret_conv, true);
24703 }
24704 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24705         LDKCResult_UpdateFeeDecodeErrorZ* arg_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)untag_ptr(arg);
24706         int64_t ret_conv = CResult_UpdateFeeDecodeErrorZ_clone_ptr(arg_conv);
24707         return ret_conv;
24708 }
24709
24710 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24711         LDKCResult_UpdateFeeDecodeErrorZ* orig_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)untag_ptr(orig);
24712         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
24713         *ret_conv = CResult_UpdateFeeDecodeErrorZ_clone(orig_conv);
24714         return tag_ptr(ret_conv, true);
24715 }
24716
24717 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
24718         LDKUpdateFulfillHTLC o_conv;
24719         o_conv.inner = untag_ptr(o);
24720         o_conv.is_owned = ptr_is_owned(o);
24721         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
24722         o_conv = UpdateFulfillHTLC_clone(&o_conv);
24723         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
24724         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_ok(o_conv);
24725         return tag_ptr(ret_conv, true);
24726 }
24727
24728 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
24729         void* e_ptr = untag_ptr(e);
24730         CHECK_ACCESS(e_ptr);
24731         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
24732         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
24733         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
24734         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_err(e_conv);
24735         return tag_ptr(ret_conv, true);
24736 }
24737
24738 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
24739         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* o_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)untag_ptr(o);
24740         jboolean ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_is_ok(o_conv);
24741         return ret_conv;
24742 }
24743
24744 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
24745         if (!ptr_is_owned(_res)) return;
24746         void* _res_ptr = untag_ptr(_res);
24747         CHECK_ACCESS(_res_ptr);
24748         LDKCResult_UpdateFulfillHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(_res_ptr);
24749         FREE(untag_ptr(_res));
24750         CResult_UpdateFulfillHTLCDecodeErrorZ_free(_res_conv);
24751 }
24752
24753 static inline uint64_t CResult_UpdateFulfillHTLCDecodeErrorZ_clone_ptr(LDKCResult_UpdateFulfillHTLCDecodeErrorZ *NONNULL_PTR arg) {
24754         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
24755         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_clone(arg);
24756         return tag_ptr(ret_conv, true);
24757 }
24758 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24759         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* arg_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)untag_ptr(arg);
24760         int64_t ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_clone_ptr(arg_conv);
24761         return ret_conv;
24762 }
24763
24764 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24765         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)untag_ptr(orig);
24766         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
24767         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_clone(orig_conv);
24768         return tag_ptr(ret_conv, true);
24769 }
24770
24771 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
24772         LDKUpdateAddHTLC o_conv;
24773         o_conv.inner = untag_ptr(o);
24774         o_conv.is_owned = ptr_is_owned(o);
24775         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
24776         o_conv = UpdateAddHTLC_clone(&o_conv);
24777         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
24778         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_ok(o_conv);
24779         return tag_ptr(ret_conv, true);
24780 }
24781
24782 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
24783         void* e_ptr = untag_ptr(e);
24784         CHECK_ACCESS(e_ptr);
24785         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
24786         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
24787         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
24788         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_err(e_conv);
24789         return tag_ptr(ret_conv, true);
24790 }
24791
24792 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
24793         LDKCResult_UpdateAddHTLCDecodeErrorZ* o_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)untag_ptr(o);
24794         jboolean ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_is_ok(o_conv);
24795         return ret_conv;
24796 }
24797
24798 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
24799         if (!ptr_is_owned(_res)) return;
24800         void* _res_ptr = untag_ptr(_res);
24801         CHECK_ACCESS(_res_ptr);
24802         LDKCResult_UpdateAddHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateAddHTLCDecodeErrorZ*)(_res_ptr);
24803         FREE(untag_ptr(_res));
24804         CResult_UpdateAddHTLCDecodeErrorZ_free(_res_conv);
24805 }
24806
24807 static inline uint64_t CResult_UpdateAddHTLCDecodeErrorZ_clone_ptr(LDKCResult_UpdateAddHTLCDecodeErrorZ *NONNULL_PTR arg) {
24808         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
24809         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_clone(arg);
24810         return tag_ptr(ret_conv, true);
24811 }
24812 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24813         LDKCResult_UpdateAddHTLCDecodeErrorZ* arg_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)untag_ptr(arg);
24814         int64_t ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_clone_ptr(arg_conv);
24815         return ret_conv;
24816 }
24817
24818 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24819         LDKCResult_UpdateAddHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)untag_ptr(orig);
24820         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
24821         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_clone(orig_conv);
24822         return tag_ptr(ret_conv, true);
24823 }
24824
24825 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OnionMessageDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
24826         LDKOnionMessage o_conv;
24827         o_conv.inner = untag_ptr(o);
24828         o_conv.is_owned = ptr_is_owned(o);
24829         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
24830         o_conv = OnionMessage_clone(&o_conv);
24831         LDKCResult_OnionMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OnionMessageDecodeErrorZ), "LDKCResult_OnionMessageDecodeErrorZ");
24832         *ret_conv = CResult_OnionMessageDecodeErrorZ_ok(o_conv);
24833         return tag_ptr(ret_conv, true);
24834 }
24835
24836 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OnionMessageDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
24837         void* e_ptr = untag_ptr(e);
24838         CHECK_ACCESS(e_ptr);
24839         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
24840         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
24841         LDKCResult_OnionMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OnionMessageDecodeErrorZ), "LDKCResult_OnionMessageDecodeErrorZ");
24842         *ret_conv = CResult_OnionMessageDecodeErrorZ_err(e_conv);
24843         return tag_ptr(ret_conv, true);
24844 }
24845
24846 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1OnionMessageDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
24847         LDKCResult_OnionMessageDecodeErrorZ* o_conv = (LDKCResult_OnionMessageDecodeErrorZ*)untag_ptr(o);
24848         jboolean ret_conv = CResult_OnionMessageDecodeErrorZ_is_ok(o_conv);
24849         return ret_conv;
24850 }
24851
24852 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1OnionMessageDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
24853         if (!ptr_is_owned(_res)) return;
24854         void* _res_ptr = untag_ptr(_res);
24855         CHECK_ACCESS(_res_ptr);
24856         LDKCResult_OnionMessageDecodeErrorZ _res_conv = *(LDKCResult_OnionMessageDecodeErrorZ*)(_res_ptr);
24857         FREE(untag_ptr(_res));
24858         CResult_OnionMessageDecodeErrorZ_free(_res_conv);
24859 }
24860
24861 static inline uint64_t CResult_OnionMessageDecodeErrorZ_clone_ptr(LDKCResult_OnionMessageDecodeErrorZ *NONNULL_PTR arg) {
24862         LDKCResult_OnionMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OnionMessageDecodeErrorZ), "LDKCResult_OnionMessageDecodeErrorZ");
24863         *ret_conv = CResult_OnionMessageDecodeErrorZ_clone(arg);
24864         return tag_ptr(ret_conv, true);
24865 }
24866 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OnionMessageDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24867         LDKCResult_OnionMessageDecodeErrorZ* arg_conv = (LDKCResult_OnionMessageDecodeErrorZ*)untag_ptr(arg);
24868         int64_t ret_conv = CResult_OnionMessageDecodeErrorZ_clone_ptr(arg_conv);
24869         return ret_conv;
24870 }
24871
24872 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OnionMessageDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24873         LDKCResult_OnionMessageDecodeErrorZ* orig_conv = (LDKCResult_OnionMessageDecodeErrorZ*)untag_ptr(orig);
24874         LDKCResult_OnionMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OnionMessageDecodeErrorZ), "LDKCResult_OnionMessageDecodeErrorZ");
24875         *ret_conv = CResult_OnionMessageDecodeErrorZ_clone(orig_conv);
24876         return tag_ptr(ret_conv, true);
24877 }
24878
24879 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
24880         LDKPing o_conv;
24881         o_conv.inner = untag_ptr(o);
24882         o_conv.is_owned = ptr_is_owned(o);
24883         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
24884         o_conv = Ping_clone(&o_conv);
24885         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
24886         *ret_conv = CResult_PingDecodeErrorZ_ok(o_conv);
24887         return tag_ptr(ret_conv, true);
24888 }
24889
24890 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
24891         void* e_ptr = untag_ptr(e);
24892         CHECK_ACCESS(e_ptr);
24893         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
24894         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
24895         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
24896         *ret_conv = CResult_PingDecodeErrorZ_err(e_conv);
24897         return tag_ptr(ret_conv, true);
24898 }
24899
24900 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
24901         LDKCResult_PingDecodeErrorZ* o_conv = (LDKCResult_PingDecodeErrorZ*)untag_ptr(o);
24902         jboolean ret_conv = CResult_PingDecodeErrorZ_is_ok(o_conv);
24903         return ret_conv;
24904 }
24905
24906 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
24907         if (!ptr_is_owned(_res)) return;
24908         void* _res_ptr = untag_ptr(_res);
24909         CHECK_ACCESS(_res_ptr);
24910         LDKCResult_PingDecodeErrorZ _res_conv = *(LDKCResult_PingDecodeErrorZ*)(_res_ptr);
24911         FREE(untag_ptr(_res));
24912         CResult_PingDecodeErrorZ_free(_res_conv);
24913 }
24914
24915 static inline uint64_t CResult_PingDecodeErrorZ_clone_ptr(LDKCResult_PingDecodeErrorZ *NONNULL_PTR arg) {
24916         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
24917         *ret_conv = CResult_PingDecodeErrorZ_clone(arg);
24918         return tag_ptr(ret_conv, true);
24919 }
24920 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24921         LDKCResult_PingDecodeErrorZ* arg_conv = (LDKCResult_PingDecodeErrorZ*)untag_ptr(arg);
24922         int64_t ret_conv = CResult_PingDecodeErrorZ_clone_ptr(arg_conv);
24923         return ret_conv;
24924 }
24925
24926 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24927         LDKCResult_PingDecodeErrorZ* orig_conv = (LDKCResult_PingDecodeErrorZ*)untag_ptr(orig);
24928         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
24929         *ret_conv = CResult_PingDecodeErrorZ_clone(orig_conv);
24930         return tag_ptr(ret_conv, true);
24931 }
24932
24933 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
24934         LDKPong o_conv;
24935         o_conv.inner = untag_ptr(o);
24936         o_conv.is_owned = ptr_is_owned(o);
24937         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
24938         o_conv = Pong_clone(&o_conv);
24939         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
24940         *ret_conv = CResult_PongDecodeErrorZ_ok(o_conv);
24941         return tag_ptr(ret_conv, true);
24942 }
24943
24944 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
24945         void* e_ptr = untag_ptr(e);
24946         CHECK_ACCESS(e_ptr);
24947         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
24948         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
24949         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
24950         *ret_conv = CResult_PongDecodeErrorZ_err(e_conv);
24951         return tag_ptr(ret_conv, true);
24952 }
24953
24954 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
24955         LDKCResult_PongDecodeErrorZ* o_conv = (LDKCResult_PongDecodeErrorZ*)untag_ptr(o);
24956         jboolean ret_conv = CResult_PongDecodeErrorZ_is_ok(o_conv);
24957         return ret_conv;
24958 }
24959
24960 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
24961         if (!ptr_is_owned(_res)) return;
24962         void* _res_ptr = untag_ptr(_res);
24963         CHECK_ACCESS(_res_ptr);
24964         LDKCResult_PongDecodeErrorZ _res_conv = *(LDKCResult_PongDecodeErrorZ*)(_res_ptr);
24965         FREE(untag_ptr(_res));
24966         CResult_PongDecodeErrorZ_free(_res_conv);
24967 }
24968
24969 static inline uint64_t CResult_PongDecodeErrorZ_clone_ptr(LDKCResult_PongDecodeErrorZ *NONNULL_PTR arg) {
24970         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
24971         *ret_conv = CResult_PongDecodeErrorZ_clone(arg);
24972         return tag_ptr(ret_conv, true);
24973 }
24974 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24975         LDKCResult_PongDecodeErrorZ* arg_conv = (LDKCResult_PongDecodeErrorZ*)untag_ptr(arg);
24976         int64_t ret_conv = CResult_PongDecodeErrorZ_clone_ptr(arg_conv);
24977         return ret_conv;
24978 }
24979
24980 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24981         LDKCResult_PongDecodeErrorZ* orig_conv = (LDKCResult_PongDecodeErrorZ*)untag_ptr(orig);
24982         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
24983         *ret_conv = CResult_PongDecodeErrorZ_clone(orig_conv);
24984         return tag_ptr(ret_conv, true);
24985 }
24986
24987 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
24988         LDKUnsignedChannelAnnouncement o_conv;
24989         o_conv.inner = untag_ptr(o);
24990         o_conv.is_owned = ptr_is_owned(o);
24991         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
24992         o_conv = UnsignedChannelAnnouncement_clone(&o_conv);
24993         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
24994         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_ok(o_conv);
24995         return tag_ptr(ret_conv, true);
24996 }
24997
24998 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
24999         void* e_ptr = untag_ptr(e);
25000         CHECK_ACCESS(e_ptr);
25001         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
25002         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
25003         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
25004         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_err(e_conv);
25005         return tag_ptr(ret_conv, true);
25006 }
25007
25008 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
25009         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* o_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)untag_ptr(o);
25010         jboolean ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_is_ok(o_conv);
25011         return ret_conv;
25012 }
25013
25014 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
25015         if (!ptr_is_owned(_res)) return;
25016         void* _res_ptr = untag_ptr(_res);
25017         CHECK_ACCESS(_res_ptr);
25018         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(_res_ptr);
25019         FREE(untag_ptr(_res));
25020         CResult_UnsignedChannelAnnouncementDecodeErrorZ_free(_res_conv);
25021 }
25022
25023 static inline uint64_t CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone_ptr(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *NONNULL_PTR arg) {
25024         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
25025         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone(arg);
25026         return tag_ptr(ret_conv, true);
25027 }
25028 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25029         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* arg_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)untag_ptr(arg);
25030         int64_t ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone_ptr(arg_conv);
25031         return ret_conv;
25032 }
25033
25034 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25035         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)untag_ptr(orig);
25036         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
25037         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone(orig_conv);
25038         return tag_ptr(ret_conv, true);
25039 }
25040
25041 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
25042         LDKChannelAnnouncement o_conv;
25043         o_conv.inner = untag_ptr(o);
25044         o_conv.is_owned = ptr_is_owned(o);
25045         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
25046         o_conv = ChannelAnnouncement_clone(&o_conv);
25047         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
25048         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_ok(o_conv);
25049         return tag_ptr(ret_conv, true);
25050 }
25051
25052 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
25053         void* e_ptr = untag_ptr(e);
25054         CHECK_ACCESS(e_ptr);
25055         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
25056         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
25057         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
25058         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_err(e_conv);
25059         return tag_ptr(ret_conv, true);
25060 }
25061
25062 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
25063         LDKCResult_ChannelAnnouncementDecodeErrorZ* o_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)untag_ptr(o);
25064         jboolean ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_is_ok(o_conv);
25065         return ret_conv;
25066 }
25067
25068 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
25069         if (!ptr_is_owned(_res)) return;
25070         void* _res_ptr = untag_ptr(_res);
25071         CHECK_ACCESS(_res_ptr);
25072         LDKCResult_ChannelAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_ChannelAnnouncementDecodeErrorZ*)(_res_ptr);
25073         FREE(untag_ptr(_res));
25074         CResult_ChannelAnnouncementDecodeErrorZ_free(_res_conv);
25075 }
25076
25077 static inline uint64_t CResult_ChannelAnnouncementDecodeErrorZ_clone_ptr(LDKCResult_ChannelAnnouncementDecodeErrorZ *NONNULL_PTR arg) {
25078         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
25079         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_clone(arg);
25080         return tag_ptr(ret_conv, true);
25081 }
25082 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25083         LDKCResult_ChannelAnnouncementDecodeErrorZ* arg_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)untag_ptr(arg);
25084         int64_t ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_clone_ptr(arg_conv);
25085         return ret_conv;
25086 }
25087
25088 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25089         LDKCResult_ChannelAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)untag_ptr(orig);
25090         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
25091         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_clone(orig_conv);
25092         return tag_ptr(ret_conv, true);
25093 }
25094
25095 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
25096         LDKUnsignedChannelUpdate o_conv;
25097         o_conv.inner = untag_ptr(o);
25098         o_conv.is_owned = ptr_is_owned(o);
25099         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
25100         o_conv = UnsignedChannelUpdate_clone(&o_conv);
25101         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
25102         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_ok(o_conv);
25103         return tag_ptr(ret_conv, true);
25104 }
25105
25106 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
25107         void* e_ptr = untag_ptr(e);
25108         CHECK_ACCESS(e_ptr);
25109         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
25110         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
25111         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
25112         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_err(e_conv);
25113         return tag_ptr(ret_conv, true);
25114 }
25115
25116 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
25117         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* o_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)untag_ptr(o);
25118         jboolean ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_is_ok(o_conv);
25119         return ret_conv;
25120 }
25121
25122 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
25123         if (!ptr_is_owned(_res)) return;
25124         void* _res_ptr = untag_ptr(_res);
25125         CHECK_ACCESS(_res_ptr);
25126         LDKCResult_UnsignedChannelUpdateDecodeErrorZ _res_conv = *(LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(_res_ptr);
25127         FREE(untag_ptr(_res));
25128         CResult_UnsignedChannelUpdateDecodeErrorZ_free(_res_conv);
25129 }
25130
25131 static inline uint64_t CResult_UnsignedChannelUpdateDecodeErrorZ_clone_ptr(LDKCResult_UnsignedChannelUpdateDecodeErrorZ *NONNULL_PTR arg) {
25132         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
25133         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_clone(arg);
25134         return tag_ptr(ret_conv, true);
25135 }
25136 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25137         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* arg_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)untag_ptr(arg);
25138         int64_t ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_clone_ptr(arg_conv);
25139         return ret_conv;
25140 }
25141
25142 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25143         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* orig_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)untag_ptr(orig);
25144         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
25145         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_clone(orig_conv);
25146         return tag_ptr(ret_conv, true);
25147 }
25148
25149 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
25150         LDKChannelUpdate o_conv;
25151         o_conv.inner = untag_ptr(o);
25152         o_conv.is_owned = ptr_is_owned(o);
25153         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
25154         o_conv = ChannelUpdate_clone(&o_conv);
25155         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
25156         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_ok(o_conv);
25157         return tag_ptr(ret_conv, true);
25158 }
25159
25160 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
25161         void* e_ptr = untag_ptr(e);
25162         CHECK_ACCESS(e_ptr);
25163         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
25164         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
25165         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
25166         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_err(e_conv);
25167         return tag_ptr(ret_conv, true);
25168 }
25169
25170 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
25171         LDKCResult_ChannelUpdateDecodeErrorZ* o_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)untag_ptr(o);
25172         jboolean ret_conv = CResult_ChannelUpdateDecodeErrorZ_is_ok(o_conv);
25173         return ret_conv;
25174 }
25175
25176 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
25177         if (!ptr_is_owned(_res)) return;
25178         void* _res_ptr = untag_ptr(_res);
25179         CHECK_ACCESS(_res_ptr);
25180         LDKCResult_ChannelUpdateDecodeErrorZ _res_conv = *(LDKCResult_ChannelUpdateDecodeErrorZ*)(_res_ptr);
25181         FREE(untag_ptr(_res));
25182         CResult_ChannelUpdateDecodeErrorZ_free(_res_conv);
25183 }
25184
25185 static inline uint64_t CResult_ChannelUpdateDecodeErrorZ_clone_ptr(LDKCResult_ChannelUpdateDecodeErrorZ *NONNULL_PTR arg) {
25186         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
25187         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_clone(arg);
25188         return tag_ptr(ret_conv, true);
25189 }
25190 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25191         LDKCResult_ChannelUpdateDecodeErrorZ* arg_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)untag_ptr(arg);
25192         int64_t ret_conv = CResult_ChannelUpdateDecodeErrorZ_clone_ptr(arg_conv);
25193         return ret_conv;
25194 }
25195
25196 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25197         LDKCResult_ChannelUpdateDecodeErrorZ* orig_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)untag_ptr(orig);
25198         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
25199         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_clone(orig_conv);
25200         return tag_ptr(ret_conv, true);
25201 }
25202
25203 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
25204         LDKErrorMessage o_conv;
25205         o_conv.inner = untag_ptr(o);
25206         o_conv.is_owned = ptr_is_owned(o);
25207         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
25208         o_conv = ErrorMessage_clone(&o_conv);
25209         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
25210         *ret_conv = CResult_ErrorMessageDecodeErrorZ_ok(o_conv);
25211         return tag_ptr(ret_conv, true);
25212 }
25213
25214 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
25215         void* e_ptr = untag_ptr(e);
25216         CHECK_ACCESS(e_ptr);
25217         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
25218         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
25219         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
25220         *ret_conv = CResult_ErrorMessageDecodeErrorZ_err(e_conv);
25221         return tag_ptr(ret_conv, true);
25222 }
25223
25224 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
25225         LDKCResult_ErrorMessageDecodeErrorZ* o_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)untag_ptr(o);
25226         jboolean ret_conv = CResult_ErrorMessageDecodeErrorZ_is_ok(o_conv);
25227         return ret_conv;
25228 }
25229
25230 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
25231         if (!ptr_is_owned(_res)) return;
25232         void* _res_ptr = untag_ptr(_res);
25233         CHECK_ACCESS(_res_ptr);
25234         LDKCResult_ErrorMessageDecodeErrorZ _res_conv = *(LDKCResult_ErrorMessageDecodeErrorZ*)(_res_ptr);
25235         FREE(untag_ptr(_res));
25236         CResult_ErrorMessageDecodeErrorZ_free(_res_conv);
25237 }
25238
25239 static inline uint64_t CResult_ErrorMessageDecodeErrorZ_clone_ptr(LDKCResult_ErrorMessageDecodeErrorZ *NONNULL_PTR arg) {
25240         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
25241         *ret_conv = CResult_ErrorMessageDecodeErrorZ_clone(arg);
25242         return tag_ptr(ret_conv, true);
25243 }
25244 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25245         LDKCResult_ErrorMessageDecodeErrorZ* arg_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)untag_ptr(arg);
25246         int64_t ret_conv = CResult_ErrorMessageDecodeErrorZ_clone_ptr(arg_conv);
25247         return ret_conv;
25248 }
25249
25250 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25251         LDKCResult_ErrorMessageDecodeErrorZ* orig_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)untag_ptr(orig);
25252         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
25253         *ret_conv = CResult_ErrorMessageDecodeErrorZ_clone(orig_conv);
25254         return tag_ptr(ret_conv, true);
25255 }
25256
25257 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1WarningMessageDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
25258         LDKWarningMessage o_conv;
25259         o_conv.inner = untag_ptr(o);
25260         o_conv.is_owned = ptr_is_owned(o);
25261         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
25262         o_conv = WarningMessage_clone(&o_conv);
25263         LDKCResult_WarningMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_WarningMessageDecodeErrorZ), "LDKCResult_WarningMessageDecodeErrorZ");
25264         *ret_conv = CResult_WarningMessageDecodeErrorZ_ok(o_conv);
25265         return tag_ptr(ret_conv, true);
25266 }
25267
25268 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1WarningMessageDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
25269         void* e_ptr = untag_ptr(e);
25270         CHECK_ACCESS(e_ptr);
25271         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
25272         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
25273         LDKCResult_WarningMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_WarningMessageDecodeErrorZ), "LDKCResult_WarningMessageDecodeErrorZ");
25274         *ret_conv = CResult_WarningMessageDecodeErrorZ_err(e_conv);
25275         return tag_ptr(ret_conv, true);
25276 }
25277
25278 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1WarningMessageDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
25279         LDKCResult_WarningMessageDecodeErrorZ* o_conv = (LDKCResult_WarningMessageDecodeErrorZ*)untag_ptr(o);
25280         jboolean ret_conv = CResult_WarningMessageDecodeErrorZ_is_ok(o_conv);
25281         return ret_conv;
25282 }
25283
25284 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1WarningMessageDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
25285         if (!ptr_is_owned(_res)) return;
25286         void* _res_ptr = untag_ptr(_res);
25287         CHECK_ACCESS(_res_ptr);
25288         LDKCResult_WarningMessageDecodeErrorZ _res_conv = *(LDKCResult_WarningMessageDecodeErrorZ*)(_res_ptr);
25289         FREE(untag_ptr(_res));
25290         CResult_WarningMessageDecodeErrorZ_free(_res_conv);
25291 }
25292
25293 static inline uint64_t CResult_WarningMessageDecodeErrorZ_clone_ptr(LDKCResult_WarningMessageDecodeErrorZ *NONNULL_PTR arg) {
25294         LDKCResult_WarningMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_WarningMessageDecodeErrorZ), "LDKCResult_WarningMessageDecodeErrorZ");
25295         *ret_conv = CResult_WarningMessageDecodeErrorZ_clone(arg);
25296         return tag_ptr(ret_conv, true);
25297 }
25298 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1WarningMessageDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25299         LDKCResult_WarningMessageDecodeErrorZ* arg_conv = (LDKCResult_WarningMessageDecodeErrorZ*)untag_ptr(arg);
25300         int64_t ret_conv = CResult_WarningMessageDecodeErrorZ_clone_ptr(arg_conv);
25301         return ret_conv;
25302 }
25303
25304 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1WarningMessageDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25305         LDKCResult_WarningMessageDecodeErrorZ* orig_conv = (LDKCResult_WarningMessageDecodeErrorZ*)untag_ptr(orig);
25306         LDKCResult_WarningMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_WarningMessageDecodeErrorZ), "LDKCResult_WarningMessageDecodeErrorZ");
25307         *ret_conv = CResult_WarningMessageDecodeErrorZ_clone(orig_conv);
25308         return tag_ptr(ret_conv, true);
25309 }
25310
25311 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
25312         LDKUnsignedNodeAnnouncement o_conv;
25313         o_conv.inner = untag_ptr(o);
25314         o_conv.is_owned = ptr_is_owned(o);
25315         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
25316         o_conv = UnsignedNodeAnnouncement_clone(&o_conv);
25317         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
25318         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_ok(o_conv);
25319         return tag_ptr(ret_conv, true);
25320 }
25321
25322 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
25323         void* e_ptr = untag_ptr(e);
25324         CHECK_ACCESS(e_ptr);
25325         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
25326         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
25327         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
25328         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_err(e_conv);
25329         return tag_ptr(ret_conv, true);
25330 }
25331
25332 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
25333         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* o_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)untag_ptr(o);
25334         jboolean ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_is_ok(o_conv);
25335         return ret_conv;
25336 }
25337
25338 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
25339         if (!ptr_is_owned(_res)) return;
25340         void* _res_ptr = untag_ptr(_res);
25341         CHECK_ACCESS(_res_ptr);
25342         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(_res_ptr);
25343         FREE(untag_ptr(_res));
25344         CResult_UnsignedNodeAnnouncementDecodeErrorZ_free(_res_conv);
25345 }
25346
25347 static inline uint64_t CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone_ptr(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *NONNULL_PTR arg) {
25348         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
25349         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone(arg);
25350         return tag_ptr(ret_conv, true);
25351 }
25352 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25353         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* arg_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)untag_ptr(arg);
25354         int64_t ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone_ptr(arg_conv);
25355         return ret_conv;
25356 }
25357
25358 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25359         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)untag_ptr(orig);
25360         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
25361         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone(orig_conv);
25362         return tag_ptr(ret_conv, true);
25363 }
25364
25365 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
25366         LDKNodeAnnouncement o_conv;
25367         o_conv.inner = untag_ptr(o);
25368         o_conv.is_owned = ptr_is_owned(o);
25369         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
25370         o_conv = NodeAnnouncement_clone(&o_conv);
25371         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
25372         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_ok(o_conv);
25373         return tag_ptr(ret_conv, true);
25374 }
25375
25376 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
25377         void* e_ptr = untag_ptr(e);
25378         CHECK_ACCESS(e_ptr);
25379         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
25380         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
25381         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
25382         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_err(e_conv);
25383         return tag_ptr(ret_conv, true);
25384 }
25385
25386 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
25387         LDKCResult_NodeAnnouncementDecodeErrorZ* o_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)untag_ptr(o);
25388         jboolean ret_conv = CResult_NodeAnnouncementDecodeErrorZ_is_ok(o_conv);
25389         return ret_conv;
25390 }
25391
25392 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
25393         if (!ptr_is_owned(_res)) return;
25394         void* _res_ptr = untag_ptr(_res);
25395         CHECK_ACCESS(_res_ptr);
25396         LDKCResult_NodeAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_NodeAnnouncementDecodeErrorZ*)(_res_ptr);
25397         FREE(untag_ptr(_res));
25398         CResult_NodeAnnouncementDecodeErrorZ_free(_res_conv);
25399 }
25400
25401 static inline uint64_t CResult_NodeAnnouncementDecodeErrorZ_clone_ptr(LDKCResult_NodeAnnouncementDecodeErrorZ *NONNULL_PTR arg) {
25402         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
25403         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_clone(arg);
25404         return tag_ptr(ret_conv, true);
25405 }
25406 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25407         LDKCResult_NodeAnnouncementDecodeErrorZ* arg_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)untag_ptr(arg);
25408         int64_t ret_conv = CResult_NodeAnnouncementDecodeErrorZ_clone_ptr(arg_conv);
25409         return ret_conv;
25410 }
25411
25412 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25413         LDKCResult_NodeAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)untag_ptr(orig);
25414         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
25415         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_clone(orig_conv);
25416         return tag_ptr(ret_conv, true);
25417 }
25418
25419 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
25420         LDKQueryShortChannelIds o_conv;
25421         o_conv.inner = untag_ptr(o);
25422         o_conv.is_owned = ptr_is_owned(o);
25423         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
25424         o_conv = QueryShortChannelIds_clone(&o_conv);
25425         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
25426         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_ok(o_conv);
25427         return tag_ptr(ret_conv, true);
25428 }
25429
25430 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
25431         void* e_ptr = untag_ptr(e);
25432         CHECK_ACCESS(e_ptr);
25433         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
25434         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
25435         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
25436         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_err(e_conv);
25437         return tag_ptr(ret_conv, true);
25438 }
25439
25440 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
25441         LDKCResult_QueryShortChannelIdsDecodeErrorZ* o_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)untag_ptr(o);
25442         jboolean ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_is_ok(o_conv);
25443         return ret_conv;
25444 }
25445
25446 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
25447         if (!ptr_is_owned(_res)) return;
25448         void* _res_ptr = untag_ptr(_res);
25449         CHECK_ACCESS(_res_ptr);
25450         LDKCResult_QueryShortChannelIdsDecodeErrorZ _res_conv = *(LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(_res_ptr);
25451         FREE(untag_ptr(_res));
25452         CResult_QueryShortChannelIdsDecodeErrorZ_free(_res_conv);
25453 }
25454
25455 static inline uint64_t CResult_QueryShortChannelIdsDecodeErrorZ_clone_ptr(LDKCResult_QueryShortChannelIdsDecodeErrorZ *NONNULL_PTR arg) {
25456         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
25457         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_clone(arg);
25458         return tag_ptr(ret_conv, true);
25459 }
25460 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25461         LDKCResult_QueryShortChannelIdsDecodeErrorZ* arg_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)untag_ptr(arg);
25462         int64_t ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_clone_ptr(arg_conv);
25463         return ret_conv;
25464 }
25465
25466 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25467         LDKCResult_QueryShortChannelIdsDecodeErrorZ* orig_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)untag_ptr(orig);
25468         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
25469         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_clone(orig_conv);
25470         return tag_ptr(ret_conv, true);
25471 }
25472
25473 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
25474         LDKReplyShortChannelIdsEnd o_conv;
25475         o_conv.inner = untag_ptr(o);
25476         o_conv.is_owned = ptr_is_owned(o);
25477         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
25478         o_conv = ReplyShortChannelIdsEnd_clone(&o_conv);
25479         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
25480         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_ok(o_conv);
25481         return tag_ptr(ret_conv, true);
25482 }
25483
25484 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
25485         void* e_ptr = untag_ptr(e);
25486         CHECK_ACCESS(e_ptr);
25487         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
25488         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
25489         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
25490         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_err(e_conv);
25491         return tag_ptr(ret_conv, true);
25492 }
25493
25494 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
25495         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* o_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)untag_ptr(o);
25496         jboolean ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_is_ok(o_conv);
25497         return ret_conv;
25498 }
25499
25500 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
25501         if (!ptr_is_owned(_res)) return;
25502         void* _res_ptr = untag_ptr(_res);
25503         CHECK_ACCESS(_res_ptr);
25504         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ _res_conv = *(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(_res_ptr);
25505         FREE(untag_ptr(_res));
25506         CResult_ReplyShortChannelIdsEndDecodeErrorZ_free(_res_conv);
25507 }
25508
25509 static inline uint64_t CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone_ptr(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *NONNULL_PTR arg) {
25510         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
25511         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone(arg);
25512         return tag_ptr(ret_conv, true);
25513 }
25514 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25515         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* arg_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)untag_ptr(arg);
25516         int64_t ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone_ptr(arg_conv);
25517         return ret_conv;
25518 }
25519
25520 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25521         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* orig_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)untag_ptr(orig);
25522         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
25523         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone(orig_conv);
25524         return tag_ptr(ret_conv, true);
25525 }
25526
25527 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
25528         LDKQueryChannelRange o_conv;
25529         o_conv.inner = untag_ptr(o);
25530         o_conv.is_owned = ptr_is_owned(o);
25531         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
25532         o_conv = QueryChannelRange_clone(&o_conv);
25533         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
25534         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_ok(o_conv);
25535         return tag_ptr(ret_conv, true);
25536 }
25537
25538 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
25539         void* e_ptr = untag_ptr(e);
25540         CHECK_ACCESS(e_ptr);
25541         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
25542         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
25543         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
25544         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_err(e_conv);
25545         return tag_ptr(ret_conv, true);
25546 }
25547
25548 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
25549         LDKCResult_QueryChannelRangeDecodeErrorZ* o_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)untag_ptr(o);
25550         jboolean ret_conv = CResult_QueryChannelRangeDecodeErrorZ_is_ok(o_conv);
25551         return ret_conv;
25552 }
25553
25554 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
25555         if (!ptr_is_owned(_res)) return;
25556         void* _res_ptr = untag_ptr(_res);
25557         CHECK_ACCESS(_res_ptr);
25558         LDKCResult_QueryChannelRangeDecodeErrorZ _res_conv = *(LDKCResult_QueryChannelRangeDecodeErrorZ*)(_res_ptr);
25559         FREE(untag_ptr(_res));
25560         CResult_QueryChannelRangeDecodeErrorZ_free(_res_conv);
25561 }
25562
25563 static inline uint64_t CResult_QueryChannelRangeDecodeErrorZ_clone_ptr(LDKCResult_QueryChannelRangeDecodeErrorZ *NONNULL_PTR arg) {
25564         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
25565         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_clone(arg);
25566         return tag_ptr(ret_conv, true);
25567 }
25568 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25569         LDKCResult_QueryChannelRangeDecodeErrorZ* arg_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)untag_ptr(arg);
25570         int64_t ret_conv = CResult_QueryChannelRangeDecodeErrorZ_clone_ptr(arg_conv);
25571         return ret_conv;
25572 }
25573
25574 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25575         LDKCResult_QueryChannelRangeDecodeErrorZ* orig_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)untag_ptr(orig);
25576         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
25577         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_clone(orig_conv);
25578         return tag_ptr(ret_conv, true);
25579 }
25580
25581 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
25582         LDKReplyChannelRange o_conv;
25583         o_conv.inner = untag_ptr(o);
25584         o_conv.is_owned = ptr_is_owned(o);
25585         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
25586         o_conv = ReplyChannelRange_clone(&o_conv);
25587         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
25588         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_ok(o_conv);
25589         return tag_ptr(ret_conv, true);
25590 }
25591
25592 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
25593         void* e_ptr = untag_ptr(e);
25594         CHECK_ACCESS(e_ptr);
25595         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
25596         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
25597         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
25598         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_err(e_conv);
25599         return tag_ptr(ret_conv, true);
25600 }
25601
25602 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
25603         LDKCResult_ReplyChannelRangeDecodeErrorZ* o_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)untag_ptr(o);
25604         jboolean ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_is_ok(o_conv);
25605         return ret_conv;
25606 }
25607
25608 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
25609         if (!ptr_is_owned(_res)) return;
25610         void* _res_ptr = untag_ptr(_res);
25611         CHECK_ACCESS(_res_ptr);
25612         LDKCResult_ReplyChannelRangeDecodeErrorZ _res_conv = *(LDKCResult_ReplyChannelRangeDecodeErrorZ*)(_res_ptr);
25613         FREE(untag_ptr(_res));
25614         CResult_ReplyChannelRangeDecodeErrorZ_free(_res_conv);
25615 }
25616
25617 static inline uint64_t CResult_ReplyChannelRangeDecodeErrorZ_clone_ptr(LDKCResult_ReplyChannelRangeDecodeErrorZ *NONNULL_PTR arg) {
25618         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
25619         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_clone(arg);
25620         return tag_ptr(ret_conv, true);
25621 }
25622 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25623         LDKCResult_ReplyChannelRangeDecodeErrorZ* arg_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)untag_ptr(arg);
25624         int64_t ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_clone_ptr(arg_conv);
25625         return ret_conv;
25626 }
25627
25628 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25629         LDKCResult_ReplyChannelRangeDecodeErrorZ* orig_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)untag_ptr(orig);
25630         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
25631         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_clone(orig_conv);
25632         return tag_ptr(ret_conv, true);
25633 }
25634
25635 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
25636         LDKGossipTimestampFilter o_conv;
25637         o_conv.inner = untag_ptr(o);
25638         o_conv.is_owned = ptr_is_owned(o);
25639         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
25640         o_conv = GossipTimestampFilter_clone(&o_conv);
25641         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
25642         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_ok(o_conv);
25643         return tag_ptr(ret_conv, true);
25644 }
25645
25646 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
25647         void* e_ptr = untag_ptr(e);
25648         CHECK_ACCESS(e_ptr);
25649         LDKDecodeError e_conv = *(LDKDecodeError*)(e_ptr);
25650         e_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(e));
25651         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
25652         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_err(e_conv);
25653         return tag_ptr(ret_conv, true);
25654 }
25655
25656 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
25657         LDKCResult_GossipTimestampFilterDecodeErrorZ* o_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)untag_ptr(o);
25658         jboolean ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_is_ok(o_conv);
25659         return ret_conv;
25660 }
25661
25662 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
25663         if (!ptr_is_owned(_res)) return;
25664         void* _res_ptr = untag_ptr(_res);
25665         CHECK_ACCESS(_res_ptr);
25666         LDKCResult_GossipTimestampFilterDecodeErrorZ _res_conv = *(LDKCResult_GossipTimestampFilterDecodeErrorZ*)(_res_ptr);
25667         FREE(untag_ptr(_res));
25668         CResult_GossipTimestampFilterDecodeErrorZ_free(_res_conv);
25669 }
25670
25671 static inline uint64_t CResult_GossipTimestampFilterDecodeErrorZ_clone_ptr(LDKCResult_GossipTimestampFilterDecodeErrorZ *NONNULL_PTR arg) {
25672         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
25673         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_clone(arg);
25674         return tag_ptr(ret_conv, true);
25675 }
25676 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25677         LDKCResult_GossipTimestampFilterDecodeErrorZ* arg_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)untag_ptr(arg);
25678         int64_t ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_clone_ptr(arg_conv);
25679         return ret_conv;
25680 }
25681
25682 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25683         LDKCResult_GossipTimestampFilterDecodeErrorZ* orig_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)untag_ptr(orig);
25684         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
25685         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_clone(orig_conv);
25686         return tag_ptr(ret_conv, true);
25687 }
25688
25689 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1PhantomRouteHintsZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
25690         LDKCVec_PhantomRouteHintsZ _res_constr;
25691         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
25692         if (_res_constr.datalen > 0)
25693                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKPhantomRouteHints), "LDKCVec_PhantomRouteHintsZ Elements");
25694         else
25695                 _res_constr.data = NULL;
25696         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
25697         for (size_t t = 0; t < _res_constr.datalen; t++) {
25698                 int64_t _res_conv_19 = _res_vals[t];
25699                 LDKPhantomRouteHints _res_conv_19_conv;
25700                 _res_conv_19_conv.inner = untag_ptr(_res_conv_19);
25701                 _res_conv_19_conv.is_owned = ptr_is_owned(_res_conv_19);
25702                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_19_conv);
25703                 _res_constr.data[t] = _res_conv_19_conv;
25704         }
25705         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
25706         CVec_PhantomRouteHintsZ_free(_res_constr);
25707 }
25708
25709 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
25710         LDKInvoice o_conv;
25711         o_conv.inner = untag_ptr(o);
25712         o_conv.is_owned = ptr_is_owned(o);
25713         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
25714         o_conv = Invoice_clone(&o_conv);
25715         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
25716         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_ok(o_conv);
25717         return tag_ptr(ret_conv, true);
25718 }
25719
25720 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
25721         void* e_ptr = untag_ptr(e);
25722         CHECK_ACCESS(e_ptr);
25723         LDKSignOrCreationError e_conv = *(LDKSignOrCreationError*)(e_ptr);
25724         e_conv = SignOrCreationError_clone((LDKSignOrCreationError*)untag_ptr(e));
25725         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
25726         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_err(e_conv);
25727         return tag_ptr(ret_conv, true);
25728 }
25729
25730 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
25731         LDKCResult_InvoiceSignOrCreationErrorZ* o_conv = (LDKCResult_InvoiceSignOrCreationErrorZ*)untag_ptr(o);
25732         jboolean ret_conv = CResult_InvoiceSignOrCreationErrorZ_is_ok(o_conv);
25733         return ret_conv;
25734 }
25735
25736 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
25737         if (!ptr_is_owned(_res)) return;
25738         void* _res_ptr = untag_ptr(_res);
25739         CHECK_ACCESS(_res_ptr);
25740         LDKCResult_InvoiceSignOrCreationErrorZ _res_conv = *(LDKCResult_InvoiceSignOrCreationErrorZ*)(_res_ptr);
25741         FREE(untag_ptr(_res));
25742         CResult_InvoiceSignOrCreationErrorZ_free(_res_conv);
25743 }
25744
25745 static inline uint64_t CResult_InvoiceSignOrCreationErrorZ_clone_ptr(LDKCResult_InvoiceSignOrCreationErrorZ *NONNULL_PTR arg) {
25746         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
25747         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_clone(arg);
25748         return tag_ptr(ret_conv, true);
25749 }
25750 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25751         LDKCResult_InvoiceSignOrCreationErrorZ* arg_conv = (LDKCResult_InvoiceSignOrCreationErrorZ*)untag_ptr(arg);
25752         int64_t ret_conv = CResult_InvoiceSignOrCreationErrorZ_clone_ptr(arg_conv);
25753         return ret_conv;
25754 }
25755
25756 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25757         LDKCResult_InvoiceSignOrCreationErrorZ* orig_conv = (LDKCResult_InvoiceSignOrCreationErrorZ*)untag_ptr(orig);
25758         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
25759         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_clone(orig_conv);
25760         return tag_ptr(ret_conv, true);
25761 }
25762
25763 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1FilterZ_1some(JNIEnv *env, jclass clz, int64_t o) {
25764         void* o_ptr = untag_ptr(o);
25765         CHECK_ACCESS(o_ptr);
25766         LDKFilter o_conv = *(LDKFilter*)(o_ptr);
25767         if (o_conv.free == LDKFilter_JCalls_free) {
25768                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
25769                 LDKFilter_JCalls_cloned(&o_conv);
25770         }
25771         LDKCOption_FilterZ *ret_copy = MALLOC(sizeof(LDKCOption_FilterZ), "LDKCOption_FilterZ");
25772         *ret_copy = COption_FilterZ_some(o_conv);
25773         int64_t ret_ref = tag_ptr(ret_copy, true);
25774         return ret_ref;
25775 }
25776
25777 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1FilterZ_1none(JNIEnv *env, jclass clz) {
25778         LDKCOption_FilterZ *ret_copy = MALLOC(sizeof(LDKCOption_FilterZ), "LDKCOption_FilterZ");
25779         *ret_copy = COption_FilterZ_none();
25780         int64_t ret_ref = tag_ptr(ret_copy, true);
25781         return ret_ref;
25782 }
25783
25784 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1FilterZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
25785         if (!ptr_is_owned(_res)) return;
25786         void* _res_ptr = untag_ptr(_res);
25787         CHECK_ACCESS(_res_ptr);
25788         LDKCOption_FilterZ _res_conv = *(LDKCOption_FilterZ*)(_res_ptr);
25789         FREE(untag_ptr(_res));
25790         COption_FilterZ_free(_res_conv);
25791 }
25792
25793 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1LockedChannelMonitorNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
25794         LDKLockedChannelMonitor o_conv;
25795         o_conv.inner = untag_ptr(o);
25796         o_conv.is_owned = ptr_is_owned(o);
25797         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
25798         // WARNING: we need a move here but no clone is available for LDKLockedChannelMonitor
25799         
25800         LDKCResult_LockedChannelMonitorNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_LockedChannelMonitorNoneZ), "LDKCResult_LockedChannelMonitorNoneZ");
25801         *ret_conv = CResult_LockedChannelMonitorNoneZ_ok(o_conv);
25802         return tag_ptr(ret_conv, true);
25803 }
25804
25805 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1LockedChannelMonitorNoneZ_1err(JNIEnv *env, jclass clz) {
25806         LDKCResult_LockedChannelMonitorNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_LockedChannelMonitorNoneZ), "LDKCResult_LockedChannelMonitorNoneZ");
25807         *ret_conv = CResult_LockedChannelMonitorNoneZ_err();
25808         return tag_ptr(ret_conv, true);
25809 }
25810
25811 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1LockedChannelMonitorNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
25812         LDKCResult_LockedChannelMonitorNoneZ* o_conv = (LDKCResult_LockedChannelMonitorNoneZ*)untag_ptr(o);
25813         jboolean ret_conv = CResult_LockedChannelMonitorNoneZ_is_ok(o_conv);
25814         return ret_conv;
25815 }
25816
25817 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1LockedChannelMonitorNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
25818         if (!ptr_is_owned(_res)) return;
25819         void* _res_ptr = untag_ptr(_res);
25820         CHECK_ACCESS(_res_ptr);
25821         LDKCResult_LockedChannelMonitorNoneZ _res_conv = *(LDKCResult_LockedChannelMonitorNoneZ*)(_res_ptr);
25822         FREE(untag_ptr(_res));
25823         CResult_LockedChannelMonitorNoneZ_free(_res_conv);
25824 }
25825
25826 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1OutPointZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
25827         LDKCVec_OutPointZ _res_constr;
25828         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
25829         if (_res_constr.datalen > 0)
25830                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKOutPoint), "LDKCVec_OutPointZ Elements");
25831         else
25832                 _res_constr.data = NULL;
25833         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
25834         for (size_t k = 0; k < _res_constr.datalen; k++) {
25835                 int64_t _res_conv_10 = _res_vals[k];
25836                 LDKOutPoint _res_conv_10_conv;
25837                 _res_conv_10_conv.inner = untag_ptr(_res_conv_10);
25838                 _res_conv_10_conv.is_owned = ptr_is_owned(_res_conv_10);
25839                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_10_conv);
25840                 _res_constr.data[k] = _res_conv_10_conv;
25841         }
25842         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
25843         CVec_OutPointZ_free(_res_constr);
25844 }
25845
25846 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1MonitorUpdateIdZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
25847         LDKCVec_MonitorUpdateIdZ _res_constr;
25848         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
25849         if (_res_constr.datalen > 0)
25850                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKMonitorUpdateId), "LDKCVec_MonitorUpdateIdZ Elements");
25851         else
25852                 _res_constr.data = NULL;
25853         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
25854         for (size_t r = 0; r < _res_constr.datalen; r++) {
25855                 int64_t _res_conv_17 = _res_vals[r];
25856                 LDKMonitorUpdateId _res_conv_17_conv;
25857                 _res_conv_17_conv.inner = untag_ptr(_res_conv_17);
25858                 _res_conv_17_conv.is_owned = ptr_is_owned(_res_conv_17);
25859                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_17_conv);
25860                 _res_constr.data[r] = _res_conv_17_conv;
25861         }
25862         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
25863         CVec_MonitorUpdateIdZ_free(_res_constr);
25864 }
25865
25866 static inline uint64_t C2Tuple_OutPointCVec_MonitorUpdateIdZZ_clone_ptr(LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ *NONNULL_PTR arg) {
25867         LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ), "LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ");
25868         *ret_conv = C2Tuple_OutPointCVec_MonitorUpdateIdZZ_clone(arg);
25869         return tag_ptr(ret_conv, true);
25870 }
25871 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointCVec_1MonitorUpdateIdZZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25872         LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ* arg_conv = (LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ*)untag_ptr(arg);
25873         int64_t ret_conv = C2Tuple_OutPointCVec_MonitorUpdateIdZZ_clone_ptr(arg_conv);
25874         return ret_conv;
25875 }
25876
25877 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointCVec_1MonitorUpdateIdZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25878         LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ* orig_conv = (LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ*)untag_ptr(orig);
25879         LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ), "LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ");
25880         *ret_conv = C2Tuple_OutPointCVec_MonitorUpdateIdZZ_clone(orig_conv);
25881         return tag_ptr(ret_conv, true);
25882 }
25883
25884 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointCVec_1MonitorUpdateIdZZ_1new(JNIEnv *env, jclass clz, int64_t a, int64_tArray b) {
25885         LDKOutPoint a_conv;
25886         a_conv.inner = untag_ptr(a);
25887         a_conv.is_owned = ptr_is_owned(a);
25888         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
25889         a_conv = OutPoint_clone(&a_conv);
25890         LDKCVec_MonitorUpdateIdZ b_constr;
25891         b_constr.datalen = (*env)->GetArrayLength(env, b);
25892         if (b_constr.datalen > 0)
25893                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKMonitorUpdateId), "LDKCVec_MonitorUpdateIdZ Elements");
25894         else
25895                 b_constr.data = NULL;
25896         int64_t* b_vals = (*env)->GetLongArrayElements (env, b, NULL);
25897         for (size_t r = 0; r < b_constr.datalen; r++) {
25898                 int64_t b_conv_17 = b_vals[r];
25899                 LDKMonitorUpdateId b_conv_17_conv;
25900                 b_conv_17_conv.inner = untag_ptr(b_conv_17);
25901                 b_conv_17_conv.is_owned = ptr_is_owned(b_conv_17);
25902                 CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv_17_conv);
25903                 b_conv_17_conv = MonitorUpdateId_clone(&b_conv_17_conv);
25904                 b_constr.data[r] = b_conv_17_conv;
25905         }
25906         (*env)->ReleaseLongArrayElements(env, b, b_vals, 0);
25907         LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ), "LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ");
25908         *ret_conv = C2Tuple_OutPointCVec_MonitorUpdateIdZZ_new(a_conv, b_constr);
25909         return tag_ptr(ret_conv, true);
25910 }
25911
25912 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointCVec_1MonitorUpdateIdZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
25913         if (!ptr_is_owned(_res)) return;
25914         void* _res_ptr = untag_ptr(_res);
25915         CHECK_ACCESS(_res_ptr);
25916         LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ _res_conv = *(LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ*)(_res_ptr);
25917         FREE(untag_ptr(_res));
25918         C2Tuple_OutPointCVec_MonitorUpdateIdZZ_free(_res_conv);
25919 }
25920
25921 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1OutPointCVec_1MonitorUpdateIdZZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
25922         LDKCVec_C2Tuple_OutPointCVec_MonitorUpdateIdZZZ _res_constr;
25923         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
25924         if (_res_constr.datalen > 0)
25925                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ), "LDKCVec_C2Tuple_OutPointCVec_MonitorUpdateIdZZZ Elements");
25926         else
25927                 _res_constr.data = NULL;
25928         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
25929         for (size_t p = 0; p < _res_constr.datalen; p++) {
25930                 int64_t _res_conv_41 = _res_vals[p];
25931                 void* _res_conv_41_ptr = untag_ptr(_res_conv_41);
25932                 CHECK_ACCESS(_res_conv_41_ptr);
25933                 LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ _res_conv_41_conv = *(LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ*)(_res_conv_41_ptr);
25934                 FREE(untag_ptr(_res_conv_41));
25935                 _res_constr.data[p] = _res_conv_41_conv;
25936         }
25937         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
25938         CVec_C2Tuple_OutPointCVec_MonitorUpdateIdZZZ_free(_res_constr);
25939 }
25940
25941 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentPurpose_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
25942         if (!ptr_is_owned(this_ptr)) return;
25943         void* this_ptr_ptr = untag_ptr(this_ptr);
25944         CHECK_ACCESS(this_ptr_ptr);
25945         LDKPaymentPurpose this_ptr_conv = *(LDKPaymentPurpose*)(this_ptr_ptr);
25946         FREE(untag_ptr(this_ptr));
25947         PaymentPurpose_free(this_ptr_conv);
25948 }
25949
25950 static inline uint64_t PaymentPurpose_clone_ptr(LDKPaymentPurpose *NONNULL_PTR arg) {
25951         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
25952         *ret_copy = PaymentPurpose_clone(arg);
25953         int64_t ret_ref = tag_ptr(ret_copy, true);
25954         return ret_ref;
25955 }
25956 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentPurpose_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25957         LDKPaymentPurpose* arg_conv = (LDKPaymentPurpose*)untag_ptr(arg);
25958         int64_t ret_conv = PaymentPurpose_clone_ptr(arg_conv);
25959         return ret_conv;
25960 }
25961
25962 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentPurpose_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25963         LDKPaymentPurpose* orig_conv = (LDKPaymentPurpose*)untag_ptr(orig);
25964         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
25965         *ret_copy = PaymentPurpose_clone(orig_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_PaymentPurpose_1invoice_1payment(JNIEnv *env, jclass clz, int8_tArray payment_preimage, int8_tArray payment_secret) {
25971         LDKThirtyTwoBytes payment_preimage_ref;
25972         CHECK((*env)->GetArrayLength(env, payment_preimage) == 32);
25973         (*env)->GetByteArrayRegion(env, payment_preimage, 0, 32, payment_preimage_ref.data);
25974         LDKThirtyTwoBytes payment_secret_ref;
25975         CHECK((*env)->GetArrayLength(env, payment_secret) == 32);
25976         (*env)->GetByteArrayRegion(env, payment_secret, 0, 32, payment_secret_ref.data);
25977         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
25978         *ret_copy = PaymentPurpose_invoice_payment(payment_preimage_ref, payment_secret_ref);
25979         int64_t ret_ref = tag_ptr(ret_copy, true);
25980         return ret_ref;
25981 }
25982
25983 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentPurpose_1spontaneous_1payment(JNIEnv *env, jclass clz, int8_tArray a) {
25984         LDKThirtyTwoBytes a_ref;
25985         CHECK((*env)->GetArrayLength(env, a) == 32);
25986         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
25987         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
25988         *ret_copy = PaymentPurpose_spontaneous_payment(a_ref);
25989         int64_t ret_ref = tag_ptr(ret_copy, true);
25990         return ret_ref;
25991 }
25992
25993 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_PaymentPurpose_1write(JNIEnv *env, jclass clz, int64_t obj) {
25994         LDKPaymentPurpose* obj_conv = (LDKPaymentPurpose*)untag_ptr(obj);
25995         LDKCVec_u8Z ret_var = PaymentPurpose_write(obj_conv);
25996         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
25997         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
25998         CVec_u8Z_free(ret_var);
25999         return ret_arr;
26000 }
26001
26002 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentPurpose_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
26003         LDKu8slice ser_ref;
26004         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
26005         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
26006         LDKCResult_PaymentPurposeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPurposeDecodeErrorZ), "LDKCResult_PaymentPurposeDecodeErrorZ");
26007         *ret_conv = PaymentPurpose_read(ser_ref);
26008         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
26009         return tag_ptr(ret_conv, true);
26010 }
26011
26012 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosureReason_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
26013         if (!ptr_is_owned(this_ptr)) return;
26014         void* this_ptr_ptr = untag_ptr(this_ptr);
26015         CHECK_ACCESS(this_ptr_ptr);
26016         LDKClosureReason this_ptr_conv = *(LDKClosureReason*)(this_ptr_ptr);
26017         FREE(untag_ptr(this_ptr));
26018         ClosureReason_free(this_ptr_conv);
26019 }
26020
26021 static inline uint64_t ClosureReason_clone_ptr(LDKClosureReason *NONNULL_PTR arg) {
26022         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
26023         *ret_copy = ClosureReason_clone(arg);
26024         int64_t ret_ref = tag_ptr(ret_copy, true);
26025         return ret_ref;
26026 }
26027 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
26028         LDKClosureReason* arg_conv = (LDKClosureReason*)untag_ptr(arg);
26029         int64_t ret_conv = ClosureReason_clone_ptr(arg_conv);
26030         return ret_conv;
26031 }
26032
26033 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26034         LDKClosureReason* orig_conv = (LDKClosureReason*)untag_ptr(orig);
26035         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
26036         *ret_copy = ClosureReason_clone(orig_conv);
26037         int64_t ret_ref = tag_ptr(ret_copy, true);
26038         return ret_ref;
26039 }
26040
26041 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1counterparty_1force_1closed(JNIEnv *env, jclass clz, jstring peer_msg) {
26042         LDKStr peer_msg_conv = java_to_owned_str(env, peer_msg);
26043         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
26044         *ret_copy = ClosureReason_counterparty_force_closed(peer_msg_conv);
26045         int64_t ret_ref = tag_ptr(ret_copy, true);
26046         return ret_ref;
26047 }
26048
26049 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1holder_1force_1closed(JNIEnv *env, jclass clz) {
26050         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
26051         *ret_copy = ClosureReason_holder_force_closed();
26052         int64_t ret_ref = tag_ptr(ret_copy, true);
26053         return ret_ref;
26054 }
26055
26056 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1cooperative_1closure(JNIEnv *env, jclass clz) {
26057         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
26058         *ret_copy = ClosureReason_cooperative_closure();
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_ClosureReason_1commitment_1tx_1confirmed(JNIEnv *env, jclass clz) {
26064         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
26065         *ret_copy = ClosureReason_commitment_tx_confirmed();
26066         int64_t ret_ref = tag_ptr(ret_copy, true);
26067         return ret_ref;
26068 }
26069
26070 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1funding_1timed_1out(JNIEnv *env, jclass clz) {
26071         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
26072         *ret_copy = ClosureReason_funding_timed_out();
26073         int64_t ret_ref = tag_ptr(ret_copy, true);
26074         return ret_ref;
26075 }
26076
26077 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1processing_1error(JNIEnv *env, jclass clz, jstring err) {
26078         LDKStr err_conv = java_to_owned_str(env, err);
26079         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
26080         *ret_copy = ClosureReason_processing_error(err_conv);
26081         int64_t ret_ref = tag_ptr(ret_copy, true);
26082         return ret_ref;
26083 }
26084
26085 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1disconnected_1peer(JNIEnv *env, jclass clz) {
26086         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
26087         *ret_copy = ClosureReason_disconnected_peer();
26088         int64_t ret_ref = tag_ptr(ret_copy, true);
26089         return ret_ref;
26090 }
26091
26092 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1outdated_1channel_1manager(JNIEnv *env, jclass clz) {
26093         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
26094         *ret_copy = ClosureReason_outdated_channel_manager();
26095         int64_t ret_ref = tag_ptr(ret_copy, true);
26096         return ret_ref;
26097 }
26098
26099 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ClosureReason_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
26100         LDKClosureReason* a_conv = (LDKClosureReason*)untag_ptr(a);
26101         LDKClosureReason* b_conv = (LDKClosureReason*)untag_ptr(b);
26102         jboolean ret_conv = ClosureReason_eq(a_conv, b_conv);
26103         return ret_conv;
26104 }
26105
26106 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosureReason_1write(JNIEnv *env, jclass clz, int64_t obj) {
26107         LDKClosureReason* obj_conv = (LDKClosureReason*)untag_ptr(obj);
26108         LDKCVec_u8Z ret_var = ClosureReason_write(obj_conv);
26109         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
26110         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
26111         CVec_u8Z_free(ret_var);
26112         return ret_arr;
26113 }
26114
26115 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
26116         LDKu8slice ser_ref;
26117         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
26118         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
26119         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
26120         *ret_conv = ClosureReason_read(ser_ref);
26121         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
26122         return tag_ptr(ret_conv, true);
26123 }
26124
26125 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCDestination_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
26126         if (!ptr_is_owned(this_ptr)) return;
26127         void* this_ptr_ptr = untag_ptr(this_ptr);
26128         CHECK_ACCESS(this_ptr_ptr);
26129         LDKHTLCDestination this_ptr_conv = *(LDKHTLCDestination*)(this_ptr_ptr);
26130         FREE(untag_ptr(this_ptr));
26131         HTLCDestination_free(this_ptr_conv);
26132 }
26133
26134 static inline uint64_t HTLCDestination_clone_ptr(LDKHTLCDestination *NONNULL_PTR arg) {
26135         LDKHTLCDestination *ret_copy = MALLOC(sizeof(LDKHTLCDestination), "LDKHTLCDestination");
26136         *ret_copy = HTLCDestination_clone(arg);
26137         int64_t ret_ref = tag_ptr(ret_copy, true);
26138         return ret_ref;
26139 }
26140 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCDestination_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
26141         LDKHTLCDestination* arg_conv = (LDKHTLCDestination*)untag_ptr(arg);
26142         int64_t ret_conv = HTLCDestination_clone_ptr(arg_conv);
26143         return ret_conv;
26144 }
26145
26146 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCDestination_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26147         LDKHTLCDestination* orig_conv = (LDKHTLCDestination*)untag_ptr(orig);
26148         LDKHTLCDestination *ret_copy = MALLOC(sizeof(LDKHTLCDestination), "LDKHTLCDestination");
26149         *ret_copy = HTLCDestination_clone(orig_conv);
26150         int64_t ret_ref = tag_ptr(ret_copy, true);
26151         return ret_ref;
26152 }
26153
26154 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) {
26155         LDKPublicKey node_id_ref;
26156         CHECK((*env)->GetArrayLength(env, node_id) == 33);
26157         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
26158         LDKThirtyTwoBytes channel_id_ref;
26159         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
26160         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_ref.data);
26161         LDKHTLCDestination *ret_copy = MALLOC(sizeof(LDKHTLCDestination), "LDKHTLCDestination");
26162         *ret_copy = HTLCDestination_next_hop_channel(node_id_ref, channel_id_ref);
26163         int64_t ret_ref = tag_ptr(ret_copy, true);
26164         return ret_ref;
26165 }
26166
26167 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCDestination_1unknown_1next_1hop(JNIEnv *env, jclass clz, int64_t requested_forward_scid) {
26168         LDKHTLCDestination *ret_copy = MALLOC(sizeof(LDKHTLCDestination), "LDKHTLCDestination");
26169         *ret_copy = HTLCDestination_unknown_next_hop(requested_forward_scid);
26170         int64_t ret_ref = tag_ptr(ret_copy, true);
26171         return ret_ref;
26172 }
26173
26174 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCDestination_1invalid_1forward(JNIEnv *env, jclass clz, int64_t requested_forward_scid) {
26175         LDKHTLCDestination *ret_copy = MALLOC(sizeof(LDKHTLCDestination), "LDKHTLCDestination");
26176         *ret_copy = HTLCDestination_invalid_forward(requested_forward_scid);
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_HTLCDestination_1failed_1payment(JNIEnv *env, jclass clz, int8_tArray payment_hash) {
26182         LDKThirtyTwoBytes payment_hash_ref;
26183         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
26184         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
26185         LDKHTLCDestination *ret_copy = MALLOC(sizeof(LDKHTLCDestination), "LDKHTLCDestination");
26186         *ret_copy = HTLCDestination_failed_payment(payment_hash_ref);
26187         int64_t ret_ref = tag_ptr(ret_copy, true);
26188         return ret_ref;
26189 }
26190
26191 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_HTLCDestination_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
26192         LDKHTLCDestination* a_conv = (LDKHTLCDestination*)untag_ptr(a);
26193         LDKHTLCDestination* b_conv = (LDKHTLCDestination*)untag_ptr(b);
26194         jboolean ret_conv = HTLCDestination_eq(a_conv, b_conv);
26195         return ret_conv;
26196 }
26197
26198 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HTLCDestination_1write(JNIEnv *env, jclass clz, int64_t obj) {
26199         LDKHTLCDestination* obj_conv = (LDKHTLCDestination*)untag_ptr(obj);
26200         LDKCVec_u8Z ret_var = HTLCDestination_write(obj_conv);
26201         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
26202         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
26203         CVec_u8Z_free(ret_var);
26204         return ret_arr;
26205 }
26206
26207 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCDestination_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
26208         LDKu8slice ser_ref;
26209         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
26210         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
26211         LDKCResult_COption_HTLCDestinationZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_HTLCDestinationZDecodeErrorZ), "LDKCResult_COption_HTLCDestinationZDecodeErrorZ");
26212         *ret_conv = HTLCDestination_read(ser_ref);
26213         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
26214         return tag_ptr(ret_conv, true);
26215 }
26216
26217 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Event_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
26218         if (!ptr_is_owned(this_ptr)) return;
26219         void* this_ptr_ptr = untag_ptr(this_ptr);
26220         CHECK_ACCESS(this_ptr_ptr);
26221         LDKEvent this_ptr_conv = *(LDKEvent*)(this_ptr_ptr);
26222         FREE(untag_ptr(this_ptr));
26223         Event_free(this_ptr_conv);
26224 }
26225
26226 static inline uint64_t Event_clone_ptr(LDKEvent *NONNULL_PTR arg) {
26227         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
26228         *ret_copy = Event_clone(arg);
26229         int64_t ret_ref = tag_ptr(ret_copy, true);
26230         return ret_ref;
26231 }
26232 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
26233         LDKEvent* arg_conv = (LDKEvent*)untag_ptr(arg);
26234         int64_t ret_conv = Event_clone_ptr(arg_conv);
26235         return ret_conv;
26236 }
26237
26238 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26239         LDKEvent* orig_conv = (LDKEvent*)untag_ptr(orig);
26240         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
26241         *ret_copy = Event_clone(orig_conv);
26242         int64_t ret_ref = tag_ptr(ret_copy, true);
26243         return ret_ref;
26244 }
26245
26246 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, int8_tArray user_channel_id) {
26247         LDKThirtyTwoBytes temporary_channel_id_ref;
26248         CHECK((*env)->GetArrayLength(env, temporary_channel_id) == 32);
26249         (*env)->GetByteArrayRegion(env, temporary_channel_id, 0, 32, temporary_channel_id_ref.data);
26250         LDKPublicKey counterparty_node_id_ref;
26251         CHECK((*env)->GetArrayLength(env, counterparty_node_id) == 33);
26252         (*env)->GetByteArrayRegion(env, counterparty_node_id, 0, 33, counterparty_node_id_ref.compressed_form);
26253         LDKCVec_u8Z output_script_ref;
26254         output_script_ref.datalen = (*env)->GetArrayLength(env, output_script);
26255         output_script_ref.data = MALLOC(output_script_ref.datalen, "LDKCVec_u8Z Bytes");
26256         (*env)->GetByteArrayRegion(env, output_script, 0, output_script_ref.datalen, output_script_ref.data);
26257         LDKU128 user_channel_id_ref;
26258         CHECK((*env)->GetArrayLength(env, user_channel_id) == 16);
26259         (*env)->GetByteArrayRegion(env, user_channel_id, 0, 16, user_channel_id_ref.le_bytes);
26260         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
26261         *ret_copy = Event_funding_generation_ready(temporary_channel_id_ref, counterparty_node_id_ref, channel_value_satoshis, output_script_ref, user_channel_id_ref);
26262         int64_t ret_ref = tag_ptr(ret_copy, true);
26263         return ret_ref;
26264 }
26265
26266 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1payment_1claimable(JNIEnv *env, jclass clz, int8_tArray receiver_node_id, int8_tArray payment_hash, int64_t amount_msat, int64_t purpose, int8_tArray via_channel_id, int64_t via_user_channel_id) {
26267         LDKPublicKey receiver_node_id_ref;
26268         CHECK((*env)->GetArrayLength(env, receiver_node_id) == 33);
26269         (*env)->GetByteArrayRegion(env, receiver_node_id, 0, 33, receiver_node_id_ref.compressed_form);
26270         LDKThirtyTwoBytes payment_hash_ref;
26271         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
26272         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
26273         void* purpose_ptr = untag_ptr(purpose);
26274         CHECK_ACCESS(purpose_ptr);
26275         LDKPaymentPurpose purpose_conv = *(LDKPaymentPurpose*)(purpose_ptr);
26276         purpose_conv = PaymentPurpose_clone((LDKPaymentPurpose*)untag_ptr(purpose));
26277         LDKThirtyTwoBytes via_channel_id_ref;
26278         CHECK((*env)->GetArrayLength(env, via_channel_id) == 32);
26279         (*env)->GetByteArrayRegion(env, via_channel_id, 0, 32, via_channel_id_ref.data);
26280         void* via_user_channel_id_ptr = untag_ptr(via_user_channel_id);
26281         CHECK_ACCESS(via_user_channel_id_ptr);
26282         LDKCOption_u128Z via_user_channel_id_conv = *(LDKCOption_u128Z*)(via_user_channel_id_ptr);
26283         via_user_channel_id_conv = COption_u128Z_clone((LDKCOption_u128Z*)untag_ptr(via_user_channel_id));
26284         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
26285         *ret_copy = Event_payment_claimable(receiver_node_id_ref, payment_hash_ref, amount_msat, purpose_conv, via_channel_id_ref, via_user_channel_id_conv);
26286         int64_t ret_ref = tag_ptr(ret_copy, true);
26287         return ret_ref;
26288 }
26289
26290 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1payment_1claimed(JNIEnv *env, jclass clz, int8_tArray receiver_node_id, int8_tArray payment_hash, int64_t amount_msat, int64_t purpose) {
26291         LDKPublicKey receiver_node_id_ref;
26292         CHECK((*env)->GetArrayLength(env, receiver_node_id) == 33);
26293         (*env)->GetByteArrayRegion(env, receiver_node_id, 0, 33, receiver_node_id_ref.compressed_form);
26294         LDKThirtyTwoBytes payment_hash_ref;
26295         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
26296         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
26297         void* purpose_ptr = untag_ptr(purpose);
26298         CHECK_ACCESS(purpose_ptr);
26299         LDKPaymentPurpose purpose_conv = *(LDKPaymentPurpose*)(purpose_ptr);
26300         purpose_conv = PaymentPurpose_clone((LDKPaymentPurpose*)untag_ptr(purpose));
26301         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
26302         *ret_copy = Event_payment_claimed(receiver_node_id_ref, payment_hash_ref, amount_msat, purpose_conv);
26303         int64_t ret_ref = tag_ptr(ret_copy, true);
26304         return ret_ref;
26305 }
26306
26307 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) {
26308         LDKThirtyTwoBytes payment_id_ref;
26309         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
26310         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
26311         LDKThirtyTwoBytes payment_preimage_ref;
26312         CHECK((*env)->GetArrayLength(env, payment_preimage) == 32);
26313         (*env)->GetByteArrayRegion(env, payment_preimage, 0, 32, payment_preimage_ref.data);
26314         LDKThirtyTwoBytes payment_hash_ref;
26315         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
26316         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
26317         void* fee_paid_msat_ptr = untag_ptr(fee_paid_msat);
26318         CHECK_ACCESS(fee_paid_msat_ptr);
26319         LDKCOption_u64Z fee_paid_msat_conv = *(LDKCOption_u64Z*)(fee_paid_msat_ptr);
26320         fee_paid_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(fee_paid_msat));
26321         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
26322         *ret_copy = Event_payment_sent(payment_id_ref, payment_preimage_ref, payment_hash_ref, fee_paid_msat_conv);
26323         int64_t ret_ref = tag_ptr(ret_copy, true);
26324         return ret_ref;
26325 }
26326
26327 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1payment_1failed(JNIEnv *env, jclass clz, int8_tArray payment_id, int8_tArray payment_hash) {
26328         LDKThirtyTwoBytes payment_id_ref;
26329         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
26330         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
26331         LDKThirtyTwoBytes payment_hash_ref;
26332         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
26333         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
26334         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
26335         *ret_copy = Event_payment_failed(payment_id_ref, payment_hash_ref);
26336         int64_t ret_ref = tag_ptr(ret_copy, true);
26337         return ret_ref;
26338 }
26339
26340 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) {
26341         LDKThirtyTwoBytes payment_id_ref;
26342         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
26343         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
26344         LDKThirtyTwoBytes payment_hash_ref;
26345         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
26346         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
26347         LDKCVec_RouteHopZ path_constr;
26348         path_constr.datalen = (*env)->GetArrayLength(env, path);
26349         if (path_constr.datalen > 0)
26350                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
26351         else
26352                 path_constr.data = NULL;
26353         int64_t* path_vals = (*env)->GetLongArrayElements (env, path, NULL);
26354         for (size_t k = 0; k < path_constr.datalen; k++) {
26355                 int64_t path_conv_10 = path_vals[k];
26356                 LDKRouteHop path_conv_10_conv;
26357                 path_conv_10_conv.inner = untag_ptr(path_conv_10);
26358                 path_conv_10_conv.is_owned = ptr_is_owned(path_conv_10);
26359                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
26360                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
26361                 path_constr.data[k] = path_conv_10_conv;
26362         }
26363         (*env)->ReleaseLongArrayElements(env, path, path_vals, 0);
26364         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
26365         *ret_copy = Event_payment_path_successful(payment_id_ref, payment_hash_ref, path_constr);
26366         int64_t ret_ref = tag_ptr(ret_copy, true);
26367         return ret_ref;
26368 }
26369
26370 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) {
26371         LDKThirtyTwoBytes payment_id_ref;
26372         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
26373         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
26374         LDKThirtyTwoBytes payment_hash_ref;
26375         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
26376         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
26377         void* network_update_ptr = untag_ptr(network_update);
26378         CHECK_ACCESS(network_update_ptr);
26379         LDKCOption_NetworkUpdateZ network_update_conv = *(LDKCOption_NetworkUpdateZ*)(network_update_ptr);
26380         network_update_conv = COption_NetworkUpdateZ_clone((LDKCOption_NetworkUpdateZ*)untag_ptr(network_update));
26381         LDKCVec_RouteHopZ path_constr;
26382         path_constr.datalen = (*env)->GetArrayLength(env, path);
26383         if (path_constr.datalen > 0)
26384                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
26385         else
26386                 path_constr.data = NULL;
26387         int64_t* path_vals = (*env)->GetLongArrayElements (env, path, NULL);
26388         for (size_t k = 0; k < path_constr.datalen; k++) {
26389                 int64_t path_conv_10 = path_vals[k];
26390                 LDKRouteHop path_conv_10_conv;
26391                 path_conv_10_conv.inner = untag_ptr(path_conv_10);
26392                 path_conv_10_conv.is_owned = ptr_is_owned(path_conv_10);
26393                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
26394                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
26395                 path_constr.data[k] = path_conv_10_conv;
26396         }
26397         (*env)->ReleaseLongArrayElements(env, path, path_vals, 0);
26398         void* short_channel_id_ptr = untag_ptr(short_channel_id);
26399         CHECK_ACCESS(short_channel_id_ptr);
26400         LDKCOption_u64Z short_channel_id_conv = *(LDKCOption_u64Z*)(short_channel_id_ptr);
26401         short_channel_id_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(short_channel_id));
26402         LDKRouteParameters retry_conv;
26403         retry_conv.inner = untag_ptr(retry);
26404         retry_conv.is_owned = ptr_is_owned(retry);
26405         CHECK_INNER_FIELD_ACCESS_OR_NULL(retry_conv);
26406         retry_conv = RouteParameters_clone(&retry_conv);
26407         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
26408         *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);
26409         int64_t ret_ref = tag_ptr(ret_copy, true);
26410         return ret_ref;
26411 }
26412
26413 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) {
26414         LDKThirtyTwoBytes payment_id_ref;
26415         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
26416         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
26417         LDKThirtyTwoBytes payment_hash_ref;
26418         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
26419         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
26420         LDKCVec_RouteHopZ path_constr;
26421         path_constr.datalen = (*env)->GetArrayLength(env, path);
26422         if (path_constr.datalen > 0)
26423                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
26424         else
26425                 path_constr.data = NULL;
26426         int64_t* path_vals = (*env)->GetLongArrayElements (env, path, NULL);
26427         for (size_t k = 0; k < path_constr.datalen; k++) {
26428                 int64_t path_conv_10 = path_vals[k];
26429                 LDKRouteHop path_conv_10_conv;
26430                 path_conv_10_conv.inner = untag_ptr(path_conv_10);
26431                 path_conv_10_conv.is_owned = ptr_is_owned(path_conv_10);
26432                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
26433                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
26434                 path_constr.data[k] = path_conv_10_conv;
26435         }
26436         (*env)->ReleaseLongArrayElements(env, path, path_vals, 0);
26437         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
26438         *ret_copy = Event_probe_successful(payment_id_ref, payment_hash_ref, path_constr);
26439         int64_t ret_ref = tag_ptr(ret_copy, true);
26440         return ret_ref;
26441 }
26442
26443 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) {
26444         LDKThirtyTwoBytes payment_id_ref;
26445         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
26446         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
26447         LDKThirtyTwoBytes payment_hash_ref;
26448         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
26449         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
26450         LDKCVec_RouteHopZ path_constr;
26451         path_constr.datalen = (*env)->GetArrayLength(env, path);
26452         if (path_constr.datalen > 0)
26453                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
26454         else
26455                 path_constr.data = NULL;
26456         int64_t* path_vals = (*env)->GetLongArrayElements (env, path, NULL);
26457         for (size_t k = 0; k < path_constr.datalen; k++) {
26458                 int64_t path_conv_10 = path_vals[k];
26459                 LDKRouteHop path_conv_10_conv;
26460                 path_conv_10_conv.inner = untag_ptr(path_conv_10);
26461                 path_conv_10_conv.is_owned = ptr_is_owned(path_conv_10);
26462                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
26463                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
26464                 path_constr.data[k] = path_conv_10_conv;
26465         }
26466         (*env)->ReleaseLongArrayElements(env, path, path_vals, 0);
26467         void* short_channel_id_ptr = untag_ptr(short_channel_id);
26468         CHECK_ACCESS(short_channel_id_ptr);
26469         LDKCOption_u64Z short_channel_id_conv = *(LDKCOption_u64Z*)(short_channel_id_ptr);
26470         short_channel_id_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(short_channel_id));
26471         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
26472         *ret_copy = Event_probe_failed(payment_id_ref, payment_hash_ref, path_constr, short_channel_id_conv);
26473         int64_t ret_ref = tag_ptr(ret_copy, true);
26474         return ret_ref;
26475 }
26476
26477 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1pending_1htlcs_1forwardable(JNIEnv *env, jclass clz, int64_t time_forwardable) {
26478         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
26479         *ret_copy = Event_pending_htlcs_forwardable(time_forwardable);
26480         int64_t ret_ref = tag_ptr(ret_copy, true);
26481         return ret_ref;
26482 }
26483
26484 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1htlcintercepted(JNIEnv *env, jclass clz, int8_tArray intercept_id, int64_t requested_next_hop_scid, int8_tArray payment_hash, int64_t inbound_amount_msat, int64_t expected_outbound_amount_msat) {
26485         LDKThirtyTwoBytes intercept_id_ref;
26486         CHECK((*env)->GetArrayLength(env, intercept_id) == 32);
26487         (*env)->GetByteArrayRegion(env, intercept_id, 0, 32, intercept_id_ref.data);
26488         LDKThirtyTwoBytes payment_hash_ref;
26489         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
26490         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
26491         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
26492         *ret_copy = Event_htlcintercepted(intercept_id_ref, requested_next_hop_scid, payment_hash_ref, inbound_amount_msat, expected_outbound_amount_msat);
26493         int64_t ret_ref = tag_ptr(ret_copy, true);
26494         return ret_ref;
26495 }
26496
26497 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1spendable_1outputs(JNIEnv *env, jclass clz, int64_tArray outputs) {
26498         LDKCVec_SpendableOutputDescriptorZ outputs_constr;
26499         outputs_constr.datalen = (*env)->GetArrayLength(env, outputs);
26500         if (outputs_constr.datalen > 0)
26501                 outputs_constr.data = MALLOC(outputs_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
26502         else
26503                 outputs_constr.data = NULL;
26504         int64_t* outputs_vals = (*env)->GetLongArrayElements (env, outputs, NULL);
26505         for (size_t b = 0; b < outputs_constr.datalen; b++) {
26506                 int64_t outputs_conv_27 = outputs_vals[b];
26507                 void* outputs_conv_27_ptr = untag_ptr(outputs_conv_27);
26508                 CHECK_ACCESS(outputs_conv_27_ptr);
26509                 LDKSpendableOutputDescriptor outputs_conv_27_conv = *(LDKSpendableOutputDescriptor*)(outputs_conv_27_ptr);
26510                 outputs_conv_27_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)untag_ptr(outputs_conv_27));
26511                 outputs_constr.data[b] = outputs_conv_27_conv;
26512         }
26513         (*env)->ReleaseLongArrayElements(env, outputs, outputs_vals, 0);
26514         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
26515         *ret_copy = Event_spendable_outputs(outputs_constr);
26516         int64_t ret_ref = tag_ptr(ret_copy, true);
26517         return ret_ref;
26518 }
26519
26520 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) {
26521         LDKThirtyTwoBytes prev_channel_id_ref;
26522         CHECK((*env)->GetArrayLength(env, prev_channel_id) == 32);
26523         (*env)->GetByteArrayRegion(env, prev_channel_id, 0, 32, prev_channel_id_ref.data);
26524         LDKThirtyTwoBytes next_channel_id_ref;
26525         CHECK((*env)->GetArrayLength(env, next_channel_id) == 32);
26526         (*env)->GetByteArrayRegion(env, next_channel_id, 0, 32, next_channel_id_ref.data);
26527         void* fee_earned_msat_ptr = untag_ptr(fee_earned_msat);
26528         CHECK_ACCESS(fee_earned_msat_ptr);
26529         LDKCOption_u64Z fee_earned_msat_conv = *(LDKCOption_u64Z*)(fee_earned_msat_ptr);
26530         fee_earned_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(fee_earned_msat));
26531         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
26532         *ret_copy = Event_payment_forwarded(prev_channel_id_ref, next_channel_id_ref, fee_earned_msat_conv, claim_from_onchain_tx);
26533         int64_t ret_ref = tag_ptr(ret_copy, true);
26534         return ret_ref;
26535 }
26536
26537 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1channel_1ready(JNIEnv *env, jclass clz, int8_tArray channel_id, int8_tArray user_channel_id, int8_tArray counterparty_node_id, int64_t channel_type) {
26538         LDKThirtyTwoBytes channel_id_ref;
26539         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
26540         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_ref.data);
26541         LDKU128 user_channel_id_ref;
26542         CHECK((*env)->GetArrayLength(env, user_channel_id) == 16);
26543         (*env)->GetByteArrayRegion(env, user_channel_id, 0, 16, user_channel_id_ref.le_bytes);
26544         LDKPublicKey counterparty_node_id_ref;
26545         CHECK((*env)->GetArrayLength(env, counterparty_node_id) == 33);
26546         (*env)->GetByteArrayRegion(env, counterparty_node_id, 0, 33, counterparty_node_id_ref.compressed_form);
26547         LDKChannelTypeFeatures channel_type_conv;
26548         channel_type_conv.inner = untag_ptr(channel_type);
26549         channel_type_conv.is_owned = ptr_is_owned(channel_type);
26550         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_type_conv);
26551         channel_type_conv = ChannelTypeFeatures_clone(&channel_type_conv);
26552         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
26553         *ret_copy = Event_channel_ready(channel_id_ref, user_channel_id_ref, counterparty_node_id_ref, channel_type_conv);
26554         int64_t ret_ref = tag_ptr(ret_copy, true);
26555         return ret_ref;
26556 }
26557
26558 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1channel_1closed(JNIEnv *env, jclass clz, int8_tArray channel_id, int8_tArray user_channel_id, int64_t reason) {
26559         LDKThirtyTwoBytes channel_id_ref;
26560         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
26561         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_ref.data);
26562         LDKU128 user_channel_id_ref;
26563         CHECK((*env)->GetArrayLength(env, user_channel_id) == 16);
26564         (*env)->GetByteArrayRegion(env, user_channel_id, 0, 16, user_channel_id_ref.le_bytes);
26565         void* reason_ptr = untag_ptr(reason);
26566         CHECK_ACCESS(reason_ptr);
26567         LDKClosureReason reason_conv = *(LDKClosureReason*)(reason_ptr);
26568         reason_conv = ClosureReason_clone((LDKClosureReason*)untag_ptr(reason));
26569         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
26570         *ret_copy = Event_channel_closed(channel_id_ref, user_channel_id_ref, reason_conv);
26571         int64_t ret_ref = tag_ptr(ret_copy, true);
26572         return ret_ref;
26573 }
26574
26575 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1discard_1funding(JNIEnv *env, jclass clz, int8_tArray channel_id, int8_tArray transaction) {
26576         LDKThirtyTwoBytes channel_id_ref;
26577         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
26578         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_ref.data);
26579         LDKTransaction transaction_ref;
26580         transaction_ref.datalen = (*env)->GetArrayLength(env, transaction);
26581         transaction_ref.data = MALLOC(transaction_ref.datalen, "LDKTransaction Bytes");
26582         (*env)->GetByteArrayRegion(env, transaction, 0, transaction_ref.datalen, transaction_ref.data);
26583         transaction_ref.data_is_owned = true;
26584         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
26585         *ret_copy = Event_discard_funding(channel_id_ref, transaction_ref);
26586         int64_t ret_ref = tag_ptr(ret_copy, true);
26587         return ret_ref;
26588 }
26589
26590 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) {
26591         LDKThirtyTwoBytes temporary_channel_id_ref;
26592         CHECK((*env)->GetArrayLength(env, temporary_channel_id) == 32);
26593         (*env)->GetByteArrayRegion(env, temporary_channel_id, 0, 32, temporary_channel_id_ref.data);
26594         LDKPublicKey counterparty_node_id_ref;
26595         CHECK((*env)->GetArrayLength(env, counterparty_node_id) == 33);
26596         (*env)->GetByteArrayRegion(env, counterparty_node_id, 0, 33, counterparty_node_id_ref.compressed_form);
26597         LDKChannelTypeFeatures channel_type_conv;
26598         channel_type_conv.inner = untag_ptr(channel_type);
26599         channel_type_conv.is_owned = ptr_is_owned(channel_type);
26600         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_type_conv);
26601         channel_type_conv = ChannelTypeFeatures_clone(&channel_type_conv);
26602         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
26603         *ret_copy = Event_open_channel_request(temporary_channel_id_ref, counterparty_node_id_ref, funding_satoshis, push_msat, channel_type_conv);
26604         int64_t ret_ref = tag_ptr(ret_copy, true);
26605         return ret_ref;
26606 }
26607
26608 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) {
26609         LDKThirtyTwoBytes prev_channel_id_ref;
26610         CHECK((*env)->GetArrayLength(env, prev_channel_id) == 32);
26611         (*env)->GetByteArrayRegion(env, prev_channel_id, 0, 32, prev_channel_id_ref.data);
26612         void* failed_next_destination_ptr = untag_ptr(failed_next_destination);
26613         CHECK_ACCESS(failed_next_destination_ptr);
26614         LDKHTLCDestination failed_next_destination_conv = *(LDKHTLCDestination*)(failed_next_destination_ptr);
26615         failed_next_destination_conv = HTLCDestination_clone((LDKHTLCDestination*)untag_ptr(failed_next_destination));
26616         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
26617         *ret_copy = Event_htlchandling_failed(prev_channel_id_ref, failed_next_destination_conv);
26618         int64_t ret_ref = tag_ptr(ret_copy, true);
26619         return ret_ref;
26620 }
26621
26622 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Event_1write(JNIEnv *env, jclass clz, int64_t obj) {
26623         LDKEvent* obj_conv = (LDKEvent*)untag_ptr(obj);
26624         LDKCVec_u8Z ret_var = Event_write(obj_conv);
26625         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
26626         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
26627         CVec_u8Z_free(ret_var);
26628         return ret_arr;
26629 }
26630
26631 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
26632         LDKu8slice ser_ref;
26633         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
26634         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
26635         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
26636         *ret_conv = Event_read(ser_ref);
26637         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
26638         return tag_ptr(ret_conv, true);
26639 }
26640
26641 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
26642         if (!ptr_is_owned(this_ptr)) return;
26643         void* this_ptr_ptr = untag_ptr(this_ptr);
26644         CHECK_ACCESS(this_ptr_ptr);
26645         LDKMessageSendEvent this_ptr_conv = *(LDKMessageSendEvent*)(this_ptr_ptr);
26646         FREE(untag_ptr(this_ptr));
26647         MessageSendEvent_free(this_ptr_conv);
26648 }
26649
26650 static inline uint64_t MessageSendEvent_clone_ptr(LDKMessageSendEvent *NONNULL_PTR arg) {
26651         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
26652         *ret_copy = MessageSendEvent_clone(arg);
26653         int64_t ret_ref = tag_ptr(ret_copy, true);
26654         return ret_ref;
26655 }
26656 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
26657         LDKMessageSendEvent* arg_conv = (LDKMessageSendEvent*)untag_ptr(arg);
26658         int64_t ret_conv = MessageSendEvent_clone_ptr(arg_conv);
26659         return ret_conv;
26660 }
26661
26662 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26663         LDKMessageSendEvent* orig_conv = (LDKMessageSendEvent*)untag_ptr(orig);
26664         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
26665         *ret_copy = MessageSendEvent_clone(orig_conv);
26666         int64_t ret_ref = tag_ptr(ret_copy, true);
26667         return ret_ref;
26668 }
26669
26670 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1accept_1channel(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
26671         LDKPublicKey node_id_ref;
26672         CHECK((*env)->GetArrayLength(env, node_id) == 33);
26673         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
26674         LDKAcceptChannel msg_conv;
26675         msg_conv.inner = untag_ptr(msg);
26676         msg_conv.is_owned = ptr_is_owned(msg);
26677         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
26678         msg_conv = AcceptChannel_clone(&msg_conv);
26679         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
26680         *ret_copy = MessageSendEvent_send_accept_channel(node_id_ref, msg_conv);
26681         int64_t ret_ref = tag_ptr(ret_copy, true);
26682         return ret_ref;
26683 }
26684
26685 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1open_1channel(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
26686         LDKPublicKey node_id_ref;
26687         CHECK((*env)->GetArrayLength(env, node_id) == 33);
26688         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
26689         LDKOpenChannel msg_conv;
26690         msg_conv.inner = untag_ptr(msg);
26691         msg_conv.is_owned = ptr_is_owned(msg);
26692         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
26693         msg_conv = OpenChannel_clone(&msg_conv);
26694         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
26695         *ret_copy = MessageSendEvent_send_open_channel(node_id_ref, msg_conv);
26696         int64_t ret_ref = tag_ptr(ret_copy, true);
26697         return ret_ref;
26698 }
26699
26700 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1funding_1created(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
26701         LDKPublicKey node_id_ref;
26702         CHECK((*env)->GetArrayLength(env, node_id) == 33);
26703         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
26704         LDKFundingCreated msg_conv;
26705         msg_conv.inner = untag_ptr(msg);
26706         msg_conv.is_owned = ptr_is_owned(msg);
26707         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
26708         msg_conv = FundingCreated_clone(&msg_conv);
26709         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
26710         *ret_copy = MessageSendEvent_send_funding_created(node_id_ref, msg_conv);
26711         int64_t ret_ref = tag_ptr(ret_copy, true);
26712         return ret_ref;
26713 }
26714
26715 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1funding_1signed(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
26716         LDKPublicKey node_id_ref;
26717         CHECK((*env)->GetArrayLength(env, node_id) == 33);
26718         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
26719         LDKFundingSigned msg_conv;
26720         msg_conv.inner = untag_ptr(msg);
26721         msg_conv.is_owned = ptr_is_owned(msg);
26722         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
26723         msg_conv = FundingSigned_clone(&msg_conv);
26724         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
26725         *ret_copy = MessageSendEvent_send_funding_signed(node_id_ref, msg_conv);
26726         int64_t ret_ref = tag_ptr(ret_copy, true);
26727         return ret_ref;
26728 }
26729
26730 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1channel_1ready(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
26731         LDKPublicKey node_id_ref;
26732         CHECK((*env)->GetArrayLength(env, node_id) == 33);
26733         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
26734         LDKChannelReady msg_conv;
26735         msg_conv.inner = untag_ptr(msg);
26736         msg_conv.is_owned = ptr_is_owned(msg);
26737         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
26738         msg_conv = ChannelReady_clone(&msg_conv);
26739         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
26740         *ret_copy = MessageSendEvent_send_channel_ready(node_id_ref, msg_conv);
26741         int64_t ret_ref = tag_ptr(ret_copy, true);
26742         return ret_ref;
26743 }
26744
26745 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1announcement_1signatures(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
26746         LDKPublicKey node_id_ref;
26747         CHECK((*env)->GetArrayLength(env, node_id) == 33);
26748         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
26749         LDKAnnouncementSignatures msg_conv;
26750         msg_conv.inner = untag_ptr(msg);
26751         msg_conv.is_owned = ptr_is_owned(msg);
26752         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
26753         msg_conv = AnnouncementSignatures_clone(&msg_conv);
26754         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
26755         *ret_copy = MessageSendEvent_send_announcement_signatures(node_id_ref, msg_conv);
26756         int64_t ret_ref = tag_ptr(ret_copy, true);
26757         return ret_ref;
26758 }
26759
26760 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1update_1htlcs(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t updates) {
26761         LDKPublicKey node_id_ref;
26762         CHECK((*env)->GetArrayLength(env, node_id) == 33);
26763         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
26764         LDKCommitmentUpdate updates_conv;
26765         updates_conv.inner = untag_ptr(updates);
26766         updates_conv.is_owned = ptr_is_owned(updates);
26767         CHECK_INNER_FIELD_ACCESS_OR_NULL(updates_conv);
26768         updates_conv = CommitmentUpdate_clone(&updates_conv);
26769         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
26770         *ret_copy = MessageSendEvent_update_htlcs(node_id_ref, updates_conv);
26771         int64_t ret_ref = tag_ptr(ret_copy, true);
26772         return ret_ref;
26773 }
26774
26775 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) {
26776         LDKPublicKey node_id_ref;
26777         CHECK((*env)->GetArrayLength(env, node_id) == 33);
26778         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
26779         LDKRevokeAndACK msg_conv;
26780         msg_conv.inner = untag_ptr(msg);
26781         msg_conv.is_owned = ptr_is_owned(msg);
26782         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
26783         msg_conv = RevokeAndACK_clone(&msg_conv);
26784         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
26785         *ret_copy = MessageSendEvent_send_revoke_and_ack(node_id_ref, msg_conv);
26786         int64_t ret_ref = tag_ptr(ret_copy, true);
26787         return ret_ref;
26788 }
26789
26790 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1closing_1signed(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
26791         LDKPublicKey node_id_ref;
26792         CHECK((*env)->GetArrayLength(env, node_id) == 33);
26793         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
26794         LDKClosingSigned msg_conv;
26795         msg_conv.inner = untag_ptr(msg);
26796         msg_conv.is_owned = ptr_is_owned(msg);
26797         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
26798         msg_conv = ClosingSigned_clone(&msg_conv);
26799         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
26800         *ret_copy = MessageSendEvent_send_closing_signed(node_id_ref, msg_conv);
26801         int64_t ret_ref = tag_ptr(ret_copy, true);
26802         return ret_ref;
26803 }
26804
26805 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1shutdown(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
26806         LDKPublicKey node_id_ref;
26807         CHECK((*env)->GetArrayLength(env, node_id) == 33);
26808         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
26809         LDKShutdown msg_conv;
26810         msg_conv.inner = untag_ptr(msg);
26811         msg_conv.is_owned = ptr_is_owned(msg);
26812         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
26813         msg_conv = Shutdown_clone(&msg_conv);
26814         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
26815         *ret_copy = MessageSendEvent_send_shutdown(node_id_ref, msg_conv);
26816         int64_t ret_ref = tag_ptr(ret_copy, true);
26817         return ret_ref;
26818 }
26819
26820 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1channel_1reestablish(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
26821         LDKPublicKey node_id_ref;
26822         CHECK((*env)->GetArrayLength(env, node_id) == 33);
26823         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
26824         LDKChannelReestablish msg_conv;
26825         msg_conv.inner = untag_ptr(msg);
26826         msg_conv.is_owned = ptr_is_owned(msg);
26827         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
26828         msg_conv = ChannelReestablish_clone(&msg_conv);
26829         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
26830         *ret_copy = MessageSendEvent_send_channel_reestablish(node_id_ref, msg_conv);
26831         int64_t ret_ref = tag_ptr(ret_copy, true);
26832         return ret_ref;
26833 }
26834
26835 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) {
26836         LDKPublicKey node_id_ref;
26837         CHECK((*env)->GetArrayLength(env, node_id) == 33);
26838         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
26839         LDKChannelAnnouncement msg_conv;
26840         msg_conv.inner = untag_ptr(msg);
26841         msg_conv.is_owned = ptr_is_owned(msg);
26842         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
26843         msg_conv = ChannelAnnouncement_clone(&msg_conv);
26844         LDKChannelUpdate update_msg_conv;
26845         update_msg_conv.inner = untag_ptr(update_msg);
26846         update_msg_conv.is_owned = ptr_is_owned(update_msg);
26847         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_msg_conv);
26848         update_msg_conv = ChannelUpdate_clone(&update_msg_conv);
26849         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
26850         *ret_copy = MessageSendEvent_send_channel_announcement(node_id_ref, msg_conv, update_msg_conv);
26851         int64_t ret_ref = tag_ptr(ret_copy, true);
26852         return ret_ref;
26853 }
26854
26855 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1broadcast_1channel_1announcement(JNIEnv *env, jclass clz, int64_t msg, int64_t update_msg) {
26856         LDKChannelAnnouncement msg_conv;
26857         msg_conv.inner = untag_ptr(msg);
26858         msg_conv.is_owned = ptr_is_owned(msg);
26859         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
26860         msg_conv = ChannelAnnouncement_clone(&msg_conv);
26861         LDKChannelUpdate update_msg_conv;
26862         update_msg_conv.inner = untag_ptr(update_msg);
26863         update_msg_conv.is_owned = ptr_is_owned(update_msg);
26864         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_msg_conv);
26865         update_msg_conv = ChannelUpdate_clone(&update_msg_conv);
26866         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
26867         *ret_copy = MessageSendEvent_broadcast_channel_announcement(msg_conv, update_msg_conv);
26868         int64_t ret_ref = tag_ptr(ret_copy, true);
26869         return ret_ref;
26870 }
26871
26872 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1broadcast_1channel_1update(JNIEnv *env, jclass clz, int64_t msg) {
26873         LDKChannelUpdate msg_conv;
26874         msg_conv.inner = untag_ptr(msg);
26875         msg_conv.is_owned = ptr_is_owned(msg);
26876         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
26877         msg_conv = ChannelUpdate_clone(&msg_conv);
26878         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
26879         *ret_copy = MessageSendEvent_broadcast_channel_update(msg_conv);
26880         int64_t ret_ref = tag_ptr(ret_copy, true);
26881         return ret_ref;
26882 }
26883
26884 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1channel_1update(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
26885         LDKPublicKey node_id_ref;
26886         CHECK((*env)->GetArrayLength(env, node_id) == 33);
26887         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
26888         LDKChannelUpdate msg_conv;
26889         msg_conv.inner = untag_ptr(msg);
26890         msg_conv.is_owned = ptr_is_owned(msg);
26891         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
26892         msg_conv = ChannelUpdate_clone(&msg_conv);
26893         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
26894         *ret_copy = MessageSendEvent_send_channel_update(node_id_ref, msg_conv);
26895         int64_t ret_ref = tag_ptr(ret_copy, true);
26896         return ret_ref;
26897 }
26898
26899 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1handle_1error(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t action) {
26900         LDKPublicKey node_id_ref;
26901         CHECK((*env)->GetArrayLength(env, node_id) == 33);
26902         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
26903         void* action_ptr = untag_ptr(action);
26904         CHECK_ACCESS(action_ptr);
26905         LDKErrorAction action_conv = *(LDKErrorAction*)(action_ptr);
26906         action_conv = ErrorAction_clone((LDKErrorAction*)untag_ptr(action));
26907         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
26908         *ret_copy = MessageSendEvent_handle_error(node_id_ref, action_conv);
26909         int64_t ret_ref = tag_ptr(ret_copy, true);
26910         return ret_ref;
26911 }
26912
26913 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) {
26914         LDKPublicKey node_id_ref;
26915         CHECK((*env)->GetArrayLength(env, node_id) == 33);
26916         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
26917         LDKQueryChannelRange msg_conv;
26918         msg_conv.inner = untag_ptr(msg);
26919         msg_conv.is_owned = ptr_is_owned(msg);
26920         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
26921         msg_conv = QueryChannelRange_clone(&msg_conv);
26922         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
26923         *ret_copy = MessageSendEvent_send_channel_range_query(node_id_ref, msg_conv);
26924         int64_t ret_ref = tag_ptr(ret_copy, true);
26925         return ret_ref;
26926 }
26927
26928 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) {
26929         LDKPublicKey node_id_ref;
26930         CHECK((*env)->GetArrayLength(env, node_id) == 33);
26931         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
26932         LDKQueryShortChannelIds msg_conv;
26933         msg_conv.inner = untag_ptr(msg);
26934         msg_conv.is_owned = ptr_is_owned(msg);
26935         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
26936         msg_conv = QueryShortChannelIds_clone(&msg_conv);
26937         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
26938         *ret_copy = MessageSendEvent_send_short_ids_query(node_id_ref, msg_conv);
26939         int64_t ret_ref = tag_ptr(ret_copy, true);
26940         return ret_ref;
26941 }
26942
26943 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) {
26944         LDKPublicKey node_id_ref;
26945         CHECK((*env)->GetArrayLength(env, node_id) == 33);
26946         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
26947         LDKReplyChannelRange msg_conv;
26948         msg_conv.inner = untag_ptr(msg);
26949         msg_conv.is_owned = ptr_is_owned(msg);
26950         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
26951         msg_conv = ReplyChannelRange_clone(&msg_conv);
26952         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
26953         *ret_copy = MessageSendEvent_send_reply_channel_range(node_id_ref, msg_conv);
26954         int64_t ret_ref = tag_ptr(ret_copy, true);
26955         return ret_ref;
26956 }
26957
26958 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) {
26959         LDKPublicKey node_id_ref;
26960         CHECK((*env)->GetArrayLength(env, node_id) == 33);
26961         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
26962         LDKGossipTimestampFilter msg_conv;
26963         msg_conv.inner = untag_ptr(msg);
26964         msg_conv.is_owned = ptr_is_owned(msg);
26965         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
26966         msg_conv = GossipTimestampFilter_clone(&msg_conv);
26967         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
26968         *ret_copy = MessageSendEvent_send_gossip_timestamp_filter(node_id_ref, msg_conv);
26969         int64_t ret_ref = tag_ptr(ret_copy, true);
26970         return ret_ref;
26971 }
26972
26973 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageSendEventsProvider_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
26974         if (!ptr_is_owned(this_ptr)) return;
26975         void* this_ptr_ptr = untag_ptr(this_ptr);
26976         CHECK_ACCESS(this_ptr_ptr);
26977         LDKMessageSendEventsProvider this_ptr_conv = *(LDKMessageSendEventsProvider*)(this_ptr_ptr);
26978         FREE(untag_ptr(this_ptr));
26979         MessageSendEventsProvider_free(this_ptr_conv);
26980 }
26981
26982 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OnionMessageProvider_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
26983         if (!ptr_is_owned(this_ptr)) return;
26984         void* this_ptr_ptr = untag_ptr(this_ptr);
26985         CHECK_ACCESS(this_ptr_ptr);
26986         LDKOnionMessageProvider this_ptr_conv = *(LDKOnionMessageProvider*)(this_ptr_ptr);
26987         FREE(untag_ptr(this_ptr));
26988         OnionMessageProvider_free(this_ptr_conv);
26989 }
26990
26991 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_EventsProvider_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
26992         if (!ptr_is_owned(this_ptr)) return;
26993         void* this_ptr_ptr = untag_ptr(this_ptr);
26994         CHECK_ACCESS(this_ptr_ptr);
26995         LDKEventsProvider this_ptr_conv = *(LDKEventsProvider*)(this_ptr_ptr);
26996         FREE(untag_ptr(this_ptr));
26997         EventsProvider_free(this_ptr_conv);
26998 }
26999
27000 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_EventHandler_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
27001         if (!ptr_is_owned(this_ptr)) return;
27002         void* this_ptr_ptr = untag_ptr(this_ptr);
27003         CHECK_ACCESS(this_ptr_ptr);
27004         LDKEventHandler this_ptr_conv = *(LDKEventHandler*)(this_ptr_ptr);
27005         FREE(untag_ptr(this_ptr));
27006         EventHandler_free(this_ptr_conv);
27007 }
27008
27009 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_APIError_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
27010         if (!ptr_is_owned(this_ptr)) return;
27011         void* this_ptr_ptr = untag_ptr(this_ptr);
27012         CHECK_ACCESS(this_ptr_ptr);
27013         LDKAPIError this_ptr_conv = *(LDKAPIError*)(this_ptr_ptr);
27014         FREE(untag_ptr(this_ptr));
27015         APIError_free(this_ptr_conv);
27016 }
27017
27018 static inline uint64_t APIError_clone_ptr(LDKAPIError *NONNULL_PTR arg) {
27019         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
27020         *ret_copy = APIError_clone(arg);
27021         int64_t ret_ref = tag_ptr(ret_copy, true);
27022         return ret_ref;
27023 }
27024 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
27025         LDKAPIError* arg_conv = (LDKAPIError*)untag_ptr(arg);
27026         int64_t ret_conv = APIError_clone_ptr(arg_conv);
27027         return ret_conv;
27028 }
27029
27030 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
27031         LDKAPIError* orig_conv = (LDKAPIError*)untag_ptr(orig);
27032         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
27033         *ret_copy = APIError_clone(orig_conv);
27034         int64_t ret_ref = tag_ptr(ret_copy, true);
27035         return ret_ref;
27036 }
27037
27038 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1apimisuse_1error(JNIEnv *env, jclass clz, jstring err) {
27039         LDKStr err_conv = java_to_owned_str(env, err);
27040         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
27041         *ret_copy = APIError_apimisuse_error(err_conv);
27042         int64_t ret_ref = tag_ptr(ret_copy, true);
27043         return ret_ref;
27044 }
27045
27046 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1fee_1rate_1too_1high(JNIEnv *env, jclass clz, jstring err, int32_t feerate) {
27047         LDKStr err_conv = java_to_owned_str(env, err);
27048         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
27049         *ret_copy = APIError_fee_rate_too_high(err_conv, feerate);
27050         int64_t ret_ref = tag_ptr(ret_copy, true);
27051         return ret_ref;
27052 }
27053
27054 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1invalid_1route(JNIEnv *env, jclass clz, jstring err) {
27055         LDKStr err_conv = java_to_owned_str(env, err);
27056         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
27057         *ret_copy = APIError_invalid_route(err_conv);
27058         int64_t ret_ref = tag_ptr(ret_copy, true);
27059         return ret_ref;
27060 }
27061
27062 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1channel_1unavailable(JNIEnv *env, jclass clz, jstring err) {
27063         LDKStr err_conv = java_to_owned_str(env, err);
27064         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
27065         *ret_copy = APIError_channel_unavailable(err_conv);
27066         int64_t ret_ref = tag_ptr(ret_copy, true);
27067         return ret_ref;
27068 }
27069
27070 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1monitor_1update_1in_1progress(JNIEnv *env, jclass clz) {
27071         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
27072         *ret_copy = APIError_monitor_update_in_progress();
27073         int64_t ret_ref = tag_ptr(ret_copy, true);
27074         return ret_ref;
27075 }
27076
27077 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1incompatible_1shutdown_1script(JNIEnv *env, jclass clz, int64_t script) {
27078         LDKShutdownScript script_conv;
27079         script_conv.inner = untag_ptr(script);
27080         script_conv.is_owned = ptr_is_owned(script);
27081         CHECK_INNER_FIELD_ACCESS_OR_NULL(script_conv);
27082         script_conv = ShutdownScript_clone(&script_conv);
27083         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
27084         *ret_copy = APIError_incompatible_shutdown_script(script_conv);
27085         int64_t ret_ref = tag_ptr(ret_copy, true);
27086         return ret_ref;
27087 }
27088
27089 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_APIError_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
27090         LDKAPIError* a_conv = (LDKAPIError*)untag_ptr(a);
27091         LDKAPIError* b_conv = (LDKAPIError*)untag_ptr(b);
27092         jboolean ret_conv = APIError_eq(a_conv, b_conv);
27093         return ret_conv;
27094 }
27095
27096 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BigSize_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
27097         LDKBigSize this_obj_conv;
27098         this_obj_conv.inner = untag_ptr(this_obj);
27099         this_obj_conv.is_owned = ptr_is_owned(this_obj);
27100         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27101         BigSize_free(this_obj_conv);
27102 }
27103
27104 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BigSize_1get_1a(JNIEnv *env, jclass clz, int64_t this_ptr) {
27105         LDKBigSize this_ptr_conv;
27106         this_ptr_conv.inner = untag_ptr(this_ptr);
27107         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27108         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27109         this_ptr_conv.is_owned = false;
27110         int64_t ret_conv = BigSize_get_a(&this_ptr_conv);
27111         return ret_conv;
27112 }
27113
27114 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BigSize_1set_1a(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
27115         LDKBigSize this_ptr_conv;
27116         this_ptr_conv.inner = untag_ptr(this_ptr);
27117         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27118         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27119         this_ptr_conv.is_owned = false;
27120         BigSize_set_a(&this_ptr_conv, val);
27121 }
27122
27123 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BigSize_1new(JNIEnv *env, jclass clz, int64_t a_arg) {
27124         LDKBigSize ret_var = BigSize_new(a_arg);
27125         int64_t ret_ref = 0;
27126         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27127         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
27128         return ret_ref;
27129 }
27130
27131 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Hostname_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
27132         LDKHostname this_obj_conv;
27133         this_obj_conv.inner = untag_ptr(this_obj);
27134         this_obj_conv.is_owned = ptr_is_owned(this_obj);
27135         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27136         Hostname_free(this_obj_conv);
27137 }
27138
27139 static inline uint64_t Hostname_clone_ptr(LDKHostname *NONNULL_PTR arg) {
27140         LDKHostname ret_var = Hostname_clone(arg);
27141         int64_t ret_ref = 0;
27142         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27143         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
27144         return ret_ref;
27145 }
27146 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Hostname_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
27147         LDKHostname arg_conv;
27148         arg_conv.inner = untag_ptr(arg);
27149         arg_conv.is_owned = ptr_is_owned(arg);
27150         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
27151         arg_conv.is_owned = false;
27152         int64_t ret_conv = Hostname_clone_ptr(&arg_conv);
27153         return ret_conv;
27154 }
27155
27156 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Hostname_1clone(JNIEnv *env, jclass clz, int64_t orig) {
27157         LDKHostname orig_conv;
27158         orig_conv.inner = untag_ptr(orig);
27159         orig_conv.is_owned = ptr_is_owned(orig);
27160         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
27161         orig_conv.is_owned = false;
27162         LDKHostname ret_var = Hostname_clone(&orig_conv);
27163         int64_t ret_ref = 0;
27164         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27165         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
27166         return ret_ref;
27167 }
27168
27169 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Hostname_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
27170         LDKHostname a_conv;
27171         a_conv.inner = untag_ptr(a);
27172         a_conv.is_owned = ptr_is_owned(a);
27173         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
27174         a_conv.is_owned = false;
27175         LDKHostname b_conv;
27176         b_conv.inner = untag_ptr(b);
27177         b_conv.is_owned = ptr_is_owned(b);
27178         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
27179         b_conv.is_owned = false;
27180         jboolean ret_conv = Hostname_eq(&a_conv, &b_conv);
27181         return ret_conv;
27182 }
27183
27184 JNIEXPORT int8_t JNICALL Java_org_ldk_impl_bindings_Hostname_1len(JNIEnv *env, jclass clz, int64_t this_arg) {
27185         LDKHostname this_arg_conv;
27186         this_arg_conv.inner = untag_ptr(this_arg);
27187         this_arg_conv.is_owned = ptr_is_owned(this_arg);
27188         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27189         this_arg_conv.is_owned = false;
27190         int8_t ret_conv = Hostname_len(&this_arg_conv);
27191         return ret_conv;
27192 }
27193
27194 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_sign(JNIEnv *env, jclass clz, int8_tArray msg, int8_tArray sk) {
27195         LDKu8slice msg_ref;
27196         msg_ref.datalen = (*env)->GetArrayLength(env, msg);
27197         msg_ref.data = (*env)->GetByteArrayElements (env, msg, NULL);
27198         unsigned char sk_arr[32];
27199         CHECK((*env)->GetArrayLength(env, sk) == 32);
27200         (*env)->GetByteArrayRegion(env, sk, 0, 32, sk_arr);
27201         unsigned char (*sk_ref)[32] = &sk_arr;
27202         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
27203         *ret_conv = sign(msg_ref, sk_ref);
27204         (*env)->ReleaseByteArrayElements(env, msg, (int8_t*)msg_ref.data, 0);
27205         return tag_ptr(ret_conv, true);
27206 }
27207
27208 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_recover_1pk(JNIEnv *env, jclass clz, int8_tArray msg, jstring sig) {
27209         LDKu8slice msg_ref;
27210         msg_ref.datalen = (*env)->GetArrayLength(env, msg);
27211         msg_ref.data = (*env)->GetByteArrayElements (env, msg, NULL);
27212         LDKStr sig_conv = java_to_owned_str(env, sig);
27213         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
27214         *ret_conv = recover_pk(msg_ref, sig_conv);
27215         (*env)->ReleaseByteArrayElements(env, msg, (int8_t*)msg_ref.data, 0);
27216         return tag_ptr(ret_conv, true);
27217 }
27218
27219 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_verify(JNIEnv *env, jclass clz, int8_tArray msg, jstring sig, int8_tArray pk) {
27220         LDKu8slice msg_ref;
27221         msg_ref.datalen = (*env)->GetArrayLength(env, msg);
27222         msg_ref.data = (*env)->GetByteArrayElements (env, msg, NULL);
27223         LDKStr sig_conv = java_to_owned_str(env, sig);
27224         LDKPublicKey pk_ref;
27225         CHECK((*env)->GetArrayLength(env, pk) == 33);
27226         (*env)->GetByteArrayRegion(env, pk, 0, 33, pk_ref.compressed_form);
27227         jboolean ret_conv = verify(msg_ref, sig_conv, pk_ref);
27228         (*env)->ReleaseByteArrayElements(env, msg, (int8_t*)msg_ref.data, 0);
27229         return ret_conv;
27230 }
27231
27232 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_construct_1invoice_1preimage(JNIEnv *env, jclass clz, int8_tArray hrp_bytes, jobjectArray data_without_signature) {
27233         LDKu8slice hrp_bytes_ref;
27234         hrp_bytes_ref.datalen = (*env)->GetArrayLength(env, hrp_bytes);
27235         hrp_bytes_ref.data = (*env)->GetByteArrayElements (env, hrp_bytes, NULL);
27236         LDKCVec_U5Z data_without_signature_constr;
27237         data_without_signature_constr.datalen = (*env)->GetArrayLength(env, data_without_signature);
27238         if (data_without_signature_constr.datalen > 0)
27239                 data_without_signature_constr.data = MALLOC(data_without_signature_constr.datalen * sizeof(LDKU5), "LDKCVec_U5Z Elements");
27240         else
27241                 data_without_signature_constr.data = NULL;
27242         int8_t* data_without_signature_vals = (*env)->GetByteArrayElements (env, data_without_signature, NULL);
27243         for (size_t h = 0; h < data_without_signature_constr.datalen; h++) {
27244                 int8_t data_without_signature_conv_7 = data_without_signature_vals[h];
27245                 
27246                 data_without_signature_constr.data[h] = (LDKU5){ ._0 = data_without_signature_conv_7 };
27247         }
27248         (*env)->ReleaseByteArrayElements(env, data_without_signature, data_without_signature_vals, 0);
27249         LDKCVec_u8Z ret_var = construct_invoice_preimage(hrp_bytes_ref, data_without_signature_constr);
27250         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
27251         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
27252         CVec_u8Z_free(ret_var);
27253         (*env)->ReleaseByteArrayElements(env, hrp_bytes, (int8_t*)hrp_bytes_ref.data, 0);
27254         return ret_arr;
27255 }
27256
27257 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Persister_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
27258         if (!ptr_is_owned(this_ptr)) return;
27259         void* this_ptr_ptr = untag_ptr(this_ptr);
27260         CHECK_ACCESS(this_ptr_ptr);
27261         LDKPersister this_ptr_conv = *(LDKPersister*)(this_ptr_ptr);
27262         FREE(untag_ptr(this_ptr));
27263         Persister_free(this_ptr_conv);
27264 }
27265
27266 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PrintableString_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
27267         LDKPrintableString this_obj_conv;
27268         this_obj_conv.inner = untag_ptr(this_obj);
27269         this_obj_conv.is_owned = ptr_is_owned(this_obj);
27270         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27271         PrintableString_free(this_obj_conv);
27272 }
27273
27274 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_PrintableString_1get_1a(JNIEnv *env, jclass clz, int64_t this_ptr) {
27275         LDKPrintableString this_ptr_conv;
27276         this_ptr_conv.inner = untag_ptr(this_ptr);
27277         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27278         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27279         this_ptr_conv.is_owned = false;
27280         LDKStr ret_str = PrintableString_get_a(&this_ptr_conv);
27281         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
27282         Str_free(ret_str);
27283         return ret_conv;
27284 }
27285
27286 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PrintableString_1set_1a(JNIEnv *env, jclass clz, int64_t this_ptr, jstring val) {
27287         LDKPrintableString this_ptr_conv;
27288         this_ptr_conv.inner = untag_ptr(this_ptr);
27289         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27290         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27291         this_ptr_conv.is_owned = false;
27292         LDKStr val_conv = java_to_owned_str(env, val);
27293         PrintableString_set_a(&this_ptr_conv, val_conv);
27294 }
27295
27296 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PrintableString_1new(JNIEnv *env, jclass clz, jstring a_arg) {
27297         LDKStr a_arg_conv = java_to_owned_str(env, a_arg);
27298         LDKPrintableString ret_var = PrintableString_new(a_arg_conv);
27299         int64_t ret_ref = 0;
27300         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27301         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
27302         return ret_ref;
27303 }
27304
27305 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FutureCallback_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
27306         if (!ptr_is_owned(this_ptr)) return;
27307         void* this_ptr_ptr = untag_ptr(this_ptr);
27308         CHECK_ACCESS(this_ptr_ptr);
27309         LDKFutureCallback this_ptr_conv = *(LDKFutureCallback*)(this_ptr_ptr);
27310         FREE(untag_ptr(this_ptr));
27311         FutureCallback_free(this_ptr_conv);
27312 }
27313
27314 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Future_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
27315         LDKFuture this_obj_conv;
27316         this_obj_conv.inner = untag_ptr(this_obj);
27317         this_obj_conv.is_owned = ptr_is_owned(this_obj);
27318         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27319         Future_free(this_obj_conv);
27320 }
27321
27322 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Future_1register_1callback_1fn(JNIEnv *env, jclass clz, int64_t this_arg, int64_t callback) {
27323         LDKFuture this_arg_conv;
27324         this_arg_conv.inner = untag_ptr(this_arg);
27325         this_arg_conv.is_owned = ptr_is_owned(this_arg);
27326         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
27327         this_arg_conv.is_owned = false;
27328         void* callback_ptr = untag_ptr(callback);
27329         CHECK_ACCESS(callback_ptr);
27330         LDKFutureCallback callback_conv = *(LDKFutureCallback*)(callback_ptr);
27331         if (callback_conv.free == LDKFutureCallback_JCalls_free) {
27332                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
27333                 LDKFutureCallback_JCalls_cloned(&callback_conv);
27334         }
27335         Future_register_callback_fn(&this_arg_conv, callback_conv);
27336 }
27337
27338 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1clone(JNIEnv *env, jclass clz, int64_t orig) {
27339         LDKLevel* orig_conv = (LDKLevel*)untag_ptr(orig);
27340         jclass ret_conv = LDKLevel_to_java(env, Level_clone(orig_conv));
27341         return ret_conv;
27342 }
27343
27344 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1gossip(JNIEnv *env, jclass clz) {
27345         jclass ret_conv = LDKLevel_to_java(env, Level_gossip());
27346         return ret_conv;
27347 }
27348
27349 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1trace(JNIEnv *env, jclass clz) {
27350         jclass ret_conv = LDKLevel_to_java(env, Level_trace());
27351         return ret_conv;
27352 }
27353
27354 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1debug(JNIEnv *env, jclass clz) {
27355         jclass ret_conv = LDKLevel_to_java(env, Level_debug());
27356         return ret_conv;
27357 }
27358
27359 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1info(JNIEnv *env, jclass clz) {
27360         jclass ret_conv = LDKLevel_to_java(env, Level_info());
27361         return ret_conv;
27362 }
27363
27364 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1warn(JNIEnv *env, jclass clz) {
27365         jclass ret_conv = LDKLevel_to_java(env, Level_warn());
27366         return ret_conv;
27367 }
27368
27369 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1error(JNIEnv *env, jclass clz) {
27370         jclass ret_conv = LDKLevel_to_java(env, Level_error());
27371         return ret_conv;
27372 }
27373
27374 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Level_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
27375         LDKLevel* a_conv = (LDKLevel*)untag_ptr(a);
27376         LDKLevel* b_conv = (LDKLevel*)untag_ptr(b);
27377         jboolean ret_conv = Level_eq(a_conv, b_conv);
27378         return ret_conv;
27379 }
27380
27381 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Level_1hash(JNIEnv *env, jclass clz, int64_t o) {
27382         LDKLevel* o_conv = (LDKLevel*)untag_ptr(o);
27383         int64_t ret_conv = Level_hash(o_conv);
27384         return ret_conv;
27385 }
27386
27387 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1max(JNIEnv *env, jclass clz) {
27388         jclass ret_conv = LDKLevel_to_java(env, Level_max());
27389         return ret_conv;
27390 }
27391
27392 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Record_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
27393         LDKRecord this_obj_conv;
27394         this_obj_conv.inner = untag_ptr(this_obj);
27395         this_obj_conv.is_owned = ptr_is_owned(this_obj);
27396         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27397         Record_free(this_obj_conv);
27398 }
27399
27400 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Record_1get_1level(JNIEnv *env, jclass clz, int64_t this_ptr) {
27401         LDKRecord this_ptr_conv;
27402         this_ptr_conv.inner = untag_ptr(this_ptr);
27403         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27404         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27405         this_ptr_conv.is_owned = false;
27406         jclass ret_conv = LDKLevel_to_java(env, Record_get_level(&this_ptr_conv));
27407         return ret_conv;
27408 }
27409
27410 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Record_1set_1level(JNIEnv *env, jclass clz, int64_t this_ptr, jclass val) {
27411         LDKRecord this_ptr_conv;
27412         this_ptr_conv.inner = untag_ptr(this_ptr);
27413         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27414         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27415         this_ptr_conv.is_owned = false;
27416         LDKLevel val_conv = LDKLevel_from_java(env, val);
27417         Record_set_level(&this_ptr_conv, val_conv);
27418 }
27419
27420 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Record_1get_1args(JNIEnv *env, jclass clz, int64_t this_ptr) {
27421         LDKRecord this_ptr_conv;
27422         this_ptr_conv.inner = untag_ptr(this_ptr);
27423         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27424         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27425         this_ptr_conv.is_owned = false;
27426         LDKStr ret_str = Record_get_args(&this_ptr_conv);
27427         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
27428         Str_free(ret_str);
27429         return ret_conv;
27430 }
27431
27432 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Record_1set_1args(JNIEnv *env, jclass clz, int64_t this_ptr, jstring val) {
27433         LDKRecord this_ptr_conv;
27434         this_ptr_conv.inner = untag_ptr(this_ptr);
27435         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27436         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27437         this_ptr_conv.is_owned = false;
27438         LDKStr val_conv = java_to_owned_str(env, val);
27439         Record_set_args(&this_ptr_conv, val_conv);
27440 }
27441
27442 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Record_1get_1module_1path(JNIEnv *env, jclass clz, int64_t this_ptr) {
27443         LDKRecord this_ptr_conv;
27444         this_ptr_conv.inner = untag_ptr(this_ptr);
27445         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27446         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27447         this_ptr_conv.is_owned = false;
27448         LDKStr ret_str = Record_get_module_path(&this_ptr_conv);
27449         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
27450         Str_free(ret_str);
27451         return ret_conv;
27452 }
27453
27454 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Record_1set_1module_1path(JNIEnv *env, jclass clz, int64_t this_ptr, jstring val) {
27455         LDKRecord this_ptr_conv;
27456         this_ptr_conv.inner = untag_ptr(this_ptr);
27457         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27458         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27459         this_ptr_conv.is_owned = false;
27460         LDKStr val_conv = java_to_owned_str(env, val);
27461         Record_set_module_path(&this_ptr_conv, val_conv);
27462 }
27463
27464 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Record_1get_1file(JNIEnv *env, jclass clz, int64_t this_ptr) {
27465         LDKRecord this_ptr_conv;
27466         this_ptr_conv.inner = untag_ptr(this_ptr);
27467         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27468         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27469         this_ptr_conv.is_owned = false;
27470         LDKStr ret_str = Record_get_file(&this_ptr_conv);
27471         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
27472         Str_free(ret_str);
27473         return ret_conv;
27474 }
27475
27476 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Record_1set_1file(JNIEnv *env, jclass clz, int64_t this_ptr, jstring val) {
27477         LDKRecord this_ptr_conv;
27478         this_ptr_conv.inner = untag_ptr(this_ptr);
27479         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27480         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27481         this_ptr_conv.is_owned = false;
27482         LDKStr val_conv = java_to_owned_str(env, val);
27483         Record_set_file(&this_ptr_conv, val_conv);
27484 }
27485
27486 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_Record_1get_1line(JNIEnv *env, jclass clz, int64_t this_ptr) {
27487         LDKRecord this_ptr_conv;
27488         this_ptr_conv.inner = untag_ptr(this_ptr);
27489         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27490         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27491         this_ptr_conv.is_owned = false;
27492         int32_t ret_conv = Record_get_line(&this_ptr_conv);
27493         return ret_conv;
27494 }
27495
27496 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Record_1set_1line(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
27497         LDKRecord this_ptr_conv;
27498         this_ptr_conv.inner = untag_ptr(this_ptr);
27499         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27500         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27501         this_ptr_conv.is_owned = false;
27502         Record_set_line(&this_ptr_conv, val);
27503 }
27504
27505 static inline uint64_t Record_clone_ptr(LDKRecord *NONNULL_PTR arg) {
27506         LDKRecord ret_var = Record_clone(arg);
27507         int64_t ret_ref = 0;
27508         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27509         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
27510         return ret_ref;
27511 }
27512 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Record_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
27513         LDKRecord arg_conv;
27514         arg_conv.inner = untag_ptr(arg);
27515         arg_conv.is_owned = ptr_is_owned(arg);
27516         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
27517         arg_conv.is_owned = false;
27518         int64_t ret_conv = Record_clone_ptr(&arg_conv);
27519         return ret_conv;
27520 }
27521
27522 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Record_1clone(JNIEnv *env, jclass clz, int64_t orig) {
27523         LDKRecord orig_conv;
27524         orig_conv.inner = untag_ptr(orig);
27525         orig_conv.is_owned = ptr_is_owned(orig);
27526         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
27527         orig_conv.is_owned = false;
27528         LDKRecord ret_var = Record_clone(&orig_conv);
27529         int64_t ret_ref = 0;
27530         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27531         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
27532         return ret_ref;
27533 }
27534
27535 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Logger_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
27536         if (!ptr_is_owned(this_ptr)) return;
27537         void* this_ptr_ptr = untag_ptr(this_ptr);
27538         CHECK_ACCESS(this_ptr_ptr);
27539         LDKLogger this_ptr_conv = *(LDKLogger*)(this_ptr_ptr);
27540         FREE(untag_ptr(this_ptr));
27541         Logger_free(this_ptr_conv);
27542 }
27543
27544 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
27545         LDKChannelHandshakeConfig this_obj_conv;
27546         this_obj_conv.inner = untag_ptr(this_obj);
27547         this_obj_conv.is_owned = ptr_is_owned(this_obj);
27548         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27549         ChannelHandshakeConfig_free(this_obj_conv);
27550 }
27551
27552 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr) {
27553         LDKChannelHandshakeConfig this_ptr_conv;
27554         this_ptr_conv.inner = untag_ptr(this_ptr);
27555         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27556         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27557         this_ptr_conv.is_owned = false;
27558         int32_t ret_conv = ChannelHandshakeConfig_get_minimum_depth(&this_ptr_conv);
27559         return ret_conv;
27560 }
27561
27562 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1set_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
27563         LDKChannelHandshakeConfig this_ptr_conv;
27564         this_ptr_conv.inner = untag_ptr(this_ptr);
27565         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27566         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27567         this_ptr_conv.is_owned = false;
27568         ChannelHandshakeConfig_set_minimum_depth(&this_ptr_conv, val);
27569 }
27570
27571 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1our_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
27572         LDKChannelHandshakeConfig this_ptr_conv;
27573         this_ptr_conv.inner = untag_ptr(this_ptr);
27574         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27575         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27576         this_ptr_conv.is_owned = false;
27577         int16_t ret_conv = ChannelHandshakeConfig_get_our_to_self_delay(&this_ptr_conv);
27578         return ret_conv;
27579 }
27580
27581 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) {
27582         LDKChannelHandshakeConfig this_ptr_conv;
27583         this_ptr_conv.inner = untag_ptr(this_ptr);
27584         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27585         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27586         this_ptr_conv.is_owned = false;
27587         ChannelHandshakeConfig_set_our_to_self_delay(&this_ptr_conv, val);
27588 }
27589
27590 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1our_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
27591         LDKChannelHandshakeConfig this_ptr_conv;
27592         this_ptr_conv.inner = untag_ptr(this_ptr);
27593         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27594         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27595         this_ptr_conv.is_owned = false;
27596         int64_t ret_conv = ChannelHandshakeConfig_get_our_htlc_minimum_msat(&this_ptr_conv);
27597         return ret_conv;
27598 }
27599
27600 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) {
27601         LDKChannelHandshakeConfig this_ptr_conv;
27602         this_ptr_conv.inner = untag_ptr(this_ptr);
27603         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27604         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27605         this_ptr_conv.is_owned = false;
27606         ChannelHandshakeConfig_set_our_htlc_minimum_msat(&this_ptr_conv, val);
27607 }
27608
27609 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) {
27610         LDKChannelHandshakeConfig this_ptr_conv;
27611         this_ptr_conv.inner = untag_ptr(this_ptr);
27612         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27613         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27614         this_ptr_conv.is_owned = false;
27615         int8_t ret_conv = ChannelHandshakeConfig_get_max_inbound_htlc_value_in_flight_percent_of_channel(&this_ptr_conv);
27616         return ret_conv;
27617 }
27618
27619 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) {
27620         LDKChannelHandshakeConfig this_ptr_conv;
27621         this_ptr_conv.inner = untag_ptr(this_ptr);
27622         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27623         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27624         this_ptr_conv.is_owned = false;
27625         ChannelHandshakeConfig_set_max_inbound_htlc_value_in_flight_percent_of_channel(&this_ptr_conv, val);
27626 }
27627
27628 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1negotiate_1scid_1privacy(JNIEnv *env, jclass clz, int64_t this_ptr) {
27629         LDKChannelHandshakeConfig this_ptr_conv;
27630         this_ptr_conv.inner = untag_ptr(this_ptr);
27631         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27632         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27633         this_ptr_conv.is_owned = false;
27634         jboolean ret_conv = ChannelHandshakeConfig_get_negotiate_scid_privacy(&this_ptr_conv);
27635         return ret_conv;
27636 }
27637
27638 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1set_1negotiate_1scid_1privacy(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
27639         LDKChannelHandshakeConfig this_ptr_conv;
27640         this_ptr_conv.inner = untag_ptr(this_ptr);
27641         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27642         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27643         this_ptr_conv.is_owned = false;
27644         ChannelHandshakeConfig_set_negotiate_scid_privacy(&this_ptr_conv, val);
27645 }
27646
27647 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1announced_1channel(JNIEnv *env, jclass clz, int64_t this_ptr) {
27648         LDKChannelHandshakeConfig this_ptr_conv;
27649         this_ptr_conv.inner = untag_ptr(this_ptr);
27650         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27651         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27652         this_ptr_conv.is_owned = false;
27653         jboolean ret_conv = ChannelHandshakeConfig_get_announced_channel(&this_ptr_conv);
27654         return ret_conv;
27655 }
27656
27657 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1set_1announced_1channel(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
27658         LDKChannelHandshakeConfig this_ptr_conv;
27659         this_ptr_conv.inner = untag_ptr(this_ptr);
27660         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27661         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27662         this_ptr_conv.is_owned = false;
27663         ChannelHandshakeConfig_set_announced_channel(&this_ptr_conv, val);
27664 }
27665
27666 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1commit_1upfront_1shutdown_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
27667         LDKChannelHandshakeConfig this_ptr_conv;
27668         this_ptr_conv.inner = untag_ptr(this_ptr);
27669         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27670         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27671         this_ptr_conv.is_owned = false;
27672         jboolean ret_conv = ChannelHandshakeConfig_get_commit_upfront_shutdown_pubkey(&this_ptr_conv);
27673         return ret_conv;
27674 }
27675
27676 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1set_1commit_1upfront_1shutdown_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
27677         LDKChannelHandshakeConfig this_ptr_conv;
27678         this_ptr_conv.inner = untag_ptr(this_ptr);
27679         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27680         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27681         this_ptr_conv.is_owned = false;
27682         ChannelHandshakeConfig_set_commit_upfront_shutdown_pubkey(&this_ptr_conv, val);
27683 }
27684
27685 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1their_1channel_1reserve_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr) {
27686         LDKChannelHandshakeConfig this_ptr_conv;
27687         this_ptr_conv.inner = untag_ptr(this_ptr);
27688         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27689         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27690         this_ptr_conv.is_owned = false;
27691         int32_t ret_conv = ChannelHandshakeConfig_get_their_channel_reserve_proportional_millionths(&this_ptr_conv);
27692         return ret_conv;
27693 }
27694
27695 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) {
27696         LDKChannelHandshakeConfig this_ptr_conv;
27697         this_ptr_conv.inner = untag_ptr(this_ptr);
27698         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27699         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27700         this_ptr_conv.is_owned = false;
27701         ChannelHandshakeConfig_set_their_channel_reserve_proportional_millionths(&this_ptr_conv, val);
27702 }
27703
27704 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) {
27705         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);
27706         int64_t ret_ref = 0;
27707         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27708         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
27709         return ret_ref;
27710 }
27711
27712 static inline uint64_t ChannelHandshakeConfig_clone_ptr(LDKChannelHandshakeConfig *NONNULL_PTR arg) {
27713         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_clone(arg);
27714         int64_t ret_ref = 0;
27715         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27716         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
27717         return ret_ref;
27718 }
27719 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
27720         LDKChannelHandshakeConfig arg_conv;
27721         arg_conv.inner = untag_ptr(arg);
27722         arg_conv.is_owned = ptr_is_owned(arg);
27723         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
27724         arg_conv.is_owned = false;
27725         int64_t ret_conv = ChannelHandshakeConfig_clone_ptr(&arg_conv);
27726         return ret_conv;
27727 }
27728
27729 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1clone(JNIEnv *env, jclass clz, int64_t orig) {
27730         LDKChannelHandshakeConfig orig_conv;
27731         orig_conv.inner = untag_ptr(orig);
27732         orig_conv.is_owned = ptr_is_owned(orig);
27733         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
27734         orig_conv.is_owned = false;
27735         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_clone(&orig_conv);
27736         int64_t ret_ref = 0;
27737         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27738         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
27739         return ret_ref;
27740 }
27741
27742 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1default(JNIEnv *env, jclass clz) {
27743         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_default();
27744         int64_t ret_ref = 0;
27745         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27746         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
27747         return ret_ref;
27748 }
27749
27750 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
27751         LDKChannelHandshakeLimits this_obj_conv;
27752         this_obj_conv.inner = untag_ptr(this_obj);
27753         this_obj_conv.is_owned = ptr_is_owned(this_obj);
27754         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27755         ChannelHandshakeLimits_free(this_obj_conv);
27756 }
27757
27758 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1min_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
27759         LDKChannelHandshakeLimits this_ptr_conv;
27760         this_ptr_conv.inner = untag_ptr(this_ptr);
27761         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27762         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27763         this_ptr_conv.is_owned = false;
27764         int64_t ret_conv = ChannelHandshakeLimits_get_min_funding_satoshis(&this_ptr_conv);
27765         return ret_conv;
27766 }
27767
27768 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1min_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
27769         LDKChannelHandshakeLimits this_ptr_conv;
27770         this_ptr_conv.inner = untag_ptr(this_ptr);
27771         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27772         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27773         this_ptr_conv.is_owned = false;
27774         ChannelHandshakeLimits_set_min_funding_satoshis(&this_ptr_conv, val);
27775 }
27776
27777 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1max_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
27778         LDKChannelHandshakeLimits this_ptr_conv;
27779         this_ptr_conv.inner = untag_ptr(this_ptr);
27780         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27781         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27782         this_ptr_conv.is_owned = false;
27783         int64_t ret_conv = ChannelHandshakeLimits_get_max_funding_satoshis(&this_ptr_conv);
27784         return ret_conv;
27785 }
27786
27787 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1max_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
27788         LDKChannelHandshakeLimits this_ptr_conv;
27789         this_ptr_conv.inner = untag_ptr(this_ptr);
27790         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27791         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27792         this_ptr_conv.is_owned = false;
27793         ChannelHandshakeLimits_set_max_funding_satoshis(&this_ptr_conv, val);
27794 }
27795
27796 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1max_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
27797         LDKChannelHandshakeLimits this_ptr_conv;
27798         this_ptr_conv.inner = untag_ptr(this_ptr);
27799         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27800         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27801         this_ptr_conv.is_owned = false;
27802         int64_t ret_conv = ChannelHandshakeLimits_get_max_htlc_minimum_msat(&this_ptr_conv);
27803         return ret_conv;
27804 }
27805
27806 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) {
27807         LDKChannelHandshakeLimits this_ptr_conv;
27808         this_ptr_conv.inner = untag_ptr(this_ptr);
27809         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27810         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27811         this_ptr_conv.is_owned = false;
27812         ChannelHandshakeLimits_set_max_htlc_minimum_msat(&this_ptr_conv, val);
27813 }
27814
27815 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) {
27816         LDKChannelHandshakeLimits this_ptr_conv;
27817         this_ptr_conv.inner = untag_ptr(this_ptr);
27818         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27819         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27820         this_ptr_conv.is_owned = false;
27821         int64_t ret_conv = ChannelHandshakeLimits_get_min_max_htlc_value_in_flight_msat(&this_ptr_conv);
27822         return ret_conv;
27823 }
27824
27825 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) {
27826         LDKChannelHandshakeLimits this_ptr_conv;
27827         this_ptr_conv.inner = untag_ptr(this_ptr);
27828         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27829         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27830         this_ptr_conv.is_owned = false;
27831         ChannelHandshakeLimits_set_min_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
27832 }
27833
27834 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1max_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
27835         LDKChannelHandshakeLimits this_ptr_conv;
27836         this_ptr_conv.inner = untag_ptr(this_ptr);
27837         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27838         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27839         this_ptr_conv.is_owned = false;
27840         int64_t ret_conv = ChannelHandshakeLimits_get_max_channel_reserve_satoshis(&this_ptr_conv);
27841         return ret_conv;
27842 }
27843
27844 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) {
27845         LDKChannelHandshakeLimits this_ptr_conv;
27846         this_ptr_conv.inner = untag_ptr(this_ptr);
27847         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27848         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27849         this_ptr_conv.is_owned = false;
27850         ChannelHandshakeLimits_set_max_channel_reserve_satoshis(&this_ptr_conv, val);
27851 }
27852
27853 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1min_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
27854         LDKChannelHandshakeLimits this_ptr_conv;
27855         this_ptr_conv.inner = untag_ptr(this_ptr);
27856         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27857         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27858         this_ptr_conv.is_owned = false;
27859         int16_t ret_conv = ChannelHandshakeLimits_get_min_max_accepted_htlcs(&this_ptr_conv);
27860         return ret_conv;
27861 }
27862
27863 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) {
27864         LDKChannelHandshakeLimits this_ptr_conv;
27865         this_ptr_conv.inner = untag_ptr(this_ptr);
27866         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27867         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27868         this_ptr_conv.is_owned = false;
27869         ChannelHandshakeLimits_set_min_max_accepted_htlcs(&this_ptr_conv, val);
27870 }
27871
27872 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1max_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr) {
27873         LDKChannelHandshakeLimits this_ptr_conv;
27874         this_ptr_conv.inner = untag_ptr(this_ptr);
27875         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27876         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27877         this_ptr_conv.is_owned = false;
27878         int32_t ret_conv = ChannelHandshakeLimits_get_max_minimum_depth(&this_ptr_conv);
27879         return ret_conv;
27880 }
27881
27882 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1max_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
27883         LDKChannelHandshakeLimits this_ptr_conv;
27884         this_ptr_conv.inner = untag_ptr(this_ptr);
27885         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27886         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27887         this_ptr_conv.is_owned = false;
27888         ChannelHandshakeLimits_set_max_minimum_depth(&this_ptr_conv, val);
27889 }
27890
27891 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1trust_1own_1funding_10conf(JNIEnv *env, jclass clz, int64_t this_ptr) {
27892         LDKChannelHandshakeLimits this_ptr_conv;
27893         this_ptr_conv.inner = untag_ptr(this_ptr);
27894         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27895         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27896         this_ptr_conv.is_owned = false;
27897         jboolean ret_conv = ChannelHandshakeLimits_get_trust_own_funding_0conf(&this_ptr_conv);
27898         return ret_conv;
27899 }
27900
27901 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1trust_1own_1funding_10conf(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
27902         LDKChannelHandshakeLimits this_ptr_conv;
27903         this_ptr_conv.inner = untag_ptr(this_ptr);
27904         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27905         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27906         this_ptr_conv.is_owned = false;
27907         ChannelHandshakeLimits_set_trust_own_funding_0conf(&this_ptr_conv, val);
27908 }
27909
27910 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1force_1announced_1channel_1preference(JNIEnv *env, jclass clz, int64_t this_ptr) {
27911         LDKChannelHandshakeLimits this_ptr_conv;
27912         this_ptr_conv.inner = untag_ptr(this_ptr);
27913         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27914         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27915         this_ptr_conv.is_owned = false;
27916         jboolean ret_conv = ChannelHandshakeLimits_get_force_announced_channel_preference(&this_ptr_conv);
27917         return ret_conv;
27918 }
27919
27920 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1force_1announced_1channel_1preference(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
27921         LDKChannelHandshakeLimits this_ptr_conv;
27922         this_ptr_conv.inner = untag_ptr(this_ptr);
27923         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27924         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27925         this_ptr_conv.is_owned = false;
27926         ChannelHandshakeLimits_set_force_announced_channel_preference(&this_ptr_conv, val);
27927 }
27928
27929 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1their_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
27930         LDKChannelHandshakeLimits this_ptr_conv;
27931         this_ptr_conv.inner = untag_ptr(this_ptr);
27932         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27933         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27934         this_ptr_conv.is_owned = false;
27935         int16_t ret_conv = ChannelHandshakeLimits_get_their_to_self_delay(&this_ptr_conv);
27936         return ret_conv;
27937 }
27938
27939 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) {
27940         LDKChannelHandshakeLimits this_ptr_conv;
27941         this_ptr_conv.inner = untag_ptr(this_ptr);
27942         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
27943         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27944         this_ptr_conv.is_owned = false;
27945         ChannelHandshakeLimits_set_their_to_self_delay(&this_ptr_conv, val);
27946 }
27947
27948 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) {
27949         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);
27950         int64_t ret_ref = 0;
27951         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27952         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
27953         return ret_ref;
27954 }
27955
27956 static inline uint64_t ChannelHandshakeLimits_clone_ptr(LDKChannelHandshakeLimits *NONNULL_PTR arg) {
27957         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_clone(arg);
27958         int64_t ret_ref = 0;
27959         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27960         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
27961         return ret_ref;
27962 }
27963 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
27964         LDKChannelHandshakeLimits arg_conv;
27965         arg_conv.inner = untag_ptr(arg);
27966         arg_conv.is_owned = ptr_is_owned(arg);
27967         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
27968         arg_conv.is_owned = false;
27969         int64_t ret_conv = ChannelHandshakeLimits_clone_ptr(&arg_conv);
27970         return ret_conv;
27971 }
27972
27973 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1clone(JNIEnv *env, jclass clz, int64_t orig) {
27974         LDKChannelHandshakeLimits orig_conv;
27975         orig_conv.inner = untag_ptr(orig);
27976         orig_conv.is_owned = ptr_is_owned(orig);
27977         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
27978         orig_conv.is_owned = false;
27979         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_clone(&orig_conv);
27980         int64_t ret_ref = 0;
27981         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27982         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
27983         return ret_ref;
27984 }
27985
27986 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1default(JNIEnv *env, jclass clz) {
27987         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_default();
27988         int64_t ret_ref = 0;
27989         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27990         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
27991         return ret_ref;
27992 }
27993
27994 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
27995         LDKChannelConfig this_obj_conv;
27996         this_obj_conv.inner = untag_ptr(this_obj);
27997         this_obj_conv.is_owned = ptr_is_owned(this_obj);
27998         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27999         ChannelConfig_free(this_obj_conv);
28000 }
28001
28002 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1forwarding_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr) {
28003         LDKChannelConfig this_ptr_conv;
28004         this_ptr_conv.inner = untag_ptr(this_ptr);
28005         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28006         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28007         this_ptr_conv.is_owned = false;
28008         int32_t ret_conv = ChannelConfig_get_forwarding_fee_proportional_millionths(&this_ptr_conv);
28009         return ret_conv;
28010 }
28011
28012 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) {
28013         LDKChannelConfig this_ptr_conv;
28014         this_ptr_conv.inner = untag_ptr(this_ptr);
28015         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28016         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28017         this_ptr_conv.is_owned = false;
28018         ChannelConfig_set_forwarding_fee_proportional_millionths(&this_ptr_conv, val);
28019 }
28020
28021 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1forwarding_1fee_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
28022         LDKChannelConfig this_ptr_conv;
28023         this_ptr_conv.inner = untag_ptr(this_ptr);
28024         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28025         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28026         this_ptr_conv.is_owned = false;
28027         int32_t ret_conv = ChannelConfig_get_forwarding_fee_base_msat(&this_ptr_conv);
28028         return ret_conv;
28029 }
28030
28031 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) {
28032         LDKChannelConfig this_ptr_conv;
28033         this_ptr_conv.inner = untag_ptr(this_ptr);
28034         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28035         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28036         this_ptr_conv.is_owned = false;
28037         ChannelConfig_set_forwarding_fee_base_msat(&this_ptr_conv, val);
28038 }
28039
28040 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
28041         LDKChannelConfig this_ptr_conv;
28042         this_ptr_conv.inner = untag_ptr(this_ptr);
28043         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28044         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28045         this_ptr_conv.is_owned = false;
28046         int16_t ret_conv = ChannelConfig_get_cltv_expiry_delta(&this_ptr_conv);
28047         return ret_conv;
28048 }
28049
28050 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
28051         LDKChannelConfig this_ptr_conv;
28052         this_ptr_conv.inner = untag_ptr(this_ptr);
28053         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28054         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28055         this_ptr_conv.is_owned = false;
28056         ChannelConfig_set_cltv_expiry_delta(&this_ptr_conv, val);
28057 }
28058
28059 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1max_1dust_1htlc_1exposure_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
28060         LDKChannelConfig this_ptr_conv;
28061         this_ptr_conv.inner = untag_ptr(this_ptr);
28062         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28063         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28064         this_ptr_conv.is_owned = false;
28065         int64_t ret_conv = ChannelConfig_get_max_dust_htlc_exposure_msat(&this_ptr_conv);
28066         return ret_conv;
28067 }
28068
28069 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) {
28070         LDKChannelConfig this_ptr_conv;
28071         this_ptr_conv.inner = untag_ptr(this_ptr);
28072         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28073         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28074         this_ptr_conv.is_owned = false;
28075         ChannelConfig_set_max_dust_htlc_exposure_msat(&this_ptr_conv, val);
28076 }
28077
28078 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) {
28079         LDKChannelConfig this_ptr_conv;
28080         this_ptr_conv.inner = untag_ptr(this_ptr);
28081         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28082         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28083         this_ptr_conv.is_owned = false;
28084         int64_t ret_conv = ChannelConfig_get_force_close_avoidance_max_fee_satoshis(&this_ptr_conv);
28085         return ret_conv;
28086 }
28087
28088 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) {
28089         LDKChannelConfig this_ptr_conv;
28090         this_ptr_conv.inner = untag_ptr(this_ptr);
28091         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28092         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28093         this_ptr_conv.is_owned = false;
28094         ChannelConfig_set_force_close_avoidance_max_fee_satoshis(&this_ptr_conv, val);
28095 }
28096
28097 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) {
28098         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);
28099         int64_t ret_ref = 0;
28100         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28101         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28102         return ret_ref;
28103 }
28104
28105 static inline uint64_t ChannelConfig_clone_ptr(LDKChannelConfig *NONNULL_PTR arg) {
28106         LDKChannelConfig ret_var = ChannelConfig_clone(arg);
28107         int64_t ret_ref = 0;
28108         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28109         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28110         return ret_ref;
28111 }
28112 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
28113         LDKChannelConfig arg_conv;
28114         arg_conv.inner = untag_ptr(arg);
28115         arg_conv.is_owned = ptr_is_owned(arg);
28116         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
28117         arg_conv.is_owned = false;
28118         int64_t ret_conv = ChannelConfig_clone_ptr(&arg_conv);
28119         return ret_conv;
28120 }
28121
28122 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1clone(JNIEnv *env, jclass clz, int64_t orig) {
28123         LDKChannelConfig orig_conv;
28124         orig_conv.inner = untag_ptr(orig);
28125         orig_conv.is_owned = ptr_is_owned(orig);
28126         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
28127         orig_conv.is_owned = false;
28128         LDKChannelConfig ret_var = ChannelConfig_clone(&orig_conv);
28129         int64_t ret_ref = 0;
28130         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28131         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28132         return ret_ref;
28133 }
28134
28135 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
28136         LDKChannelConfig a_conv;
28137         a_conv.inner = untag_ptr(a);
28138         a_conv.is_owned = ptr_is_owned(a);
28139         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
28140         a_conv.is_owned = false;
28141         LDKChannelConfig b_conv;
28142         b_conv.inner = untag_ptr(b);
28143         b_conv.is_owned = ptr_is_owned(b);
28144         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
28145         b_conv.is_owned = false;
28146         jboolean ret_conv = ChannelConfig_eq(&a_conv, &b_conv);
28147         return ret_conv;
28148 }
28149
28150 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1default(JNIEnv *env, jclass clz) {
28151         LDKChannelConfig ret_var = ChannelConfig_default();
28152         int64_t ret_ref = 0;
28153         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28154         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28155         return ret_ref;
28156 }
28157
28158 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1write(JNIEnv *env, jclass clz, int64_t obj) {
28159         LDKChannelConfig obj_conv;
28160         obj_conv.inner = untag_ptr(obj);
28161         obj_conv.is_owned = ptr_is_owned(obj);
28162         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
28163         obj_conv.is_owned = false;
28164         LDKCVec_u8Z ret_var = ChannelConfig_write(&obj_conv);
28165         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
28166         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
28167         CVec_u8Z_free(ret_var);
28168         return ret_arr;
28169 }
28170
28171 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
28172         LDKu8slice ser_ref;
28173         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
28174         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
28175         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
28176         *ret_conv = ChannelConfig_read(ser_ref);
28177         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
28178         return tag_ptr(ret_conv, true);
28179 }
28180
28181 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
28182         LDKUserConfig this_obj_conv;
28183         this_obj_conv.inner = untag_ptr(this_obj);
28184         this_obj_conv.is_owned = ptr_is_owned(this_obj);
28185         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28186         UserConfig_free(this_obj_conv);
28187 }
28188
28189 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1channel_1handshake_1config(JNIEnv *env, jclass clz, int64_t this_ptr) {
28190         LDKUserConfig this_ptr_conv;
28191         this_ptr_conv.inner = untag_ptr(this_ptr);
28192         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28193         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28194         this_ptr_conv.is_owned = false;
28195         LDKChannelHandshakeConfig ret_var = UserConfig_get_channel_handshake_config(&this_ptr_conv);
28196         int64_t ret_ref = 0;
28197         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28198         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28199         return ret_ref;
28200 }
28201
28202 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1set_1channel_1handshake_1config(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
28203         LDKUserConfig this_ptr_conv;
28204         this_ptr_conv.inner = untag_ptr(this_ptr);
28205         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28206         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28207         this_ptr_conv.is_owned = false;
28208         LDKChannelHandshakeConfig val_conv;
28209         val_conv.inner = untag_ptr(val);
28210         val_conv.is_owned = ptr_is_owned(val);
28211         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
28212         val_conv = ChannelHandshakeConfig_clone(&val_conv);
28213         UserConfig_set_channel_handshake_config(&this_ptr_conv, val_conv);
28214 }
28215
28216 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1channel_1handshake_1limits(JNIEnv *env, jclass clz, int64_t this_ptr) {
28217         LDKUserConfig this_ptr_conv;
28218         this_ptr_conv.inner = untag_ptr(this_ptr);
28219         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28220         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28221         this_ptr_conv.is_owned = false;
28222         LDKChannelHandshakeLimits ret_var = UserConfig_get_channel_handshake_limits(&this_ptr_conv);
28223         int64_t ret_ref = 0;
28224         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28225         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28226         return ret_ref;
28227 }
28228
28229 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1set_1channel_1handshake_1limits(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
28230         LDKUserConfig this_ptr_conv;
28231         this_ptr_conv.inner = untag_ptr(this_ptr);
28232         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28233         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28234         this_ptr_conv.is_owned = false;
28235         LDKChannelHandshakeLimits val_conv;
28236         val_conv.inner = untag_ptr(val);
28237         val_conv.is_owned = ptr_is_owned(val);
28238         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
28239         val_conv = ChannelHandshakeLimits_clone(&val_conv);
28240         UserConfig_set_channel_handshake_limits(&this_ptr_conv, val_conv);
28241 }
28242
28243 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1channel_1config(JNIEnv *env, jclass clz, int64_t this_ptr) {
28244         LDKUserConfig this_ptr_conv;
28245         this_ptr_conv.inner = untag_ptr(this_ptr);
28246         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28247         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28248         this_ptr_conv.is_owned = false;
28249         LDKChannelConfig ret_var = UserConfig_get_channel_config(&this_ptr_conv);
28250         int64_t ret_ref = 0;
28251         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28252         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28253         return ret_ref;
28254 }
28255
28256 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1set_1channel_1config(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
28257         LDKUserConfig this_ptr_conv;
28258         this_ptr_conv.inner = untag_ptr(this_ptr);
28259         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28260         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28261         this_ptr_conv.is_owned = false;
28262         LDKChannelConfig val_conv;
28263         val_conv.inner = untag_ptr(val);
28264         val_conv.is_owned = ptr_is_owned(val);
28265         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
28266         val_conv = ChannelConfig_clone(&val_conv);
28267         UserConfig_set_channel_config(&this_ptr_conv, val_conv);
28268 }
28269
28270 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1accept_1forwards_1to_1priv_1channels(JNIEnv *env, jclass clz, int64_t this_ptr) {
28271         LDKUserConfig this_ptr_conv;
28272         this_ptr_conv.inner = untag_ptr(this_ptr);
28273         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28274         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28275         this_ptr_conv.is_owned = false;
28276         jboolean ret_conv = UserConfig_get_accept_forwards_to_priv_channels(&this_ptr_conv);
28277         return ret_conv;
28278 }
28279
28280 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) {
28281         LDKUserConfig this_ptr_conv;
28282         this_ptr_conv.inner = untag_ptr(this_ptr);
28283         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28284         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28285         this_ptr_conv.is_owned = false;
28286         UserConfig_set_accept_forwards_to_priv_channels(&this_ptr_conv, val);
28287 }
28288
28289 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1accept_1inbound_1channels(JNIEnv *env, jclass clz, int64_t this_ptr) {
28290         LDKUserConfig this_ptr_conv;
28291         this_ptr_conv.inner = untag_ptr(this_ptr);
28292         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28293         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28294         this_ptr_conv.is_owned = false;
28295         jboolean ret_conv = UserConfig_get_accept_inbound_channels(&this_ptr_conv);
28296         return ret_conv;
28297 }
28298
28299 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1set_1accept_1inbound_1channels(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
28300         LDKUserConfig this_ptr_conv;
28301         this_ptr_conv.inner = untag_ptr(this_ptr);
28302         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28303         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28304         this_ptr_conv.is_owned = false;
28305         UserConfig_set_accept_inbound_channels(&this_ptr_conv, val);
28306 }
28307
28308 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1manually_1accept_1inbound_1channels(JNIEnv *env, jclass clz, int64_t this_ptr) {
28309         LDKUserConfig this_ptr_conv;
28310         this_ptr_conv.inner = untag_ptr(this_ptr);
28311         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28312         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28313         this_ptr_conv.is_owned = false;
28314         jboolean ret_conv = UserConfig_get_manually_accept_inbound_channels(&this_ptr_conv);
28315         return ret_conv;
28316 }
28317
28318 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1set_1manually_1accept_1inbound_1channels(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
28319         LDKUserConfig this_ptr_conv;
28320         this_ptr_conv.inner = untag_ptr(this_ptr);
28321         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28322         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28323         this_ptr_conv.is_owned = false;
28324         UserConfig_set_manually_accept_inbound_channels(&this_ptr_conv, val);
28325 }
28326
28327 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1accept_1intercept_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
28328         LDKUserConfig this_ptr_conv;
28329         this_ptr_conv.inner = untag_ptr(this_ptr);
28330         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28331         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28332         this_ptr_conv.is_owned = false;
28333         jboolean ret_conv = UserConfig_get_accept_intercept_htlcs(&this_ptr_conv);
28334         return ret_conv;
28335 }
28336
28337 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1set_1accept_1intercept_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
28338         LDKUserConfig this_ptr_conv;
28339         this_ptr_conv.inner = untag_ptr(this_ptr);
28340         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28341         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28342         this_ptr_conv.is_owned = false;
28343         UserConfig_set_accept_intercept_htlcs(&this_ptr_conv, val);
28344 }
28345
28346 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, jboolean accept_intercept_htlcs_arg) {
28347         LDKChannelHandshakeConfig channel_handshake_config_arg_conv;
28348         channel_handshake_config_arg_conv.inner = untag_ptr(channel_handshake_config_arg);
28349         channel_handshake_config_arg_conv.is_owned = ptr_is_owned(channel_handshake_config_arg);
28350         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_handshake_config_arg_conv);
28351         channel_handshake_config_arg_conv = ChannelHandshakeConfig_clone(&channel_handshake_config_arg_conv);
28352         LDKChannelHandshakeLimits channel_handshake_limits_arg_conv;
28353         channel_handshake_limits_arg_conv.inner = untag_ptr(channel_handshake_limits_arg);
28354         channel_handshake_limits_arg_conv.is_owned = ptr_is_owned(channel_handshake_limits_arg);
28355         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_handshake_limits_arg_conv);
28356         channel_handshake_limits_arg_conv = ChannelHandshakeLimits_clone(&channel_handshake_limits_arg_conv);
28357         LDKChannelConfig channel_config_arg_conv;
28358         channel_config_arg_conv.inner = untag_ptr(channel_config_arg);
28359         channel_config_arg_conv.is_owned = ptr_is_owned(channel_config_arg);
28360         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_config_arg_conv);
28361         channel_config_arg_conv = ChannelConfig_clone(&channel_config_arg_conv);
28362         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, accept_intercept_htlcs_arg);
28363         int64_t ret_ref = 0;
28364         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28365         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28366         return ret_ref;
28367 }
28368
28369 static inline uint64_t UserConfig_clone_ptr(LDKUserConfig *NONNULL_PTR arg) {
28370         LDKUserConfig ret_var = UserConfig_clone(arg);
28371         int64_t ret_ref = 0;
28372         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28373         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28374         return ret_ref;
28375 }
28376 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
28377         LDKUserConfig arg_conv;
28378         arg_conv.inner = untag_ptr(arg);
28379         arg_conv.is_owned = ptr_is_owned(arg);
28380         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
28381         arg_conv.is_owned = false;
28382         int64_t ret_conv = UserConfig_clone_ptr(&arg_conv);
28383         return ret_conv;
28384 }
28385
28386 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1clone(JNIEnv *env, jclass clz, int64_t orig) {
28387         LDKUserConfig orig_conv;
28388         orig_conv.inner = untag_ptr(orig);
28389         orig_conv.is_owned = ptr_is_owned(orig);
28390         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
28391         orig_conv.is_owned = false;
28392         LDKUserConfig ret_var = UserConfig_clone(&orig_conv);
28393         int64_t ret_ref = 0;
28394         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28395         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28396         return ret_ref;
28397 }
28398
28399 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1default(JNIEnv *env, jclass clz) {
28400         LDKUserConfig ret_var = UserConfig_default();
28401         int64_t ret_ref = 0;
28402         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28403         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28404         return ret_ref;
28405 }
28406
28407 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BestBlock_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
28408         LDKBestBlock this_obj_conv;
28409         this_obj_conv.inner = untag_ptr(this_obj);
28410         this_obj_conv.is_owned = ptr_is_owned(this_obj);
28411         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28412         BestBlock_free(this_obj_conv);
28413 }
28414
28415 static inline uint64_t BestBlock_clone_ptr(LDKBestBlock *NONNULL_PTR arg) {
28416         LDKBestBlock ret_var = BestBlock_clone(arg);
28417         int64_t ret_ref = 0;
28418         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28419         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28420         return ret_ref;
28421 }
28422 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
28423         LDKBestBlock arg_conv;
28424         arg_conv.inner = untag_ptr(arg);
28425         arg_conv.is_owned = ptr_is_owned(arg);
28426         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
28427         arg_conv.is_owned = false;
28428         int64_t ret_conv = BestBlock_clone_ptr(&arg_conv);
28429         return ret_conv;
28430 }
28431
28432 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1clone(JNIEnv *env, jclass clz, int64_t orig) {
28433         LDKBestBlock orig_conv;
28434         orig_conv.inner = untag_ptr(orig);
28435         orig_conv.is_owned = ptr_is_owned(orig);
28436         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
28437         orig_conv.is_owned = false;
28438         LDKBestBlock ret_var = BestBlock_clone(&orig_conv);
28439         int64_t ret_ref = 0;
28440         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28441         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28442         return ret_ref;
28443 }
28444
28445 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_BestBlock_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
28446         LDKBestBlock a_conv;
28447         a_conv.inner = untag_ptr(a);
28448         a_conv.is_owned = ptr_is_owned(a);
28449         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
28450         a_conv.is_owned = false;
28451         LDKBestBlock b_conv;
28452         b_conv.inner = untag_ptr(b);
28453         b_conv.is_owned = ptr_is_owned(b);
28454         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
28455         b_conv.is_owned = false;
28456         jboolean ret_conv = BestBlock_eq(&a_conv, &b_conv);
28457         return ret_conv;
28458 }
28459
28460 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1from_1genesis(JNIEnv *env, jclass clz, jclass network) {
28461         LDKNetwork network_conv = LDKNetwork_from_java(env, network);
28462         LDKBestBlock ret_var = BestBlock_from_genesis(network_conv);
28463         int64_t ret_ref = 0;
28464         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28465         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28466         return ret_ref;
28467 }
28468
28469 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1new(JNIEnv *env, jclass clz, int8_tArray block_hash, int32_t height) {
28470         LDKThirtyTwoBytes block_hash_ref;
28471         CHECK((*env)->GetArrayLength(env, block_hash) == 32);
28472         (*env)->GetByteArrayRegion(env, block_hash, 0, 32, block_hash_ref.data);
28473         LDKBestBlock ret_var = BestBlock_new(block_hash_ref, height);
28474         int64_t ret_ref = 0;
28475         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28476         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28477         return ret_ref;
28478 }
28479
28480 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BestBlock_1block_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
28481         LDKBestBlock this_arg_conv;
28482         this_arg_conv.inner = untag_ptr(this_arg);
28483         this_arg_conv.is_owned = ptr_is_owned(this_arg);
28484         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28485         this_arg_conv.is_owned = false;
28486         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
28487         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, BestBlock_block_hash(&this_arg_conv).data);
28488         return ret_arr;
28489 }
28490
28491 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1height(JNIEnv *env, jclass clz, int64_t this_arg) {
28492         LDKBestBlock this_arg_conv;
28493         this_arg_conv.inner = untag_ptr(this_arg);
28494         this_arg_conv.is_owned = ptr_is_owned(this_arg);
28495         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28496         this_arg_conv.is_owned = false;
28497         int32_t ret_conv = BestBlock_height(&this_arg_conv);
28498         return ret_conv;
28499 }
28500
28501 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_AccessError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
28502         LDKAccessError* orig_conv = (LDKAccessError*)untag_ptr(orig);
28503         jclass ret_conv = LDKAccessError_to_java(env, AccessError_clone(orig_conv));
28504         return ret_conv;
28505 }
28506
28507 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_AccessError_1unknown_1chain(JNIEnv *env, jclass clz) {
28508         jclass ret_conv = LDKAccessError_to_java(env, AccessError_unknown_chain());
28509         return ret_conv;
28510 }
28511
28512 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_AccessError_1unknown_1tx(JNIEnv *env, jclass clz) {
28513         jclass ret_conv = LDKAccessError_to_java(env, AccessError_unknown_tx());
28514         return ret_conv;
28515 }
28516
28517 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Access_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
28518         if (!ptr_is_owned(this_ptr)) return;
28519         void* this_ptr_ptr = untag_ptr(this_ptr);
28520         CHECK_ACCESS(this_ptr_ptr);
28521         LDKAccess this_ptr_conv = *(LDKAccess*)(this_ptr_ptr);
28522         FREE(untag_ptr(this_ptr));
28523         Access_free(this_ptr_conv);
28524 }
28525
28526 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Listen_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
28527         if (!ptr_is_owned(this_ptr)) return;
28528         void* this_ptr_ptr = untag_ptr(this_ptr);
28529         CHECK_ACCESS(this_ptr_ptr);
28530         LDKListen this_ptr_conv = *(LDKListen*)(this_ptr_ptr);
28531         FREE(untag_ptr(this_ptr));
28532         Listen_free(this_ptr_conv);
28533 }
28534
28535 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Confirm_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
28536         if (!ptr_is_owned(this_ptr)) return;
28537         void* this_ptr_ptr = untag_ptr(this_ptr);
28538         CHECK_ACCESS(this_ptr_ptr);
28539         LDKConfirm this_ptr_conv = *(LDKConfirm*)(this_ptr_ptr);
28540         FREE(untag_ptr(this_ptr));
28541         Confirm_free(this_ptr_conv);
28542 }
28543
28544 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdateStatus_1clone(JNIEnv *env, jclass clz, int64_t orig) {
28545         LDKChannelMonitorUpdateStatus* orig_conv = (LDKChannelMonitorUpdateStatus*)untag_ptr(orig);
28546         jclass ret_conv = LDKChannelMonitorUpdateStatus_to_java(env, ChannelMonitorUpdateStatus_clone(orig_conv));
28547         return ret_conv;
28548 }
28549
28550 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdateStatus_1completed(JNIEnv *env, jclass clz) {
28551         jclass ret_conv = LDKChannelMonitorUpdateStatus_to_java(env, ChannelMonitorUpdateStatus_completed());
28552         return ret_conv;
28553 }
28554
28555 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdateStatus_1in_1progress(JNIEnv *env, jclass clz) {
28556         jclass ret_conv = LDKChannelMonitorUpdateStatus_to_java(env, ChannelMonitorUpdateStatus_in_progress());
28557         return ret_conv;
28558 }
28559
28560 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdateStatus_1permanent_1failure(JNIEnv *env, jclass clz) {
28561         jclass ret_conv = LDKChannelMonitorUpdateStatus_to_java(env, ChannelMonitorUpdateStatus_permanent_failure());
28562         return ret_conv;
28563 }
28564
28565 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdateStatus_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
28566         LDKChannelMonitorUpdateStatus* a_conv = (LDKChannelMonitorUpdateStatus*)untag_ptr(a);
28567         LDKChannelMonitorUpdateStatus* b_conv = (LDKChannelMonitorUpdateStatus*)untag_ptr(b);
28568         jboolean ret_conv = ChannelMonitorUpdateStatus_eq(a_conv, b_conv);
28569         return ret_conv;
28570 }
28571
28572 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Watch_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
28573         if (!ptr_is_owned(this_ptr)) return;
28574         void* this_ptr_ptr = untag_ptr(this_ptr);
28575         CHECK_ACCESS(this_ptr_ptr);
28576         LDKWatch this_ptr_conv = *(LDKWatch*)(this_ptr_ptr);
28577         FREE(untag_ptr(this_ptr));
28578         Watch_free(this_ptr_conv);
28579 }
28580
28581 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Filter_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
28582         if (!ptr_is_owned(this_ptr)) return;
28583         void* this_ptr_ptr = untag_ptr(this_ptr);
28584         CHECK_ACCESS(this_ptr_ptr);
28585         LDKFilter this_ptr_conv = *(LDKFilter*)(this_ptr_ptr);
28586         FREE(untag_ptr(this_ptr));
28587         Filter_free(this_ptr_conv);
28588 }
28589
28590 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
28591         LDKWatchedOutput this_obj_conv;
28592         this_obj_conv.inner = untag_ptr(this_obj);
28593         this_obj_conv.is_owned = ptr_is_owned(this_obj);
28594         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28595         WatchedOutput_free(this_obj_conv);
28596 }
28597
28598 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1get_1block_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
28599         LDKWatchedOutput this_ptr_conv;
28600         this_ptr_conv.inner = untag_ptr(this_ptr);
28601         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28602         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28603         this_ptr_conv.is_owned = false;
28604         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
28605         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, WatchedOutput_get_block_hash(&this_ptr_conv).data);
28606         return ret_arr;
28607 }
28608
28609 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1set_1block_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
28610         LDKWatchedOutput this_ptr_conv;
28611         this_ptr_conv.inner = untag_ptr(this_ptr);
28612         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28613         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28614         this_ptr_conv.is_owned = false;
28615         LDKThirtyTwoBytes val_ref;
28616         CHECK((*env)->GetArrayLength(env, val) == 32);
28617         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
28618         WatchedOutput_set_block_hash(&this_ptr_conv, val_ref);
28619 }
28620
28621 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1get_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
28622         LDKWatchedOutput this_ptr_conv;
28623         this_ptr_conv.inner = untag_ptr(this_ptr);
28624         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28625         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28626         this_ptr_conv.is_owned = false;
28627         LDKOutPoint ret_var = WatchedOutput_get_outpoint(&this_ptr_conv);
28628         int64_t ret_ref = 0;
28629         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28630         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28631         return ret_ref;
28632 }
28633
28634 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1set_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
28635         LDKWatchedOutput this_ptr_conv;
28636         this_ptr_conv.inner = untag_ptr(this_ptr);
28637         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28638         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28639         this_ptr_conv.is_owned = false;
28640         LDKOutPoint val_conv;
28641         val_conv.inner = untag_ptr(val);
28642         val_conv.is_owned = ptr_is_owned(val);
28643         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
28644         val_conv = OutPoint_clone(&val_conv);
28645         WatchedOutput_set_outpoint(&this_ptr_conv, val_conv);
28646 }
28647
28648 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1get_1script_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
28649         LDKWatchedOutput this_ptr_conv;
28650         this_ptr_conv.inner = untag_ptr(this_ptr);
28651         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28652         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28653         this_ptr_conv.is_owned = false;
28654         LDKu8slice ret_var = WatchedOutput_get_script_pubkey(&this_ptr_conv);
28655         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
28656         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
28657         return ret_arr;
28658 }
28659
28660 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1set_1script_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
28661         LDKWatchedOutput this_ptr_conv;
28662         this_ptr_conv.inner = untag_ptr(this_ptr);
28663         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
28664         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28665         this_ptr_conv.is_owned = false;
28666         LDKCVec_u8Z val_ref;
28667         val_ref.datalen = (*env)->GetArrayLength(env, val);
28668         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
28669         (*env)->GetByteArrayRegion(env, val, 0, val_ref.datalen, val_ref.data);
28670         WatchedOutput_set_script_pubkey(&this_ptr_conv, val_ref);
28671 }
28672
28673 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) {
28674         LDKThirtyTwoBytes block_hash_arg_ref;
28675         CHECK((*env)->GetArrayLength(env, block_hash_arg) == 32);
28676         (*env)->GetByteArrayRegion(env, block_hash_arg, 0, 32, block_hash_arg_ref.data);
28677         LDKOutPoint outpoint_arg_conv;
28678         outpoint_arg_conv.inner = untag_ptr(outpoint_arg);
28679         outpoint_arg_conv.is_owned = ptr_is_owned(outpoint_arg);
28680         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_arg_conv);
28681         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
28682         LDKCVec_u8Z script_pubkey_arg_ref;
28683         script_pubkey_arg_ref.datalen = (*env)->GetArrayLength(env, script_pubkey_arg);
28684         script_pubkey_arg_ref.data = MALLOC(script_pubkey_arg_ref.datalen, "LDKCVec_u8Z Bytes");
28685         (*env)->GetByteArrayRegion(env, script_pubkey_arg, 0, script_pubkey_arg_ref.datalen, script_pubkey_arg_ref.data);
28686         LDKWatchedOutput ret_var = WatchedOutput_new(block_hash_arg_ref, outpoint_arg_conv, script_pubkey_arg_ref);
28687         int64_t ret_ref = 0;
28688         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28689         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28690         return ret_ref;
28691 }
28692
28693 static inline uint64_t WatchedOutput_clone_ptr(LDKWatchedOutput *NONNULL_PTR arg) {
28694         LDKWatchedOutput ret_var = WatchedOutput_clone(arg);
28695         int64_t ret_ref = 0;
28696         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28697         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28698         return ret_ref;
28699 }
28700 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
28701         LDKWatchedOutput arg_conv;
28702         arg_conv.inner = untag_ptr(arg);
28703         arg_conv.is_owned = ptr_is_owned(arg);
28704         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
28705         arg_conv.is_owned = false;
28706         int64_t ret_conv = WatchedOutput_clone_ptr(&arg_conv);
28707         return ret_conv;
28708 }
28709
28710 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1clone(JNIEnv *env, jclass clz, int64_t orig) {
28711         LDKWatchedOutput orig_conv;
28712         orig_conv.inner = untag_ptr(orig);
28713         orig_conv.is_owned = ptr_is_owned(orig);
28714         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
28715         orig_conv.is_owned = false;
28716         LDKWatchedOutput ret_var = WatchedOutput_clone(&orig_conv);
28717         int64_t ret_ref = 0;
28718         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28719         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28720         return ret_ref;
28721 }
28722
28723 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
28724         LDKWatchedOutput a_conv;
28725         a_conv.inner = untag_ptr(a);
28726         a_conv.is_owned = ptr_is_owned(a);
28727         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
28728         a_conv.is_owned = false;
28729         LDKWatchedOutput b_conv;
28730         b_conv.inner = untag_ptr(b);
28731         b_conv.is_owned = ptr_is_owned(b);
28732         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
28733         b_conv.is_owned = false;
28734         jboolean ret_conv = WatchedOutput_eq(&a_conv, &b_conv);
28735         return ret_conv;
28736 }
28737
28738 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1hash(JNIEnv *env, jclass clz, int64_t o) {
28739         LDKWatchedOutput o_conv;
28740         o_conv.inner = untag_ptr(o);
28741         o_conv.is_owned = ptr_is_owned(o);
28742         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
28743         o_conv.is_owned = false;
28744         int64_t ret_conv = WatchedOutput_hash(&o_conv);
28745         return ret_conv;
28746 }
28747
28748 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BroadcasterInterface_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
28749         if (!ptr_is_owned(this_ptr)) return;
28750         void* this_ptr_ptr = untag_ptr(this_ptr);
28751         CHECK_ACCESS(this_ptr_ptr);
28752         LDKBroadcasterInterface this_ptr_conv = *(LDKBroadcasterInterface*)(this_ptr_ptr);
28753         FREE(untag_ptr(this_ptr));
28754         BroadcasterInterface_free(this_ptr_conv);
28755 }
28756
28757 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ConfirmationTarget_1clone(JNIEnv *env, jclass clz, int64_t orig) {
28758         LDKConfirmationTarget* orig_conv = (LDKConfirmationTarget*)untag_ptr(orig);
28759         jclass ret_conv = LDKConfirmationTarget_to_java(env, ConfirmationTarget_clone(orig_conv));
28760         return ret_conv;
28761 }
28762
28763 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ConfirmationTarget_1background(JNIEnv *env, jclass clz) {
28764         jclass ret_conv = LDKConfirmationTarget_to_java(env, ConfirmationTarget_background());
28765         return ret_conv;
28766 }
28767
28768 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ConfirmationTarget_1normal(JNIEnv *env, jclass clz) {
28769         jclass ret_conv = LDKConfirmationTarget_to_java(env, ConfirmationTarget_normal());
28770         return ret_conv;
28771 }
28772
28773 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ConfirmationTarget_1high_1priority(JNIEnv *env, jclass clz) {
28774         jclass ret_conv = LDKConfirmationTarget_to_java(env, ConfirmationTarget_high_priority());
28775         return ret_conv;
28776 }
28777
28778 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ConfirmationTarget_1hash(JNIEnv *env, jclass clz, int64_t o) {
28779         LDKConfirmationTarget* o_conv = (LDKConfirmationTarget*)untag_ptr(o);
28780         int64_t ret_conv = ConfirmationTarget_hash(o_conv);
28781         return ret_conv;
28782 }
28783
28784 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ConfirmationTarget_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
28785         LDKConfirmationTarget* a_conv = (LDKConfirmationTarget*)untag_ptr(a);
28786         LDKConfirmationTarget* b_conv = (LDKConfirmationTarget*)untag_ptr(b);
28787         jboolean ret_conv = ConfirmationTarget_eq(a_conv, b_conv);
28788         return ret_conv;
28789 }
28790
28791 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FeeEstimator_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
28792         if (!ptr_is_owned(this_ptr)) return;
28793         void* this_ptr_ptr = untag_ptr(this_ptr);
28794         CHECK_ACCESS(this_ptr_ptr);
28795         LDKFeeEstimator this_ptr_conv = *(LDKFeeEstimator*)(this_ptr_ptr);
28796         FREE(untag_ptr(this_ptr));
28797         FeeEstimator_free(this_ptr_conv);
28798 }
28799
28800 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MonitorUpdateId_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
28801         LDKMonitorUpdateId this_obj_conv;
28802         this_obj_conv.inner = untag_ptr(this_obj);
28803         this_obj_conv.is_owned = ptr_is_owned(this_obj);
28804         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28805         MonitorUpdateId_free(this_obj_conv);
28806 }
28807
28808 static inline uint64_t MonitorUpdateId_clone_ptr(LDKMonitorUpdateId *NONNULL_PTR arg) {
28809         LDKMonitorUpdateId ret_var = MonitorUpdateId_clone(arg);
28810         int64_t ret_ref = 0;
28811         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28812         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28813         return ret_ref;
28814 }
28815 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorUpdateId_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
28816         LDKMonitorUpdateId arg_conv;
28817         arg_conv.inner = untag_ptr(arg);
28818         arg_conv.is_owned = ptr_is_owned(arg);
28819         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
28820         arg_conv.is_owned = false;
28821         int64_t ret_conv = MonitorUpdateId_clone_ptr(&arg_conv);
28822         return ret_conv;
28823 }
28824
28825 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorUpdateId_1clone(JNIEnv *env, jclass clz, int64_t orig) {
28826         LDKMonitorUpdateId orig_conv;
28827         orig_conv.inner = untag_ptr(orig);
28828         orig_conv.is_owned = ptr_is_owned(orig);
28829         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
28830         orig_conv.is_owned = false;
28831         LDKMonitorUpdateId ret_var = MonitorUpdateId_clone(&orig_conv);
28832         int64_t ret_ref = 0;
28833         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28834         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28835         return ret_ref;
28836 }
28837
28838 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorUpdateId_1hash(JNIEnv *env, jclass clz, int64_t o) {
28839         LDKMonitorUpdateId o_conv;
28840         o_conv.inner = untag_ptr(o);
28841         o_conv.is_owned = ptr_is_owned(o);
28842         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
28843         o_conv.is_owned = false;
28844         int64_t ret_conv = MonitorUpdateId_hash(&o_conv);
28845         return ret_conv;
28846 }
28847
28848 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_MonitorUpdateId_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
28849         LDKMonitorUpdateId a_conv;
28850         a_conv.inner = untag_ptr(a);
28851         a_conv.is_owned = ptr_is_owned(a);
28852         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
28853         a_conv.is_owned = false;
28854         LDKMonitorUpdateId b_conv;
28855         b_conv.inner = untag_ptr(b);
28856         b_conv.is_owned = ptr_is_owned(b);
28857         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
28858         b_conv.is_owned = false;
28859         jboolean ret_conv = MonitorUpdateId_eq(&a_conv, &b_conv);
28860         return ret_conv;
28861 }
28862
28863 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Persist_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
28864         if (!ptr_is_owned(this_ptr)) return;
28865         void* this_ptr_ptr = untag_ptr(this_ptr);
28866         CHECK_ACCESS(this_ptr_ptr);
28867         LDKPersist this_ptr_conv = *(LDKPersist*)(this_ptr_ptr);
28868         FREE(untag_ptr(this_ptr));
28869         Persist_free(this_ptr_conv);
28870 }
28871
28872 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LockedChannelMonitor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
28873         LDKLockedChannelMonitor this_obj_conv;
28874         this_obj_conv.inner = untag_ptr(this_obj);
28875         this_obj_conv.is_owned = ptr_is_owned(this_obj);
28876         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28877         LockedChannelMonitor_free(this_obj_conv);
28878 }
28879
28880 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
28881         LDKChainMonitor this_obj_conv;
28882         this_obj_conv.inner = untag_ptr(this_obj);
28883         this_obj_conv.is_owned = ptr_is_owned(this_obj);
28884         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28885         ChainMonitor_free(this_obj_conv);
28886 }
28887
28888 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) {
28889         void* chain_source_ptr = untag_ptr(chain_source);
28890         CHECK_ACCESS(chain_source_ptr);
28891         LDKCOption_FilterZ chain_source_conv = *(LDKCOption_FilterZ*)(chain_source_ptr);
28892         // WARNING: we may need a move here but no clone is available for LDKCOption_FilterZ
28893         if (chain_source_conv.tag == LDKCOption_FilterZ_Some) {
28894                 // Manually implement clone for Java trait instances
28895                 if (chain_source_conv.some.free == LDKFilter_JCalls_free) {
28896                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
28897                         LDKFilter_JCalls_cloned(&chain_source_conv.some);
28898                 }
28899         }
28900         void* broadcaster_ptr = untag_ptr(broadcaster);
28901         CHECK_ACCESS(broadcaster_ptr);
28902         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
28903         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
28904                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
28905                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
28906         }
28907         void* logger_ptr = untag_ptr(logger);
28908         CHECK_ACCESS(logger_ptr);
28909         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
28910         if (logger_conv.free == LDKLogger_JCalls_free) {
28911                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
28912                 LDKLogger_JCalls_cloned(&logger_conv);
28913         }
28914         void* feeest_ptr = untag_ptr(feeest);
28915         CHECK_ACCESS(feeest_ptr);
28916         LDKFeeEstimator feeest_conv = *(LDKFeeEstimator*)(feeest_ptr);
28917         if (feeest_conv.free == LDKFeeEstimator_JCalls_free) {
28918                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
28919                 LDKFeeEstimator_JCalls_cloned(&feeest_conv);
28920         }
28921         void* persister_ptr = untag_ptr(persister);
28922         CHECK_ACCESS(persister_ptr);
28923         LDKPersist persister_conv = *(LDKPersist*)(persister_ptr);
28924         if (persister_conv.free == LDKPersist_JCalls_free) {
28925                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
28926                 LDKPersist_JCalls_cloned(&persister_conv);
28927         }
28928         LDKChainMonitor ret_var = ChainMonitor_new(chain_source_conv, broadcaster_conv, logger_conv, feeest_conv, persister_conv);
28929         int64_t ret_ref = 0;
28930         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28931         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
28932         return ret_ref;
28933 }
28934
28935 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) {
28936         LDKChainMonitor this_arg_conv;
28937         this_arg_conv.inner = untag_ptr(this_arg);
28938         this_arg_conv.is_owned = ptr_is_owned(this_arg);
28939         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28940         this_arg_conv.is_owned = false;
28941         LDKCVec_ChannelDetailsZ ignored_channels_constr;
28942         ignored_channels_constr.datalen = (*env)->GetArrayLength(env, ignored_channels);
28943         if (ignored_channels_constr.datalen > 0)
28944                 ignored_channels_constr.data = MALLOC(ignored_channels_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
28945         else
28946                 ignored_channels_constr.data = NULL;
28947         int64_t* ignored_channels_vals = (*env)->GetLongArrayElements (env, ignored_channels, NULL);
28948         for (size_t q = 0; q < ignored_channels_constr.datalen; q++) {
28949                 int64_t ignored_channels_conv_16 = ignored_channels_vals[q];
28950                 LDKChannelDetails ignored_channels_conv_16_conv;
28951                 ignored_channels_conv_16_conv.inner = untag_ptr(ignored_channels_conv_16);
28952                 ignored_channels_conv_16_conv.is_owned = ptr_is_owned(ignored_channels_conv_16);
28953                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ignored_channels_conv_16_conv);
28954                 ignored_channels_conv_16_conv = ChannelDetails_clone(&ignored_channels_conv_16_conv);
28955                 ignored_channels_constr.data[q] = ignored_channels_conv_16_conv;
28956         }
28957         (*env)->ReleaseLongArrayElements(env, ignored_channels, ignored_channels_vals, 0);
28958         LDKCVec_BalanceZ ret_var = ChainMonitor_get_claimable_balances(&this_arg_conv, ignored_channels_constr);
28959         int64_tArray ret_arr = NULL;
28960         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
28961         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
28962         for (size_t j = 0; j < ret_var.datalen; j++) {
28963                 LDKBalance *ret_conv_9_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
28964                 *ret_conv_9_copy = ret_var.data[j];
28965                 int64_t ret_conv_9_ref = tag_ptr(ret_conv_9_copy, true);
28966                 ret_arr_ptr[j] = ret_conv_9_ref;
28967         }
28968         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
28969         FREE(ret_var.data);
28970         return ret_arr;
28971 }
28972
28973 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1get_1monitor(JNIEnv *env, jclass clz, int64_t this_arg, int64_t funding_txo) {
28974         LDKChainMonitor this_arg_conv;
28975         this_arg_conv.inner = untag_ptr(this_arg);
28976         this_arg_conv.is_owned = ptr_is_owned(this_arg);
28977         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28978         this_arg_conv.is_owned = false;
28979         LDKOutPoint funding_txo_conv;
28980         funding_txo_conv.inner = untag_ptr(funding_txo);
28981         funding_txo_conv.is_owned = ptr_is_owned(funding_txo);
28982         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
28983         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
28984         LDKCResult_LockedChannelMonitorNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_LockedChannelMonitorNoneZ), "LDKCResult_LockedChannelMonitorNoneZ");
28985         *ret_conv = ChainMonitor_get_monitor(&this_arg_conv, funding_txo_conv);
28986         return tag_ptr(ret_conv, true);
28987 }
28988
28989 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1list_1monitors(JNIEnv *env, jclass clz, int64_t this_arg) {
28990         LDKChainMonitor this_arg_conv;
28991         this_arg_conv.inner = untag_ptr(this_arg);
28992         this_arg_conv.is_owned = ptr_is_owned(this_arg);
28993         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
28994         this_arg_conv.is_owned = false;
28995         LDKCVec_OutPointZ ret_var = ChainMonitor_list_monitors(&this_arg_conv);
28996         int64_tArray ret_arr = NULL;
28997         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
28998         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
28999         for (size_t k = 0; k < ret_var.datalen; k++) {
29000                 LDKOutPoint ret_conv_10_var = ret_var.data[k];
29001                 int64_t ret_conv_10_ref = 0;
29002                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_10_var);
29003                 ret_conv_10_ref = tag_ptr(ret_conv_10_var.inner, ret_conv_10_var.is_owned);
29004                 ret_arr_ptr[k] = ret_conv_10_ref;
29005         }
29006         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
29007         FREE(ret_var.data);
29008         return ret_arr;
29009 }
29010
29011 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1list_1pending_1monitor_1updates(JNIEnv *env, jclass clz, int64_t this_arg) {
29012         LDKChainMonitor this_arg_conv;
29013         this_arg_conv.inner = untag_ptr(this_arg);
29014         this_arg_conv.is_owned = ptr_is_owned(this_arg);
29015         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29016         this_arg_conv.is_owned = false;
29017         LDKCVec_C2Tuple_OutPointCVec_MonitorUpdateIdZZZ ret_var = ChainMonitor_list_pending_monitor_updates(&this_arg_conv);
29018         int64_tArray ret_arr = NULL;
29019         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
29020         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
29021         for (size_t p = 0; p < ret_var.datalen; p++) {
29022                 LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ* ret_conv_41_conv = MALLOC(sizeof(LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ), "LDKC2Tuple_OutPointCVec_MonitorUpdateIdZZ");
29023                 *ret_conv_41_conv = ret_var.data[p];
29024                 ret_arr_ptr[p] = tag_ptr(ret_conv_41_conv, true);
29025         }
29026         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
29027         FREE(ret_var.data);
29028         return ret_arr;
29029 }
29030
29031 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) {
29032         LDKChainMonitor this_arg_conv;
29033         this_arg_conv.inner = untag_ptr(this_arg);
29034         this_arg_conv.is_owned = ptr_is_owned(this_arg);
29035         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29036         this_arg_conv.is_owned = false;
29037         LDKOutPoint funding_txo_conv;
29038         funding_txo_conv.inner = untag_ptr(funding_txo);
29039         funding_txo_conv.is_owned = ptr_is_owned(funding_txo);
29040         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
29041         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
29042         LDKMonitorUpdateId completed_update_id_conv;
29043         completed_update_id_conv.inner = untag_ptr(completed_update_id);
29044         completed_update_id_conv.is_owned = ptr_is_owned(completed_update_id);
29045         CHECK_INNER_FIELD_ACCESS_OR_NULL(completed_update_id_conv);
29046         completed_update_id_conv = MonitorUpdateId_clone(&completed_update_id_conv);
29047         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
29048         *ret_conv = ChainMonitor_channel_monitor_updated(&this_arg_conv, funding_txo_conv, completed_update_id_conv);
29049         return tag_ptr(ret_conv, true);
29050 }
29051
29052 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1as_1Listen(JNIEnv *env, jclass clz, int64_t this_arg) {
29053         LDKChainMonitor this_arg_conv;
29054         this_arg_conv.inner = untag_ptr(this_arg);
29055         this_arg_conv.is_owned = ptr_is_owned(this_arg);
29056         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29057         this_arg_conv.is_owned = false;
29058         LDKListen* ret_ret = MALLOC(sizeof(LDKListen), "LDKListen");
29059         *ret_ret = ChainMonitor_as_Listen(&this_arg_conv);
29060         return tag_ptr(ret_ret, true);
29061 }
29062
29063 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1as_1Confirm(JNIEnv *env, jclass clz, int64_t this_arg) {
29064         LDKChainMonitor this_arg_conv;
29065         this_arg_conv.inner = untag_ptr(this_arg);
29066         this_arg_conv.is_owned = ptr_is_owned(this_arg);
29067         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29068         this_arg_conv.is_owned = false;
29069         LDKConfirm* ret_ret = MALLOC(sizeof(LDKConfirm), "LDKConfirm");
29070         *ret_ret = ChainMonitor_as_Confirm(&this_arg_conv);
29071         return tag_ptr(ret_ret, true);
29072 }
29073
29074 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1as_1Watch(JNIEnv *env, jclass clz, int64_t this_arg) {
29075         LDKChainMonitor this_arg_conv;
29076         this_arg_conv.inner = untag_ptr(this_arg);
29077         this_arg_conv.is_owned = ptr_is_owned(this_arg);
29078         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29079         this_arg_conv.is_owned = false;
29080         LDKWatch* ret_ret = MALLOC(sizeof(LDKWatch), "LDKWatch");
29081         *ret_ret = ChainMonitor_as_Watch(&this_arg_conv);
29082         return tag_ptr(ret_ret, true);
29083 }
29084
29085 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1as_1EventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
29086         LDKChainMonitor this_arg_conv;
29087         this_arg_conv.inner = untag_ptr(this_arg);
29088         this_arg_conv.is_owned = ptr_is_owned(this_arg);
29089         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29090         this_arg_conv.is_owned = false;
29091         LDKEventsProvider* ret_ret = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
29092         *ret_ret = ChainMonitor_as_EventsProvider(&this_arg_conv);
29093         return tag_ptr(ret_ret, true);
29094 }
29095
29096 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
29097         LDKChannelMonitorUpdate this_obj_conv;
29098         this_obj_conv.inner = untag_ptr(this_obj);
29099         this_obj_conv.is_owned = ptr_is_owned(this_obj);
29100         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29101         ChannelMonitorUpdate_free(this_obj_conv);
29102 }
29103
29104 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1get_1update_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
29105         LDKChannelMonitorUpdate this_ptr_conv;
29106         this_ptr_conv.inner = untag_ptr(this_ptr);
29107         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
29108         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29109         this_ptr_conv.is_owned = false;
29110         int64_t ret_conv = ChannelMonitorUpdate_get_update_id(&this_ptr_conv);
29111         return ret_conv;
29112 }
29113
29114 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1set_1update_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
29115         LDKChannelMonitorUpdate this_ptr_conv;
29116         this_ptr_conv.inner = untag_ptr(this_ptr);
29117         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
29118         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29119         this_ptr_conv.is_owned = false;
29120         ChannelMonitorUpdate_set_update_id(&this_ptr_conv, val);
29121 }
29122
29123 static inline uint64_t ChannelMonitorUpdate_clone_ptr(LDKChannelMonitorUpdate *NONNULL_PTR arg) {
29124         LDKChannelMonitorUpdate ret_var = ChannelMonitorUpdate_clone(arg);
29125         int64_t ret_ref = 0;
29126         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29127         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
29128         return ret_ref;
29129 }
29130 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
29131         LDKChannelMonitorUpdate arg_conv;
29132         arg_conv.inner = untag_ptr(arg);
29133         arg_conv.is_owned = ptr_is_owned(arg);
29134         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29135         arg_conv.is_owned = false;
29136         int64_t ret_conv = ChannelMonitorUpdate_clone_ptr(&arg_conv);
29137         return ret_conv;
29138 }
29139
29140 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
29141         LDKChannelMonitorUpdate orig_conv;
29142         orig_conv.inner = untag_ptr(orig);
29143         orig_conv.is_owned = ptr_is_owned(orig);
29144         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29145         orig_conv.is_owned = false;
29146         LDKChannelMonitorUpdate ret_var = ChannelMonitorUpdate_clone(&orig_conv);
29147         int64_t ret_ref = 0;
29148         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29149         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
29150         return ret_ref;
29151 }
29152
29153 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) {
29154         LDKChannelMonitorUpdate obj_conv;
29155         obj_conv.inner = untag_ptr(obj);
29156         obj_conv.is_owned = ptr_is_owned(obj);
29157         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
29158         obj_conv.is_owned = false;
29159         LDKCVec_u8Z ret_var = ChannelMonitorUpdate_write(&obj_conv);
29160         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
29161         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
29162         CVec_u8Z_free(ret_var);
29163         return ret_arr;
29164 }
29165
29166 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
29167         LDKu8slice ser_ref;
29168         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
29169         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
29170         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
29171         *ret_conv = ChannelMonitorUpdate_read(ser_ref);
29172         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
29173         return tag_ptr(ret_conv, true);
29174 }
29175
29176 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
29177         if (!ptr_is_owned(this_ptr)) return;
29178         void* this_ptr_ptr = untag_ptr(this_ptr);
29179         CHECK_ACCESS(this_ptr_ptr);
29180         LDKMonitorEvent this_ptr_conv = *(LDKMonitorEvent*)(this_ptr_ptr);
29181         FREE(untag_ptr(this_ptr));
29182         MonitorEvent_free(this_ptr_conv);
29183 }
29184
29185 static inline uint64_t MonitorEvent_clone_ptr(LDKMonitorEvent *NONNULL_PTR arg) {
29186         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
29187         *ret_copy = MonitorEvent_clone(arg);
29188         int64_t ret_ref = tag_ptr(ret_copy, true);
29189         return ret_ref;
29190 }
29191 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
29192         LDKMonitorEvent* arg_conv = (LDKMonitorEvent*)untag_ptr(arg);
29193         int64_t ret_conv = MonitorEvent_clone_ptr(arg_conv);
29194         return ret_conv;
29195 }
29196
29197 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1clone(JNIEnv *env, jclass clz, int64_t orig) {
29198         LDKMonitorEvent* orig_conv = (LDKMonitorEvent*)untag_ptr(orig);
29199         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
29200         *ret_copy = MonitorEvent_clone(orig_conv);
29201         int64_t ret_ref = tag_ptr(ret_copy, true);
29202         return ret_ref;
29203 }
29204
29205 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1htlcevent(JNIEnv *env, jclass clz, int64_t a) {
29206         LDKHTLCUpdate a_conv;
29207         a_conv.inner = untag_ptr(a);
29208         a_conv.is_owned = ptr_is_owned(a);
29209         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
29210         a_conv = HTLCUpdate_clone(&a_conv);
29211         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
29212         *ret_copy = MonitorEvent_htlcevent(a_conv);
29213         int64_t ret_ref = tag_ptr(ret_copy, true);
29214         return ret_ref;
29215 }
29216
29217 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1commitment_1tx_1confirmed(JNIEnv *env, jclass clz, int64_t a) {
29218         LDKOutPoint a_conv;
29219         a_conv.inner = untag_ptr(a);
29220         a_conv.is_owned = ptr_is_owned(a);
29221         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
29222         a_conv = OutPoint_clone(&a_conv);
29223         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
29224         *ret_copy = MonitorEvent_commitment_tx_confirmed(a_conv);
29225         int64_t ret_ref = tag_ptr(ret_copy, true);
29226         return ret_ref;
29227 }
29228
29229 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1completed(JNIEnv *env, jclass clz, int64_t funding_txo, int64_t monitor_update_id) {
29230         LDKOutPoint funding_txo_conv;
29231         funding_txo_conv.inner = untag_ptr(funding_txo);
29232         funding_txo_conv.is_owned = ptr_is_owned(funding_txo);
29233         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
29234         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
29235         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
29236         *ret_copy = MonitorEvent_completed(funding_txo_conv, monitor_update_id);
29237         int64_t ret_ref = tag_ptr(ret_copy, true);
29238         return ret_ref;
29239 }
29240
29241 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1update_1failed(JNIEnv *env, jclass clz, int64_t a) {
29242         LDKOutPoint a_conv;
29243         a_conv.inner = untag_ptr(a);
29244         a_conv.is_owned = ptr_is_owned(a);
29245         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
29246         a_conv = OutPoint_clone(&a_conv);
29247         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
29248         *ret_copy = MonitorEvent_update_failed(a_conv);
29249         int64_t ret_ref = tag_ptr(ret_copy, true);
29250         return ret_ref;
29251 }
29252
29253 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
29254         LDKMonitorEvent* a_conv = (LDKMonitorEvent*)untag_ptr(a);
29255         LDKMonitorEvent* b_conv = (LDKMonitorEvent*)untag_ptr(b);
29256         jboolean ret_conv = MonitorEvent_eq(a_conv, b_conv);
29257         return ret_conv;
29258 }
29259
29260 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1write(JNIEnv *env, jclass clz, int64_t obj) {
29261         LDKMonitorEvent* obj_conv = (LDKMonitorEvent*)untag_ptr(obj);
29262         LDKCVec_u8Z ret_var = MonitorEvent_write(obj_conv);
29263         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
29264         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
29265         CVec_u8Z_free(ret_var);
29266         return ret_arr;
29267 }
29268
29269 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
29270         LDKu8slice ser_ref;
29271         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
29272         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
29273         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
29274         *ret_conv = MonitorEvent_read(ser_ref);
29275         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
29276         return tag_ptr(ret_conv, true);
29277 }
29278
29279 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
29280         LDKHTLCUpdate this_obj_conv;
29281         this_obj_conv.inner = untag_ptr(this_obj);
29282         this_obj_conv.is_owned = ptr_is_owned(this_obj);
29283         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29284         HTLCUpdate_free(this_obj_conv);
29285 }
29286
29287 static inline uint64_t HTLCUpdate_clone_ptr(LDKHTLCUpdate *NONNULL_PTR arg) {
29288         LDKHTLCUpdate ret_var = HTLCUpdate_clone(arg);
29289         int64_t ret_ref = 0;
29290         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29291         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
29292         return ret_ref;
29293 }
29294 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
29295         LDKHTLCUpdate arg_conv;
29296         arg_conv.inner = untag_ptr(arg);
29297         arg_conv.is_owned = ptr_is_owned(arg);
29298         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29299         arg_conv.is_owned = false;
29300         int64_t ret_conv = HTLCUpdate_clone_ptr(&arg_conv);
29301         return ret_conv;
29302 }
29303
29304 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
29305         LDKHTLCUpdate orig_conv;
29306         orig_conv.inner = untag_ptr(orig);
29307         orig_conv.is_owned = ptr_is_owned(orig);
29308         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29309         orig_conv.is_owned = false;
29310         LDKHTLCUpdate ret_var = HTLCUpdate_clone(&orig_conv);
29311         int64_t ret_ref = 0;
29312         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29313         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
29314         return ret_ref;
29315 }
29316
29317 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
29318         LDKHTLCUpdate a_conv;
29319         a_conv.inner = untag_ptr(a);
29320         a_conv.is_owned = ptr_is_owned(a);
29321         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
29322         a_conv.is_owned = false;
29323         LDKHTLCUpdate b_conv;
29324         b_conv.inner = untag_ptr(b);
29325         b_conv.is_owned = ptr_is_owned(b);
29326         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
29327         b_conv.is_owned = false;
29328         jboolean ret_conv = HTLCUpdate_eq(&a_conv, &b_conv);
29329         return ret_conv;
29330 }
29331
29332 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) {
29333         LDKHTLCUpdate obj_conv;
29334         obj_conv.inner = untag_ptr(obj);
29335         obj_conv.is_owned = ptr_is_owned(obj);
29336         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
29337         obj_conv.is_owned = false;
29338         LDKCVec_u8Z ret_var = HTLCUpdate_write(&obj_conv);
29339         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
29340         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
29341         CVec_u8Z_free(ret_var);
29342         return ret_arr;
29343 }
29344
29345 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
29346         LDKu8slice ser_ref;
29347         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
29348         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
29349         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
29350         *ret_conv = HTLCUpdate_read(ser_ref);
29351         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
29352         return tag_ptr(ret_conv, true);
29353 }
29354
29355 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Balance_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
29356         if (!ptr_is_owned(this_ptr)) return;
29357         void* this_ptr_ptr = untag_ptr(this_ptr);
29358         CHECK_ACCESS(this_ptr_ptr);
29359         LDKBalance this_ptr_conv = *(LDKBalance*)(this_ptr_ptr);
29360         FREE(untag_ptr(this_ptr));
29361         Balance_free(this_ptr_conv);
29362 }
29363
29364 static inline uint64_t Balance_clone_ptr(LDKBalance *NONNULL_PTR arg) {
29365         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
29366         *ret_copy = Balance_clone(arg);
29367         int64_t ret_ref = tag_ptr(ret_copy, true);
29368         return ret_ref;
29369 }
29370 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Balance_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
29371         LDKBalance* arg_conv = (LDKBalance*)untag_ptr(arg);
29372         int64_t ret_conv = Balance_clone_ptr(arg_conv);
29373         return ret_conv;
29374 }
29375
29376 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Balance_1clone(JNIEnv *env, jclass clz, int64_t orig) {
29377         LDKBalance* orig_conv = (LDKBalance*)untag_ptr(orig);
29378         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
29379         *ret_copy = Balance_clone(orig_conv);
29380         int64_t ret_ref = tag_ptr(ret_copy, true);
29381         return ret_ref;
29382 }
29383
29384 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Balance_1claimable_1on_1channel_1close(JNIEnv *env, jclass clz, int64_t claimable_amount_satoshis) {
29385         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
29386         *ret_copy = Balance_claimable_on_channel_close(claimable_amount_satoshis);
29387         int64_t ret_ref = tag_ptr(ret_copy, true);
29388         return ret_ref;
29389 }
29390
29391 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) {
29392         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
29393         *ret_copy = Balance_claimable_awaiting_confirmations(claimable_amount_satoshis, confirmation_height);
29394         int64_t ret_ref = tag_ptr(ret_copy, true);
29395         return ret_ref;
29396 }
29397
29398 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) {
29399         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
29400         *ret_copy = Balance_contentious_claimable(claimable_amount_satoshis, timeout_height);
29401         int64_t ret_ref = tag_ptr(ret_copy, true);
29402         return ret_ref;
29403 }
29404
29405 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) {
29406         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
29407         *ret_copy = Balance_maybe_timeout_claimable_htlc(claimable_amount_satoshis, claimable_height);
29408         int64_t ret_ref = tag_ptr(ret_copy, true);
29409         return ret_ref;
29410 }
29411
29412 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) {
29413         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
29414         *ret_copy = Balance_maybe_preimage_claimable_htlc(claimable_amount_satoshis, expiry_height);
29415         int64_t ret_ref = tag_ptr(ret_copy, true);
29416         return ret_ref;
29417 }
29418
29419 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Balance_1counterparty_1revoked_1output_1claimable(JNIEnv *env, jclass clz, int64_t claimable_amount_satoshis) {
29420         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
29421         *ret_copy = Balance_counterparty_revoked_output_claimable(claimable_amount_satoshis);
29422         int64_t ret_ref = tag_ptr(ret_copy, true);
29423         return ret_ref;
29424 }
29425
29426 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Balance_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
29427         LDKBalance* a_conv = (LDKBalance*)untag_ptr(a);
29428         LDKBalance* b_conv = (LDKBalance*)untag_ptr(b);
29429         jboolean ret_conv = Balance_eq(a_conv, b_conv);
29430         return ret_conv;
29431 }
29432
29433 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
29434         LDKChannelMonitor this_obj_conv;
29435         this_obj_conv.inner = untag_ptr(this_obj);
29436         this_obj_conv.is_owned = ptr_is_owned(this_obj);
29437         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29438         ChannelMonitor_free(this_obj_conv);
29439 }
29440
29441 static inline uint64_t ChannelMonitor_clone_ptr(LDKChannelMonitor *NONNULL_PTR arg) {
29442         LDKChannelMonitor ret_var = ChannelMonitor_clone(arg);
29443         int64_t ret_ref = 0;
29444         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29445         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
29446         return ret_ref;
29447 }
29448 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
29449         LDKChannelMonitor arg_conv;
29450         arg_conv.inner = untag_ptr(arg);
29451         arg_conv.is_owned = ptr_is_owned(arg);
29452         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29453         arg_conv.is_owned = false;
29454         int64_t ret_conv = ChannelMonitor_clone_ptr(&arg_conv);
29455         return ret_conv;
29456 }
29457
29458 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
29459         LDKChannelMonitor orig_conv;
29460         orig_conv.inner = untag_ptr(orig);
29461         orig_conv.is_owned = ptr_is_owned(orig);
29462         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29463         orig_conv.is_owned = false;
29464         LDKChannelMonitor ret_var = ChannelMonitor_clone(&orig_conv);
29465         int64_t ret_ref = 0;
29466         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29467         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
29468         return ret_ref;
29469 }
29470
29471 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1write(JNIEnv *env, jclass clz, int64_t obj) {
29472         LDKChannelMonitor obj_conv;
29473         obj_conv.inner = untag_ptr(obj);
29474         obj_conv.is_owned = ptr_is_owned(obj);
29475         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
29476         obj_conv.is_owned = false;
29477         LDKCVec_u8Z ret_var = ChannelMonitor_write(&obj_conv);
29478         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
29479         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
29480         CVec_u8Z_free(ret_var);
29481         return ret_arr;
29482 }
29483
29484 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) {
29485         LDKChannelMonitor this_arg_conv;
29486         this_arg_conv.inner = untag_ptr(this_arg);
29487         this_arg_conv.is_owned = ptr_is_owned(this_arg);
29488         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29489         this_arg_conv.is_owned = false;
29490         LDKChannelMonitorUpdate updates_conv;
29491         updates_conv.inner = untag_ptr(updates);
29492         updates_conv.is_owned = ptr_is_owned(updates);
29493         CHECK_INNER_FIELD_ACCESS_OR_NULL(updates_conv);
29494         updates_conv.is_owned = false;
29495         void* broadcaster_ptr = untag_ptr(broadcaster);
29496         if (ptr_is_owned(broadcaster)) { CHECK_ACCESS(broadcaster_ptr); }
29497         LDKBroadcasterInterface* broadcaster_conv = (LDKBroadcasterInterface*)broadcaster_ptr;
29498         void* fee_estimator_ptr = untag_ptr(fee_estimator);
29499         CHECK_ACCESS(fee_estimator_ptr);
29500         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
29501         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
29502                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
29503                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
29504         }
29505         void* logger_ptr = untag_ptr(logger);
29506         if (ptr_is_owned(logger)) { CHECK_ACCESS(logger_ptr); }
29507         LDKLogger* logger_conv = (LDKLogger*)logger_ptr;
29508         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
29509         *ret_conv = ChannelMonitor_update_monitor(&this_arg_conv, &updates_conv, broadcaster_conv, fee_estimator_conv, logger_conv);
29510         return tag_ptr(ret_conv, true);
29511 }
29512
29513 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1latest_1update_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
29514         LDKChannelMonitor this_arg_conv;
29515         this_arg_conv.inner = untag_ptr(this_arg);
29516         this_arg_conv.is_owned = ptr_is_owned(this_arg);
29517         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29518         this_arg_conv.is_owned = false;
29519         int64_t ret_conv = ChannelMonitor_get_latest_update_id(&this_arg_conv);
29520         return ret_conv;
29521 }
29522
29523 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1funding_1txo(JNIEnv *env, jclass clz, int64_t this_arg) {
29524         LDKChannelMonitor this_arg_conv;
29525         this_arg_conv.inner = untag_ptr(this_arg);
29526         this_arg_conv.is_owned = ptr_is_owned(this_arg);
29527         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29528         this_arg_conv.is_owned = false;
29529         LDKC2Tuple_OutPointScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
29530         *ret_conv = ChannelMonitor_get_funding_txo(&this_arg_conv);
29531         return tag_ptr(ret_conv, true);
29532 }
29533
29534 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1outputs_1to_1watch(JNIEnv *env, jclass clz, int64_t this_arg) {
29535         LDKChannelMonitor this_arg_conv;
29536         this_arg_conv.inner = untag_ptr(this_arg);
29537         this_arg_conv.is_owned = ptr_is_owned(this_arg);
29538         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29539         this_arg_conv.is_owned = false;
29540         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ ret_var = ChannelMonitor_get_outputs_to_watch(&this_arg_conv);
29541         int64_tArray ret_arr = NULL;
29542         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
29543         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
29544         for (size_t o = 0; o < ret_var.datalen; o++) {
29545                 LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_conv_40_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
29546                 *ret_conv_40_conv = ret_var.data[o];
29547                 ret_arr_ptr[o] = tag_ptr(ret_conv_40_conv, true);
29548         }
29549         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
29550         FREE(ret_var.data);
29551         return ret_arr;
29552 }
29553
29554 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1load_1outputs_1to_1watch(JNIEnv *env, jclass clz, int64_t this_arg, int64_t filter) {
29555         LDKChannelMonitor this_arg_conv;
29556         this_arg_conv.inner = untag_ptr(this_arg);
29557         this_arg_conv.is_owned = ptr_is_owned(this_arg);
29558         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29559         this_arg_conv.is_owned = false;
29560         void* filter_ptr = untag_ptr(filter);
29561         if (ptr_is_owned(filter)) { CHECK_ACCESS(filter_ptr); }
29562         LDKFilter* filter_conv = (LDKFilter*)filter_ptr;
29563         ChannelMonitor_load_outputs_to_watch(&this_arg_conv, filter_conv);
29564 }
29565
29566 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1and_1clear_1pending_1monitor_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
29567         LDKChannelMonitor this_arg_conv;
29568         this_arg_conv.inner = untag_ptr(this_arg);
29569         this_arg_conv.is_owned = ptr_is_owned(this_arg);
29570         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29571         this_arg_conv.is_owned = false;
29572         LDKCVec_MonitorEventZ ret_var = ChannelMonitor_get_and_clear_pending_monitor_events(&this_arg_conv);
29573         int64_tArray ret_arr = NULL;
29574         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
29575         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
29576         for (size_t o = 0; o < ret_var.datalen; o++) {
29577                 LDKMonitorEvent *ret_conv_14_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
29578                 *ret_conv_14_copy = ret_var.data[o];
29579                 int64_t ret_conv_14_ref = tag_ptr(ret_conv_14_copy, true);
29580                 ret_arr_ptr[o] = ret_conv_14_ref;
29581         }
29582         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
29583         FREE(ret_var.data);
29584         return ret_arr;
29585 }
29586
29587 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1and_1clear_1pending_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
29588         LDKChannelMonitor this_arg_conv;
29589         this_arg_conv.inner = untag_ptr(this_arg);
29590         this_arg_conv.is_owned = ptr_is_owned(this_arg);
29591         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29592         this_arg_conv.is_owned = false;
29593         LDKCVec_EventZ ret_var = ChannelMonitor_get_and_clear_pending_events(&this_arg_conv);
29594         int64_tArray ret_arr = NULL;
29595         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
29596         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
29597         for (size_t h = 0; h < ret_var.datalen; h++) {
29598                 LDKEvent *ret_conv_7_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
29599                 *ret_conv_7_copy = ret_var.data[h];
29600                 int64_t ret_conv_7_ref = tag_ptr(ret_conv_7_copy, true);
29601                 ret_arr_ptr[h] = ret_conv_7_ref;
29602         }
29603         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
29604         FREE(ret_var.data);
29605         return ret_arr;
29606 }
29607
29608 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1counterparty_1node_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
29609         LDKChannelMonitor this_arg_conv;
29610         this_arg_conv.inner = untag_ptr(this_arg);
29611         this_arg_conv.is_owned = ptr_is_owned(this_arg);
29612         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29613         this_arg_conv.is_owned = false;
29614         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
29615         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelMonitor_get_counterparty_node_id(&this_arg_conv).compressed_form);
29616         return ret_arr;
29617 }
29618
29619 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) {
29620         LDKChannelMonitor this_arg_conv;
29621         this_arg_conv.inner = untag_ptr(this_arg);
29622         this_arg_conv.is_owned = ptr_is_owned(this_arg);
29623         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29624         this_arg_conv.is_owned = false;
29625         void* logger_ptr = untag_ptr(logger);
29626         if (ptr_is_owned(logger)) { CHECK_ACCESS(logger_ptr); }
29627         LDKLogger* logger_conv = (LDKLogger*)logger_ptr;
29628         LDKCVec_TransactionZ ret_var = ChannelMonitor_get_latest_holder_commitment_txn(&this_arg_conv, logger_conv);
29629         jobjectArray ret_arr = NULL;
29630         ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
29631         ;
29632         for (size_t i = 0; i < ret_var.datalen; i++) {
29633                 LDKTransaction ret_conv_8_var = ret_var.data[i];
29634                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, ret_conv_8_var.datalen);
29635                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, ret_conv_8_var.datalen, ret_conv_8_var.data);
29636                 Transaction_free(ret_conv_8_var);
29637                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
29638         }
29639         
29640         FREE(ret_var.data);
29641         return ret_arr;
29642 }
29643
29644 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) {
29645         LDKChannelMonitor this_arg_conv;
29646         this_arg_conv.inner = untag_ptr(this_arg);
29647         this_arg_conv.is_owned = ptr_is_owned(this_arg);
29648         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29649         this_arg_conv.is_owned = false;
29650         unsigned char header_arr[80];
29651         CHECK((*env)->GetArrayLength(env, header) == 80);
29652         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
29653         unsigned char (*header_ref)[80] = &header_arr;
29654         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
29655         txdata_constr.datalen = (*env)->GetArrayLength(env, txdata);
29656         if (txdata_constr.datalen > 0)
29657                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
29658         else
29659                 txdata_constr.data = NULL;
29660         int64_t* txdata_vals = (*env)->GetLongArrayElements (env, txdata, NULL);
29661         for (size_t c = 0; c < txdata_constr.datalen; c++) {
29662                 int64_t txdata_conv_28 = txdata_vals[c];
29663                 void* txdata_conv_28_ptr = untag_ptr(txdata_conv_28);
29664                 CHECK_ACCESS(txdata_conv_28_ptr);
29665                 LDKC2Tuple_usizeTransactionZ txdata_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(txdata_conv_28_ptr);
29666                 txdata_conv_28_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)untag_ptr(txdata_conv_28));
29667                 txdata_constr.data[c] = txdata_conv_28_conv;
29668         }
29669         (*env)->ReleaseLongArrayElements(env, txdata, txdata_vals, 0);
29670         void* broadcaster_ptr = untag_ptr(broadcaster);
29671         CHECK_ACCESS(broadcaster_ptr);
29672         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
29673         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
29674                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
29675                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
29676         }
29677         void* fee_estimator_ptr = untag_ptr(fee_estimator);
29678         CHECK_ACCESS(fee_estimator_ptr);
29679         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
29680         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
29681                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
29682                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
29683         }
29684         void* logger_ptr = untag_ptr(logger);
29685         CHECK_ACCESS(logger_ptr);
29686         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
29687         if (logger_conv.free == LDKLogger_JCalls_free) {
29688                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
29689                 LDKLogger_JCalls_cloned(&logger_conv);
29690         }
29691         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);
29692         int64_tArray ret_arr = NULL;
29693         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
29694         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
29695         for (size_t n = 0; n < ret_var.datalen; n++) {
29696                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_39_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
29697                 *ret_conv_39_conv = ret_var.data[n];
29698                 ret_arr_ptr[n] = tag_ptr(ret_conv_39_conv, true);
29699         }
29700         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
29701         FREE(ret_var.data);
29702         return ret_arr;
29703 }
29704
29705 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) {
29706         LDKChannelMonitor this_arg_conv;
29707         this_arg_conv.inner = untag_ptr(this_arg);
29708         this_arg_conv.is_owned = ptr_is_owned(this_arg);
29709         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29710         this_arg_conv.is_owned = false;
29711         unsigned char header_arr[80];
29712         CHECK((*env)->GetArrayLength(env, header) == 80);
29713         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
29714         unsigned char (*header_ref)[80] = &header_arr;
29715         void* broadcaster_ptr = untag_ptr(broadcaster);
29716         CHECK_ACCESS(broadcaster_ptr);
29717         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
29718         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
29719                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
29720                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
29721         }
29722         void* fee_estimator_ptr = untag_ptr(fee_estimator);
29723         CHECK_ACCESS(fee_estimator_ptr);
29724         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
29725         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
29726                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
29727                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
29728         }
29729         void* logger_ptr = untag_ptr(logger);
29730         CHECK_ACCESS(logger_ptr);
29731         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
29732         if (logger_conv.free == LDKLogger_JCalls_free) {
29733                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
29734                 LDKLogger_JCalls_cloned(&logger_conv);
29735         }
29736         ChannelMonitor_block_disconnected(&this_arg_conv, header_ref, height, broadcaster_conv, fee_estimator_conv, logger_conv);
29737 }
29738
29739 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) {
29740         LDKChannelMonitor this_arg_conv;
29741         this_arg_conv.inner = untag_ptr(this_arg);
29742         this_arg_conv.is_owned = ptr_is_owned(this_arg);
29743         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29744         this_arg_conv.is_owned = false;
29745         unsigned char header_arr[80];
29746         CHECK((*env)->GetArrayLength(env, header) == 80);
29747         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
29748         unsigned char (*header_ref)[80] = &header_arr;
29749         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
29750         txdata_constr.datalen = (*env)->GetArrayLength(env, txdata);
29751         if (txdata_constr.datalen > 0)
29752                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
29753         else
29754                 txdata_constr.data = NULL;
29755         int64_t* txdata_vals = (*env)->GetLongArrayElements (env, txdata, NULL);
29756         for (size_t c = 0; c < txdata_constr.datalen; c++) {
29757                 int64_t txdata_conv_28 = txdata_vals[c];
29758                 void* txdata_conv_28_ptr = untag_ptr(txdata_conv_28);
29759                 CHECK_ACCESS(txdata_conv_28_ptr);
29760                 LDKC2Tuple_usizeTransactionZ txdata_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(txdata_conv_28_ptr);
29761                 txdata_conv_28_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)untag_ptr(txdata_conv_28));
29762                 txdata_constr.data[c] = txdata_conv_28_conv;
29763         }
29764         (*env)->ReleaseLongArrayElements(env, txdata, txdata_vals, 0);
29765         void* broadcaster_ptr = untag_ptr(broadcaster);
29766         CHECK_ACCESS(broadcaster_ptr);
29767         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
29768         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
29769                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
29770                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
29771         }
29772         void* fee_estimator_ptr = untag_ptr(fee_estimator);
29773         CHECK_ACCESS(fee_estimator_ptr);
29774         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
29775         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
29776                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
29777                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
29778         }
29779         void* logger_ptr = untag_ptr(logger);
29780         CHECK_ACCESS(logger_ptr);
29781         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
29782         if (logger_conv.free == LDKLogger_JCalls_free) {
29783                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
29784                 LDKLogger_JCalls_cloned(&logger_conv);
29785         }
29786         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);
29787         int64_tArray ret_arr = NULL;
29788         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
29789         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
29790         for (size_t n = 0; n < ret_var.datalen; n++) {
29791                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_39_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
29792                 *ret_conv_39_conv = ret_var.data[n];
29793                 ret_arr_ptr[n] = tag_ptr(ret_conv_39_conv, true);
29794         }
29795         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
29796         FREE(ret_var.data);
29797         return ret_arr;
29798 }
29799
29800 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) {
29801         LDKChannelMonitor this_arg_conv;
29802         this_arg_conv.inner = untag_ptr(this_arg);
29803         this_arg_conv.is_owned = ptr_is_owned(this_arg);
29804         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29805         this_arg_conv.is_owned = false;
29806         unsigned char txid_arr[32];
29807         CHECK((*env)->GetArrayLength(env, txid) == 32);
29808         (*env)->GetByteArrayRegion(env, txid, 0, 32, txid_arr);
29809         unsigned char (*txid_ref)[32] = &txid_arr;
29810         void* broadcaster_ptr = untag_ptr(broadcaster);
29811         CHECK_ACCESS(broadcaster_ptr);
29812         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
29813         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
29814                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
29815                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
29816         }
29817         void* fee_estimator_ptr = untag_ptr(fee_estimator);
29818         CHECK_ACCESS(fee_estimator_ptr);
29819         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
29820         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
29821                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
29822                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
29823         }
29824         void* logger_ptr = untag_ptr(logger);
29825         CHECK_ACCESS(logger_ptr);
29826         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
29827         if (logger_conv.free == LDKLogger_JCalls_free) {
29828                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
29829                 LDKLogger_JCalls_cloned(&logger_conv);
29830         }
29831         ChannelMonitor_transaction_unconfirmed(&this_arg_conv, txid_ref, broadcaster_conv, fee_estimator_conv, logger_conv);
29832 }
29833
29834 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) {
29835         LDKChannelMonitor this_arg_conv;
29836         this_arg_conv.inner = untag_ptr(this_arg);
29837         this_arg_conv.is_owned = ptr_is_owned(this_arg);
29838         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29839         this_arg_conv.is_owned = false;
29840         unsigned char header_arr[80];
29841         CHECK((*env)->GetArrayLength(env, header) == 80);
29842         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
29843         unsigned char (*header_ref)[80] = &header_arr;
29844         void* broadcaster_ptr = untag_ptr(broadcaster);
29845         CHECK_ACCESS(broadcaster_ptr);
29846         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
29847         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
29848                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
29849                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
29850         }
29851         void* fee_estimator_ptr = untag_ptr(fee_estimator);
29852         CHECK_ACCESS(fee_estimator_ptr);
29853         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
29854         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
29855                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
29856                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
29857         }
29858         void* logger_ptr = untag_ptr(logger);
29859         CHECK_ACCESS(logger_ptr);
29860         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
29861         if (logger_conv.free == LDKLogger_JCalls_free) {
29862                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
29863                 LDKLogger_JCalls_cloned(&logger_conv);
29864         }
29865         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ ret_var = ChannelMonitor_best_block_updated(&this_arg_conv, header_ref, height, broadcaster_conv, fee_estimator_conv, logger_conv);
29866         int64_tArray ret_arr = NULL;
29867         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
29868         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
29869         for (size_t n = 0; n < ret_var.datalen; n++) {
29870                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_39_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
29871                 *ret_conv_39_conv = ret_var.data[n];
29872                 ret_arr_ptr[n] = tag_ptr(ret_conv_39_conv, true);
29873         }
29874         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
29875         FREE(ret_var.data);
29876         return ret_arr;
29877 }
29878
29879 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1relevant_1txids(JNIEnv *env, jclass clz, int64_t this_arg) {
29880         LDKChannelMonitor this_arg_conv;
29881         this_arg_conv.inner = untag_ptr(this_arg);
29882         this_arg_conv.is_owned = ptr_is_owned(this_arg);
29883         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29884         this_arg_conv.is_owned = false;
29885         LDKCVec_C2Tuple_TxidBlockHashZZ ret_var = ChannelMonitor_get_relevant_txids(&this_arg_conv);
29886         int64_tArray ret_arr = NULL;
29887         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
29888         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
29889         for (size_t z = 0; z < ret_var.datalen; z++) {
29890                 LDKC2Tuple_TxidBlockHashZ* ret_conv_25_conv = MALLOC(sizeof(LDKC2Tuple_TxidBlockHashZ), "LDKC2Tuple_TxidBlockHashZ");
29891                 *ret_conv_25_conv = ret_var.data[z];
29892                 ret_arr_ptr[z] = tag_ptr(ret_conv_25_conv, true);
29893         }
29894         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
29895         FREE(ret_var.data);
29896         return ret_arr;
29897 }
29898
29899 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1current_1best_1block(JNIEnv *env, jclass clz, int64_t this_arg) {
29900         LDKChannelMonitor this_arg_conv;
29901         this_arg_conv.inner = untag_ptr(this_arg);
29902         this_arg_conv.is_owned = ptr_is_owned(this_arg);
29903         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29904         this_arg_conv.is_owned = false;
29905         LDKBestBlock ret_var = ChannelMonitor_current_best_block(&this_arg_conv);
29906         int64_t ret_ref = 0;
29907         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29908         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
29909         return ret_ref;
29910 }
29911
29912 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1claimable_1balances(JNIEnv *env, jclass clz, int64_t this_arg) {
29913         LDKChannelMonitor this_arg_conv;
29914         this_arg_conv.inner = untag_ptr(this_arg);
29915         this_arg_conv.is_owned = ptr_is_owned(this_arg);
29916         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
29917         this_arg_conv.is_owned = false;
29918         LDKCVec_BalanceZ ret_var = ChannelMonitor_get_claimable_balances(&this_arg_conv);
29919         int64_tArray ret_arr = NULL;
29920         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
29921         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
29922         for (size_t j = 0; j < ret_var.datalen; j++) {
29923                 LDKBalance *ret_conv_9_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
29924                 *ret_conv_9_copy = ret_var.data[j];
29925                 int64_t ret_conv_9_ref = tag_ptr(ret_conv_9_copy, true);
29926                 ret_arr_ptr[j] = ret_conv_9_ref;
29927         }
29928         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
29929         FREE(ret_var.data);
29930         return ret_arr;
29931 }
29932
29933 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1read(JNIEnv *env, jclass clz, int8_tArray ser, int64_t arg) {
29934         LDKu8slice ser_ref;
29935         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
29936         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
29937         void* arg_ptr = untag_ptr(arg);
29938         if (ptr_is_owned(arg)) { CHECK_ACCESS(arg_ptr); }
29939         LDKKeysInterface* arg_conv = (LDKKeysInterface*)arg_ptr;
29940         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
29941         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_read(ser_ref, arg_conv);
29942         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
29943         return tag_ptr(ret_conv, true);
29944 }
29945
29946 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OutPoint_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
29947         LDKOutPoint this_obj_conv;
29948         this_obj_conv.inner = untag_ptr(this_obj);
29949         this_obj_conv.is_owned = ptr_is_owned(this_obj);
29950         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29951         OutPoint_free(this_obj_conv);
29952 }
29953
29954 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OutPoint_1get_1txid(JNIEnv *env, jclass clz, int64_t this_ptr) {
29955         LDKOutPoint this_ptr_conv;
29956         this_ptr_conv.inner = untag_ptr(this_ptr);
29957         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
29958         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29959         this_ptr_conv.is_owned = false;
29960         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
29961         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *OutPoint_get_txid(&this_ptr_conv));
29962         return ret_arr;
29963 }
29964
29965 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OutPoint_1set_1txid(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
29966         LDKOutPoint this_ptr_conv;
29967         this_ptr_conv.inner = untag_ptr(this_ptr);
29968         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
29969         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29970         this_ptr_conv.is_owned = false;
29971         LDKThirtyTwoBytes val_ref;
29972         CHECK((*env)->GetArrayLength(env, val) == 32);
29973         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
29974         OutPoint_set_txid(&this_ptr_conv, val_ref);
29975 }
29976
29977 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1get_1index(JNIEnv *env, jclass clz, int64_t this_ptr) {
29978         LDKOutPoint this_ptr_conv;
29979         this_ptr_conv.inner = untag_ptr(this_ptr);
29980         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
29981         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29982         this_ptr_conv.is_owned = false;
29983         int16_t ret_conv = OutPoint_get_index(&this_ptr_conv);
29984         return ret_conv;
29985 }
29986
29987 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OutPoint_1set_1index(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
29988         LDKOutPoint this_ptr_conv;
29989         this_ptr_conv.inner = untag_ptr(this_ptr);
29990         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
29991         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29992         this_ptr_conv.is_owned = false;
29993         OutPoint_set_index(&this_ptr_conv, val);
29994 }
29995
29996 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1new(JNIEnv *env, jclass clz, int8_tArray txid_arg, int16_t index_arg) {
29997         LDKThirtyTwoBytes txid_arg_ref;
29998         CHECK((*env)->GetArrayLength(env, txid_arg) == 32);
29999         (*env)->GetByteArrayRegion(env, txid_arg, 0, 32, txid_arg_ref.data);
30000         LDKOutPoint ret_var = OutPoint_new(txid_arg_ref, index_arg);
30001         int64_t ret_ref = 0;
30002         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30003         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30004         return ret_ref;
30005 }
30006
30007 static inline uint64_t OutPoint_clone_ptr(LDKOutPoint *NONNULL_PTR arg) {
30008         LDKOutPoint ret_var = OutPoint_clone(arg);
30009         int64_t ret_ref = 0;
30010         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30011         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30012         return ret_ref;
30013 }
30014 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
30015         LDKOutPoint arg_conv;
30016         arg_conv.inner = untag_ptr(arg);
30017         arg_conv.is_owned = ptr_is_owned(arg);
30018         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30019         arg_conv.is_owned = false;
30020         int64_t ret_conv = OutPoint_clone_ptr(&arg_conv);
30021         return ret_conv;
30022 }
30023
30024 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1clone(JNIEnv *env, jclass clz, int64_t orig) {
30025         LDKOutPoint orig_conv;
30026         orig_conv.inner = untag_ptr(orig);
30027         orig_conv.is_owned = ptr_is_owned(orig);
30028         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30029         orig_conv.is_owned = false;
30030         LDKOutPoint ret_var = OutPoint_clone(&orig_conv);
30031         int64_t ret_ref = 0;
30032         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30033         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30034         return ret_ref;
30035 }
30036
30037 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_OutPoint_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
30038         LDKOutPoint a_conv;
30039         a_conv.inner = untag_ptr(a);
30040         a_conv.is_owned = ptr_is_owned(a);
30041         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
30042         a_conv.is_owned = false;
30043         LDKOutPoint b_conv;
30044         b_conv.inner = untag_ptr(b);
30045         b_conv.is_owned = ptr_is_owned(b);
30046         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
30047         b_conv.is_owned = false;
30048         jboolean ret_conv = OutPoint_eq(&a_conv, &b_conv);
30049         return ret_conv;
30050 }
30051
30052 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1hash(JNIEnv *env, jclass clz, int64_t o) {
30053         LDKOutPoint o_conv;
30054         o_conv.inner = untag_ptr(o);
30055         o_conv.is_owned = ptr_is_owned(o);
30056         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
30057         o_conv.is_owned = false;
30058         int64_t ret_conv = OutPoint_hash(&o_conv);
30059         return ret_conv;
30060 }
30061
30062 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OutPoint_1to_1channel_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
30063         LDKOutPoint this_arg_conv;
30064         this_arg_conv.inner = untag_ptr(this_arg);
30065         this_arg_conv.is_owned = ptr_is_owned(this_arg);
30066         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30067         this_arg_conv.is_owned = false;
30068         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
30069         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, OutPoint_to_channel_id(&this_arg_conv).data);
30070         return ret_arr;
30071 }
30072
30073 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OutPoint_1write(JNIEnv *env, jclass clz, int64_t obj) {
30074         LDKOutPoint obj_conv;
30075         obj_conv.inner = untag_ptr(obj);
30076         obj_conv.is_owned = ptr_is_owned(obj);
30077         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
30078         obj_conv.is_owned = false;
30079         LDKCVec_u8Z ret_var = OutPoint_write(&obj_conv);
30080         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
30081         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
30082         CVec_u8Z_free(ret_var);
30083         return ret_arr;
30084 }
30085
30086 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
30087         LDKu8slice ser_ref;
30088         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
30089         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
30090         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
30091         *ret_conv = OutPoint_read(ser_ref);
30092         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
30093         return tag_ptr(ret_conv, true);
30094 }
30095
30096 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
30097         LDKDelayedPaymentOutputDescriptor this_obj_conv;
30098         this_obj_conv.inner = untag_ptr(this_obj);
30099         this_obj_conv.is_owned = ptr_is_owned(this_obj);
30100         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30101         DelayedPaymentOutputDescriptor_free(this_obj_conv);
30102 }
30103
30104 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
30105         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
30106         this_ptr_conv.inner = untag_ptr(this_ptr);
30107         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30108         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30109         this_ptr_conv.is_owned = false;
30110         LDKOutPoint ret_var = DelayedPaymentOutputDescriptor_get_outpoint(&this_ptr_conv);
30111         int64_t ret_ref = 0;
30112         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30113         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30114         return ret_ref;
30115 }
30116
30117 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30118         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
30119         this_ptr_conv.inner = untag_ptr(this_ptr);
30120         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30121         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30122         this_ptr_conv.is_owned = false;
30123         LDKOutPoint val_conv;
30124         val_conv.inner = untag_ptr(val);
30125         val_conv.is_owned = ptr_is_owned(val);
30126         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
30127         val_conv = OutPoint_clone(&val_conv);
30128         DelayedPaymentOutputDescriptor_set_outpoint(&this_ptr_conv, val_conv);
30129 }
30130
30131 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
30132         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
30133         this_ptr_conv.inner = untag_ptr(this_ptr);
30134         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30135         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30136         this_ptr_conv.is_owned = false;
30137         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
30138         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, DelayedPaymentOutputDescriptor_get_per_commitment_point(&this_ptr_conv).compressed_form);
30139         return ret_arr;
30140 }
30141
30142 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
30143         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
30144         this_ptr_conv.inner = untag_ptr(this_ptr);
30145         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30146         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30147         this_ptr_conv.is_owned = false;
30148         LDKPublicKey val_ref;
30149         CHECK((*env)->GetArrayLength(env, val) == 33);
30150         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
30151         DelayedPaymentOutputDescriptor_set_per_commitment_point(&this_ptr_conv, val_ref);
30152 }
30153
30154 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
30155         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
30156         this_ptr_conv.inner = untag_ptr(this_ptr);
30157         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30158         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30159         this_ptr_conv.is_owned = false;
30160         int16_t ret_conv = DelayedPaymentOutputDescriptor_get_to_self_delay(&this_ptr_conv);
30161         return ret_conv;
30162 }
30163
30164 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
30165         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
30166         this_ptr_conv.inner = untag_ptr(this_ptr);
30167         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30168         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30169         this_ptr_conv.is_owned = false;
30170         DelayedPaymentOutputDescriptor_set_to_self_delay(&this_ptr_conv, val);
30171 }
30172
30173 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1output(JNIEnv *env, jclass clz, int64_t this_ptr) {
30174         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
30175         this_ptr_conv.inner = untag_ptr(this_ptr);
30176         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30177         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30178         this_ptr_conv.is_owned = false;
30179         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
30180         *ret_ref = DelayedPaymentOutputDescriptor_get_output(&this_ptr_conv);
30181         return tag_ptr(ret_ref, true);
30182 }
30183
30184 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1output(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30185         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
30186         this_ptr_conv.inner = untag_ptr(this_ptr);
30187         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30188         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30189         this_ptr_conv.is_owned = false;
30190         void* val_ptr = untag_ptr(val);
30191         CHECK_ACCESS(val_ptr);
30192         LDKTxOut val_conv = *(LDKTxOut*)(val_ptr);
30193         val_conv = TxOut_clone((LDKTxOut*)untag_ptr(val));
30194         DelayedPaymentOutputDescriptor_set_output(&this_ptr_conv, val_conv);
30195 }
30196
30197 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1revocation_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
30198         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
30199         this_ptr_conv.inner = untag_ptr(this_ptr);
30200         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30201         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30202         this_ptr_conv.is_owned = false;
30203         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
30204         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, DelayedPaymentOutputDescriptor_get_revocation_pubkey(&this_ptr_conv).compressed_form);
30205         return ret_arr;
30206 }
30207
30208 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1revocation_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
30209         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
30210         this_ptr_conv.inner = untag_ptr(this_ptr);
30211         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30212         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30213         this_ptr_conv.is_owned = false;
30214         LDKPublicKey val_ref;
30215         CHECK((*env)->GetArrayLength(env, val) == 33);
30216         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
30217         DelayedPaymentOutputDescriptor_set_revocation_pubkey(&this_ptr_conv, val_ref);
30218 }
30219
30220 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
30221         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
30222         this_ptr_conv.inner = untag_ptr(this_ptr);
30223         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30224         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30225         this_ptr_conv.is_owned = false;
30226         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
30227         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *DelayedPaymentOutputDescriptor_get_channel_keys_id(&this_ptr_conv));
30228         return ret_arr;
30229 }
30230
30231 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
30232         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
30233         this_ptr_conv.inner = untag_ptr(this_ptr);
30234         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30235         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30236         this_ptr_conv.is_owned = false;
30237         LDKThirtyTwoBytes val_ref;
30238         CHECK((*env)->GetArrayLength(env, val) == 32);
30239         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
30240         DelayedPaymentOutputDescriptor_set_channel_keys_id(&this_ptr_conv, val_ref);
30241 }
30242
30243 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
30244         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
30245         this_ptr_conv.inner = untag_ptr(this_ptr);
30246         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30247         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30248         this_ptr_conv.is_owned = false;
30249         int64_t ret_conv = DelayedPaymentOutputDescriptor_get_channel_value_satoshis(&this_ptr_conv);
30250         return ret_conv;
30251 }
30252
30253 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30254         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
30255         this_ptr_conv.inner = untag_ptr(this_ptr);
30256         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30257         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30258         this_ptr_conv.is_owned = false;
30259         DelayedPaymentOutputDescriptor_set_channel_value_satoshis(&this_ptr_conv, val);
30260 }
30261
30262 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) {
30263         LDKOutPoint outpoint_arg_conv;
30264         outpoint_arg_conv.inner = untag_ptr(outpoint_arg);
30265         outpoint_arg_conv.is_owned = ptr_is_owned(outpoint_arg);
30266         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_arg_conv);
30267         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
30268         LDKPublicKey per_commitment_point_arg_ref;
30269         CHECK((*env)->GetArrayLength(env, per_commitment_point_arg) == 33);
30270         (*env)->GetByteArrayRegion(env, per_commitment_point_arg, 0, 33, per_commitment_point_arg_ref.compressed_form);
30271         void* output_arg_ptr = untag_ptr(output_arg);
30272         CHECK_ACCESS(output_arg_ptr);
30273         LDKTxOut output_arg_conv = *(LDKTxOut*)(output_arg_ptr);
30274         output_arg_conv = TxOut_clone((LDKTxOut*)untag_ptr(output_arg));
30275         LDKPublicKey revocation_pubkey_arg_ref;
30276         CHECK((*env)->GetArrayLength(env, revocation_pubkey_arg) == 33);
30277         (*env)->GetByteArrayRegion(env, revocation_pubkey_arg, 0, 33, revocation_pubkey_arg_ref.compressed_form);
30278         LDKThirtyTwoBytes channel_keys_id_arg_ref;
30279         CHECK((*env)->GetArrayLength(env, channel_keys_id_arg) == 32);
30280         (*env)->GetByteArrayRegion(env, channel_keys_id_arg, 0, 32, channel_keys_id_arg_ref.data);
30281         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);
30282         int64_t ret_ref = 0;
30283         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30284         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30285         return ret_ref;
30286 }
30287
30288 static inline uint64_t DelayedPaymentOutputDescriptor_clone_ptr(LDKDelayedPaymentOutputDescriptor *NONNULL_PTR arg) {
30289         LDKDelayedPaymentOutputDescriptor ret_var = DelayedPaymentOutputDescriptor_clone(arg);
30290         int64_t ret_ref = 0;
30291         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30292         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30293         return ret_ref;
30294 }
30295 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
30296         LDKDelayedPaymentOutputDescriptor arg_conv;
30297         arg_conv.inner = untag_ptr(arg);
30298         arg_conv.is_owned = ptr_is_owned(arg);
30299         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30300         arg_conv.is_owned = false;
30301         int64_t ret_conv = DelayedPaymentOutputDescriptor_clone_ptr(&arg_conv);
30302         return ret_conv;
30303 }
30304
30305 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
30306         LDKDelayedPaymentOutputDescriptor orig_conv;
30307         orig_conv.inner = untag_ptr(orig);
30308         orig_conv.is_owned = ptr_is_owned(orig);
30309         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30310         orig_conv.is_owned = false;
30311         LDKDelayedPaymentOutputDescriptor ret_var = DelayedPaymentOutputDescriptor_clone(&orig_conv);
30312         int64_t ret_ref = 0;
30313         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30314         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30315         return ret_ref;
30316 }
30317
30318 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
30319         LDKDelayedPaymentOutputDescriptor a_conv;
30320         a_conv.inner = untag_ptr(a);
30321         a_conv.is_owned = ptr_is_owned(a);
30322         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
30323         a_conv.is_owned = false;
30324         LDKDelayedPaymentOutputDescriptor b_conv;
30325         b_conv.inner = untag_ptr(b);
30326         b_conv.is_owned = ptr_is_owned(b);
30327         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
30328         b_conv.is_owned = false;
30329         jboolean ret_conv = DelayedPaymentOutputDescriptor_eq(&a_conv, &b_conv);
30330         return ret_conv;
30331 }
30332
30333 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1write(JNIEnv *env, jclass clz, int64_t obj) {
30334         LDKDelayedPaymentOutputDescriptor obj_conv;
30335         obj_conv.inner = untag_ptr(obj);
30336         obj_conv.is_owned = ptr_is_owned(obj);
30337         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
30338         obj_conv.is_owned = false;
30339         LDKCVec_u8Z ret_var = DelayedPaymentOutputDescriptor_write(&obj_conv);
30340         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
30341         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
30342         CVec_u8Z_free(ret_var);
30343         return ret_arr;
30344 }
30345
30346 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
30347         LDKu8slice ser_ref;
30348         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
30349         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
30350         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
30351         *ret_conv = DelayedPaymentOutputDescriptor_read(ser_ref);
30352         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
30353         return tag_ptr(ret_conv, true);
30354 }
30355
30356 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
30357         LDKStaticPaymentOutputDescriptor this_obj_conv;
30358         this_obj_conv.inner = untag_ptr(this_obj);
30359         this_obj_conv.is_owned = ptr_is_owned(this_obj);
30360         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30361         StaticPaymentOutputDescriptor_free(this_obj_conv);
30362 }
30363
30364 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1get_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
30365         LDKStaticPaymentOutputDescriptor this_ptr_conv;
30366         this_ptr_conv.inner = untag_ptr(this_ptr);
30367         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30368         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30369         this_ptr_conv.is_owned = false;
30370         LDKOutPoint ret_var = StaticPaymentOutputDescriptor_get_outpoint(&this_ptr_conv);
30371         int64_t ret_ref = 0;
30372         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30373         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30374         return ret_ref;
30375 }
30376
30377 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1set_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30378         LDKStaticPaymentOutputDescriptor this_ptr_conv;
30379         this_ptr_conv.inner = untag_ptr(this_ptr);
30380         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30381         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30382         this_ptr_conv.is_owned = false;
30383         LDKOutPoint val_conv;
30384         val_conv.inner = untag_ptr(val);
30385         val_conv.is_owned = ptr_is_owned(val);
30386         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
30387         val_conv = OutPoint_clone(&val_conv);
30388         StaticPaymentOutputDescriptor_set_outpoint(&this_ptr_conv, val_conv);
30389 }
30390
30391 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1get_1output(JNIEnv *env, jclass clz, int64_t this_ptr) {
30392         LDKStaticPaymentOutputDescriptor this_ptr_conv;
30393         this_ptr_conv.inner = untag_ptr(this_ptr);
30394         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30395         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30396         this_ptr_conv.is_owned = false;
30397         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
30398         *ret_ref = StaticPaymentOutputDescriptor_get_output(&this_ptr_conv);
30399         return tag_ptr(ret_ref, true);
30400 }
30401
30402 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1set_1output(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30403         LDKStaticPaymentOutputDescriptor this_ptr_conv;
30404         this_ptr_conv.inner = untag_ptr(this_ptr);
30405         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30406         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30407         this_ptr_conv.is_owned = false;
30408         void* val_ptr = untag_ptr(val);
30409         CHECK_ACCESS(val_ptr);
30410         LDKTxOut val_conv = *(LDKTxOut*)(val_ptr);
30411         val_conv = TxOut_clone((LDKTxOut*)untag_ptr(val));
30412         StaticPaymentOutputDescriptor_set_output(&this_ptr_conv, val_conv);
30413 }
30414
30415 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1get_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
30416         LDKStaticPaymentOutputDescriptor this_ptr_conv;
30417         this_ptr_conv.inner = untag_ptr(this_ptr);
30418         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30419         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30420         this_ptr_conv.is_owned = false;
30421         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
30422         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *StaticPaymentOutputDescriptor_get_channel_keys_id(&this_ptr_conv));
30423         return ret_arr;
30424 }
30425
30426 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1set_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
30427         LDKStaticPaymentOutputDescriptor this_ptr_conv;
30428         this_ptr_conv.inner = untag_ptr(this_ptr);
30429         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30430         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30431         this_ptr_conv.is_owned = false;
30432         LDKThirtyTwoBytes val_ref;
30433         CHECK((*env)->GetArrayLength(env, val) == 32);
30434         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
30435         StaticPaymentOutputDescriptor_set_channel_keys_id(&this_ptr_conv, val_ref);
30436 }
30437
30438 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1get_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
30439         LDKStaticPaymentOutputDescriptor this_ptr_conv;
30440         this_ptr_conv.inner = untag_ptr(this_ptr);
30441         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30442         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30443         this_ptr_conv.is_owned = false;
30444         int64_t ret_conv = StaticPaymentOutputDescriptor_get_channel_value_satoshis(&this_ptr_conv);
30445         return ret_conv;
30446 }
30447
30448 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1set_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30449         LDKStaticPaymentOutputDescriptor this_ptr_conv;
30450         this_ptr_conv.inner = untag_ptr(this_ptr);
30451         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30452         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30453         this_ptr_conv.is_owned = false;
30454         StaticPaymentOutputDescriptor_set_channel_value_satoshis(&this_ptr_conv, val);
30455 }
30456
30457 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) {
30458         LDKOutPoint outpoint_arg_conv;
30459         outpoint_arg_conv.inner = untag_ptr(outpoint_arg);
30460         outpoint_arg_conv.is_owned = ptr_is_owned(outpoint_arg);
30461         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_arg_conv);
30462         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
30463         void* output_arg_ptr = untag_ptr(output_arg);
30464         CHECK_ACCESS(output_arg_ptr);
30465         LDKTxOut output_arg_conv = *(LDKTxOut*)(output_arg_ptr);
30466         output_arg_conv = TxOut_clone((LDKTxOut*)untag_ptr(output_arg));
30467         LDKThirtyTwoBytes channel_keys_id_arg_ref;
30468         CHECK((*env)->GetArrayLength(env, channel_keys_id_arg) == 32);
30469         (*env)->GetByteArrayRegion(env, channel_keys_id_arg, 0, 32, channel_keys_id_arg_ref.data);
30470         LDKStaticPaymentOutputDescriptor ret_var = StaticPaymentOutputDescriptor_new(outpoint_arg_conv, output_arg_conv, channel_keys_id_arg_ref, channel_value_satoshis_arg);
30471         int64_t ret_ref = 0;
30472         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30473         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30474         return ret_ref;
30475 }
30476
30477 static inline uint64_t StaticPaymentOutputDescriptor_clone_ptr(LDKStaticPaymentOutputDescriptor *NONNULL_PTR arg) {
30478         LDKStaticPaymentOutputDescriptor ret_var = StaticPaymentOutputDescriptor_clone(arg);
30479         int64_t ret_ref = 0;
30480         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30481         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30482         return ret_ref;
30483 }
30484 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
30485         LDKStaticPaymentOutputDescriptor arg_conv;
30486         arg_conv.inner = untag_ptr(arg);
30487         arg_conv.is_owned = ptr_is_owned(arg);
30488         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30489         arg_conv.is_owned = false;
30490         int64_t ret_conv = StaticPaymentOutputDescriptor_clone_ptr(&arg_conv);
30491         return ret_conv;
30492 }
30493
30494 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
30495         LDKStaticPaymentOutputDescriptor orig_conv;
30496         orig_conv.inner = untag_ptr(orig);
30497         orig_conv.is_owned = ptr_is_owned(orig);
30498         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30499         orig_conv.is_owned = false;
30500         LDKStaticPaymentOutputDescriptor ret_var = StaticPaymentOutputDescriptor_clone(&orig_conv);
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 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
30508         LDKStaticPaymentOutputDescriptor a_conv;
30509         a_conv.inner = untag_ptr(a);
30510         a_conv.is_owned = ptr_is_owned(a);
30511         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
30512         a_conv.is_owned = false;
30513         LDKStaticPaymentOutputDescriptor b_conv;
30514         b_conv.inner = untag_ptr(b);
30515         b_conv.is_owned = ptr_is_owned(b);
30516         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
30517         b_conv.is_owned = false;
30518         jboolean ret_conv = StaticPaymentOutputDescriptor_eq(&a_conv, &b_conv);
30519         return ret_conv;
30520 }
30521
30522 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1write(JNIEnv *env, jclass clz, int64_t obj) {
30523         LDKStaticPaymentOutputDescriptor obj_conv;
30524         obj_conv.inner = untag_ptr(obj);
30525         obj_conv.is_owned = ptr_is_owned(obj);
30526         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
30527         obj_conv.is_owned = false;
30528         LDKCVec_u8Z ret_var = StaticPaymentOutputDescriptor_write(&obj_conv);
30529         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
30530         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
30531         CVec_u8Z_free(ret_var);
30532         return ret_arr;
30533 }
30534
30535 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
30536         LDKu8slice ser_ref;
30537         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
30538         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
30539         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
30540         *ret_conv = StaticPaymentOutputDescriptor_read(ser_ref);
30541         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
30542         return tag_ptr(ret_conv, true);
30543 }
30544
30545 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
30546         if (!ptr_is_owned(this_ptr)) return;
30547         void* this_ptr_ptr = untag_ptr(this_ptr);
30548         CHECK_ACCESS(this_ptr_ptr);
30549         LDKSpendableOutputDescriptor this_ptr_conv = *(LDKSpendableOutputDescriptor*)(this_ptr_ptr);
30550         FREE(untag_ptr(this_ptr));
30551         SpendableOutputDescriptor_free(this_ptr_conv);
30552 }
30553
30554 static inline uint64_t SpendableOutputDescriptor_clone_ptr(LDKSpendableOutputDescriptor *NONNULL_PTR arg) {
30555         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
30556         *ret_copy = SpendableOutputDescriptor_clone(arg);
30557         int64_t ret_ref = tag_ptr(ret_copy, true);
30558         return ret_ref;
30559 }
30560 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
30561         LDKSpendableOutputDescriptor* arg_conv = (LDKSpendableOutputDescriptor*)untag_ptr(arg);
30562         int64_t ret_conv = SpendableOutputDescriptor_clone_ptr(arg_conv);
30563         return ret_conv;
30564 }
30565
30566 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
30567         LDKSpendableOutputDescriptor* orig_conv = (LDKSpendableOutputDescriptor*)untag_ptr(orig);
30568         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
30569         *ret_copy = SpendableOutputDescriptor_clone(orig_conv);
30570         int64_t ret_ref = tag_ptr(ret_copy, true);
30571         return ret_ref;
30572 }
30573
30574 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1static_1output(JNIEnv *env, jclass clz, int64_t outpoint, int64_t output) {
30575         LDKOutPoint outpoint_conv;
30576         outpoint_conv.inner = untag_ptr(outpoint);
30577         outpoint_conv.is_owned = ptr_is_owned(outpoint);
30578         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_conv);
30579         outpoint_conv = OutPoint_clone(&outpoint_conv);
30580         void* output_ptr = untag_ptr(output);
30581         CHECK_ACCESS(output_ptr);
30582         LDKTxOut output_conv = *(LDKTxOut*)(output_ptr);
30583         output_conv = TxOut_clone((LDKTxOut*)untag_ptr(output));
30584         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
30585         *ret_copy = SpendableOutputDescriptor_static_output(outpoint_conv, output_conv);
30586         int64_t ret_ref = tag_ptr(ret_copy, true);
30587         return ret_ref;
30588 }
30589
30590 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1delayed_1payment_1output(JNIEnv *env, jclass clz, int64_t a) {
30591         LDKDelayedPaymentOutputDescriptor a_conv;
30592         a_conv.inner = untag_ptr(a);
30593         a_conv.is_owned = ptr_is_owned(a);
30594         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
30595         a_conv = DelayedPaymentOutputDescriptor_clone(&a_conv);
30596         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
30597         *ret_copy = SpendableOutputDescriptor_delayed_payment_output(a_conv);
30598         int64_t ret_ref = tag_ptr(ret_copy, true);
30599         return ret_ref;
30600 }
30601
30602 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1static_1payment_1output(JNIEnv *env, jclass clz, int64_t a) {
30603         LDKStaticPaymentOutputDescriptor a_conv;
30604         a_conv.inner = untag_ptr(a);
30605         a_conv.is_owned = ptr_is_owned(a);
30606         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
30607         a_conv = StaticPaymentOutputDescriptor_clone(&a_conv);
30608         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
30609         *ret_copy = SpendableOutputDescriptor_static_payment_output(a_conv);
30610         int64_t ret_ref = tag_ptr(ret_copy, true);
30611         return ret_ref;
30612 }
30613
30614 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
30615         LDKSpendableOutputDescriptor* a_conv = (LDKSpendableOutputDescriptor*)untag_ptr(a);
30616         LDKSpendableOutputDescriptor* b_conv = (LDKSpendableOutputDescriptor*)untag_ptr(b);
30617         jboolean ret_conv = SpendableOutputDescriptor_eq(a_conv, b_conv);
30618         return ret_conv;
30619 }
30620
30621 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1write(JNIEnv *env, jclass clz, int64_t obj) {
30622         LDKSpendableOutputDescriptor* obj_conv = (LDKSpendableOutputDescriptor*)untag_ptr(obj);
30623         LDKCVec_u8Z ret_var = SpendableOutputDescriptor_write(obj_conv);
30624         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
30625         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
30626         CVec_u8Z_free(ret_var);
30627         return ret_arr;
30628 }
30629
30630 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
30631         LDKu8slice ser_ref;
30632         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
30633         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
30634         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
30635         *ret_conv = SpendableOutputDescriptor_read(ser_ref);
30636         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
30637         return tag_ptr(ret_conv, true);
30638 }
30639
30640 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BaseSign_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
30641         if (!ptr_is_owned(this_ptr)) return;
30642         void* this_ptr_ptr = untag_ptr(this_ptr);
30643         CHECK_ACCESS(this_ptr_ptr);
30644         LDKBaseSign this_ptr_conv = *(LDKBaseSign*)(this_ptr_ptr);
30645         FREE(untag_ptr(this_ptr));
30646         BaseSign_free(this_ptr_conv);
30647 }
30648
30649 static inline uint64_t Sign_clone_ptr(LDKSign *NONNULL_PTR arg) {
30650         LDKSign* ret_ret = MALLOC(sizeof(LDKSign), "LDKSign");
30651         *ret_ret = Sign_clone(arg);
30652         return tag_ptr(ret_ret, true);
30653 }
30654 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Sign_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
30655         void* arg_ptr = untag_ptr(arg);
30656         if (ptr_is_owned(arg)) { CHECK_ACCESS(arg_ptr); }
30657         LDKSign* arg_conv = (LDKSign*)arg_ptr;
30658         int64_t ret_conv = Sign_clone_ptr(arg_conv);
30659         return ret_conv;
30660 }
30661
30662 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Sign_1clone(JNIEnv *env, jclass clz, int64_t orig) {
30663         void* orig_ptr = untag_ptr(orig);
30664         if (ptr_is_owned(orig)) { CHECK_ACCESS(orig_ptr); }
30665         LDKSign* orig_conv = (LDKSign*)orig_ptr;
30666         LDKSign* ret_ret = MALLOC(sizeof(LDKSign), "LDKSign");
30667         *ret_ret = Sign_clone(orig_conv);
30668         return tag_ptr(ret_ret, true);
30669 }
30670
30671 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Sign_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
30672         if (!ptr_is_owned(this_ptr)) return;
30673         void* this_ptr_ptr = untag_ptr(this_ptr);
30674         CHECK_ACCESS(this_ptr_ptr);
30675         LDKSign this_ptr_conv = *(LDKSign*)(this_ptr_ptr);
30676         FREE(untag_ptr(this_ptr));
30677         Sign_free(this_ptr_conv);
30678 }
30679
30680 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Recipient_1clone(JNIEnv *env, jclass clz, int64_t orig) {
30681         LDKRecipient* orig_conv = (LDKRecipient*)untag_ptr(orig);
30682         jclass ret_conv = LDKRecipient_to_java(env, Recipient_clone(orig_conv));
30683         return ret_conv;
30684 }
30685
30686 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Recipient_1node(JNIEnv *env, jclass clz) {
30687         jclass ret_conv = LDKRecipient_to_java(env, Recipient_node());
30688         return ret_conv;
30689 }
30690
30691 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Recipient_1phantom_1node(JNIEnv *env, jclass clz) {
30692         jclass ret_conv = LDKRecipient_to_java(env, Recipient_phantom_node());
30693         return ret_conv;
30694 }
30695
30696 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_KeysInterface_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
30697         if (!ptr_is_owned(this_ptr)) return;
30698         void* this_ptr_ptr = untag_ptr(this_ptr);
30699         CHECK_ACCESS(this_ptr_ptr);
30700         LDKKeysInterface this_ptr_conv = *(LDKKeysInterface*)(this_ptr_ptr);
30701         FREE(untag_ptr(this_ptr));
30702         KeysInterface_free(this_ptr_conv);
30703 }
30704
30705 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
30706         LDKInMemorySigner this_obj_conv;
30707         this_obj_conv.inner = untag_ptr(this_obj);
30708         this_obj_conv.is_owned = ptr_is_owned(this_obj);
30709         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30710         InMemorySigner_free(this_obj_conv);
30711 }
30712
30713 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1funding_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
30714         LDKInMemorySigner this_ptr_conv;
30715         this_ptr_conv.inner = untag_ptr(this_ptr);
30716         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30717         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30718         this_ptr_conv.is_owned = false;
30719         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
30720         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_funding_key(&this_ptr_conv));
30721         return ret_arr;
30722 }
30723
30724 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1funding_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
30725         LDKInMemorySigner this_ptr_conv;
30726         this_ptr_conv.inner = untag_ptr(this_ptr);
30727         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30728         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30729         this_ptr_conv.is_owned = false;
30730         LDKSecretKey val_ref;
30731         CHECK((*env)->GetArrayLength(env, val) == 32);
30732         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
30733         InMemorySigner_set_funding_key(&this_ptr_conv, val_ref);
30734 }
30735
30736 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1revocation_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
30737         LDKInMemorySigner this_ptr_conv;
30738         this_ptr_conv.inner = untag_ptr(this_ptr);
30739         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30740         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30741         this_ptr_conv.is_owned = false;
30742         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
30743         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_revocation_base_key(&this_ptr_conv));
30744         return ret_arr;
30745 }
30746
30747 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1revocation_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
30748         LDKInMemorySigner this_ptr_conv;
30749         this_ptr_conv.inner = untag_ptr(this_ptr);
30750         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30751         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30752         this_ptr_conv.is_owned = false;
30753         LDKSecretKey val_ref;
30754         CHECK((*env)->GetArrayLength(env, val) == 32);
30755         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
30756         InMemorySigner_set_revocation_base_key(&this_ptr_conv, val_ref);
30757 }
30758
30759 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1payment_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
30760         LDKInMemorySigner this_ptr_conv;
30761         this_ptr_conv.inner = untag_ptr(this_ptr);
30762         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30763         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30764         this_ptr_conv.is_owned = false;
30765         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
30766         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_payment_key(&this_ptr_conv));
30767         return ret_arr;
30768 }
30769
30770 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1payment_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
30771         LDKInMemorySigner this_ptr_conv;
30772         this_ptr_conv.inner = untag_ptr(this_ptr);
30773         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30774         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30775         this_ptr_conv.is_owned = false;
30776         LDKSecretKey val_ref;
30777         CHECK((*env)->GetArrayLength(env, val) == 32);
30778         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
30779         InMemorySigner_set_payment_key(&this_ptr_conv, val_ref);
30780 }
30781
30782 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1delayed_1payment_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
30783         LDKInMemorySigner this_ptr_conv;
30784         this_ptr_conv.inner = untag_ptr(this_ptr);
30785         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30786         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30787         this_ptr_conv.is_owned = false;
30788         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
30789         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_delayed_payment_base_key(&this_ptr_conv));
30790         return ret_arr;
30791 }
30792
30793 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) {
30794         LDKInMemorySigner this_ptr_conv;
30795         this_ptr_conv.inner = untag_ptr(this_ptr);
30796         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30797         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30798         this_ptr_conv.is_owned = false;
30799         LDKSecretKey val_ref;
30800         CHECK((*env)->GetArrayLength(env, val) == 32);
30801         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
30802         InMemorySigner_set_delayed_payment_base_key(&this_ptr_conv, val_ref);
30803 }
30804
30805 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1htlc_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
30806         LDKInMemorySigner this_ptr_conv;
30807         this_ptr_conv.inner = untag_ptr(this_ptr);
30808         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30809         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30810         this_ptr_conv.is_owned = false;
30811         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
30812         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_htlc_base_key(&this_ptr_conv));
30813         return ret_arr;
30814 }
30815
30816 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1htlc_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
30817         LDKInMemorySigner this_ptr_conv;
30818         this_ptr_conv.inner = untag_ptr(this_ptr);
30819         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30820         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30821         this_ptr_conv.is_owned = false;
30822         LDKSecretKey val_ref;
30823         CHECK((*env)->GetArrayLength(env, val) == 32);
30824         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
30825         InMemorySigner_set_htlc_base_key(&this_ptr_conv, val_ref);
30826 }
30827
30828 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1commitment_1seed(JNIEnv *env, jclass clz, int64_t this_ptr) {
30829         LDKInMemorySigner this_ptr_conv;
30830         this_ptr_conv.inner = untag_ptr(this_ptr);
30831         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30832         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30833         this_ptr_conv.is_owned = false;
30834         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
30835         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_commitment_seed(&this_ptr_conv));
30836         return ret_arr;
30837 }
30838
30839 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1commitment_1seed(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
30840         LDKInMemorySigner this_ptr_conv;
30841         this_ptr_conv.inner = untag_ptr(this_ptr);
30842         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
30843         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30844         this_ptr_conv.is_owned = false;
30845         LDKThirtyTwoBytes val_ref;
30846         CHECK((*env)->GetArrayLength(env, val) == 32);
30847         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
30848         InMemorySigner_set_commitment_seed(&this_ptr_conv, val_ref);
30849 }
30850
30851 static inline uint64_t InMemorySigner_clone_ptr(LDKInMemorySigner *NONNULL_PTR arg) {
30852         LDKInMemorySigner ret_var = InMemorySigner_clone(arg);
30853         int64_t ret_ref = 0;
30854         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30855         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30856         return ret_ref;
30857 }
30858 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
30859         LDKInMemorySigner arg_conv;
30860         arg_conv.inner = untag_ptr(arg);
30861         arg_conv.is_owned = ptr_is_owned(arg);
30862         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30863         arg_conv.is_owned = false;
30864         int64_t ret_conv = InMemorySigner_clone_ptr(&arg_conv);
30865         return ret_conv;
30866 }
30867
30868 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1clone(JNIEnv *env, jclass clz, int64_t orig) {
30869         LDKInMemorySigner orig_conv;
30870         orig_conv.inner = untag_ptr(orig);
30871         orig_conv.is_owned = ptr_is_owned(orig);
30872         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30873         orig_conv.is_owned = false;
30874         LDKInMemorySigner ret_var = InMemorySigner_clone(&orig_conv);
30875         int64_t ret_ref = 0;
30876         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30877         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30878         return ret_ref;
30879 }
30880
30881 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) {
30882         LDKSecretKey node_secret_ref;
30883         CHECK((*env)->GetArrayLength(env, node_secret) == 32);
30884         (*env)->GetByteArrayRegion(env, node_secret, 0, 32, node_secret_ref.bytes);
30885         LDKSecretKey funding_key_ref;
30886         CHECK((*env)->GetArrayLength(env, funding_key) == 32);
30887         (*env)->GetByteArrayRegion(env, funding_key, 0, 32, funding_key_ref.bytes);
30888         LDKSecretKey revocation_base_key_ref;
30889         CHECK((*env)->GetArrayLength(env, revocation_base_key) == 32);
30890         (*env)->GetByteArrayRegion(env, revocation_base_key, 0, 32, revocation_base_key_ref.bytes);
30891         LDKSecretKey payment_key_ref;
30892         CHECK((*env)->GetArrayLength(env, payment_key) == 32);
30893         (*env)->GetByteArrayRegion(env, payment_key, 0, 32, payment_key_ref.bytes);
30894         LDKSecretKey delayed_payment_base_key_ref;
30895         CHECK((*env)->GetArrayLength(env, delayed_payment_base_key) == 32);
30896         (*env)->GetByteArrayRegion(env, delayed_payment_base_key, 0, 32, delayed_payment_base_key_ref.bytes);
30897         LDKSecretKey htlc_base_key_ref;
30898         CHECK((*env)->GetArrayLength(env, htlc_base_key) == 32);
30899         (*env)->GetByteArrayRegion(env, htlc_base_key, 0, 32, htlc_base_key_ref.bytes);
30900         LDKThirtyTwoBytes commitment_seed_ref;
30901         CHECK((*env)->GetArrayLength(env, commitment_seed) == 32);
30902         (*env)->GetByteArrayRegion(env, commitment_seed, 0, 32, commitment_seed_ref.data);
30903         LDKThirtyTwoBytes channel_keys_id_ref;
30904         CHECK((*env)->GetArrayLength(env, channel_keys_id) == 32);
30905         (*env)->GetByteArrayRegion(env, channel_keys_id, 0, 32, channel_keys_id_ref.data);
30906         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);
30907         int64_t ret_ref = 0;
30908         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30909         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30910         return ret_ref;
30911 }
30912
30913 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1counterparty_1pubkeys(JNIEnv *env, jclass clz, int64_t this_arg) {
30914         LDKInMemorySigner this_arg_conv;
30915         this_arg_conv.inner = untag_ptr(this_arg);
30916         this_arg_conv.is_owned = ptr_is_owned(this_arg);
30917         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30918         this_arg_conv.is_owned = false;
30919         LDKChannelPublicKeys ret_var = InMemorySigner_counterparty_pubkeys(&this_arg_conv);
30920         int64_t ret_ref = 0;
30921         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30922         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30923         return ret_ref;
30924 }
30925
30926 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1counterparty_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_arg) {
30927         LDKInMemorySigner this_arg_conv;
30928         this_arg_conv.inner = untag_ptr(this_arg);
30929         this_arg_conv.is_owned = ptr_is_owned(this_arg);
30930         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30931         this_arg_conv.is_owned = false;
30932         int16_t ret_conv = InMemorySigner_counterparty_selected_contest_delay(&this_arg_conv);
30933         return ret_conv;
30934 }
30935
30936 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1holder_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_arg) {
30937         LDKInMemorySigner this_arg_conv;
30938         this_arg_conv.inner = untag_ptr(this_arg);
30939         this_arg_conv.is_owned = ptr_is_owned(this_arg);
30940         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30941         this_arg_conv.is_owned = false;
30942         int16_t ret_conv = InMemorySigner_holder_selected_contest_delay(&this_arg_conv);
30943         return ret_conv;
30944 }
30945
30946 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1is_1outbound(JNIEnv *env, jclass clz, int64_t this_arg) {
30947         LDKInMemorySigner this_arg_conv;
30948         this_arg_conv.inner = untag_ptr(this_arg);
30949         this_arg_conv.is_owned = ptr_is_owned(this_arg);
30950         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30951         this_arg_conv.is_owned = false;
30952         jboolean ret_conv = InMemorySigner_is_outbound(&this_arg_conv);
30953         return ret_conv;
30954 }
30955
30956 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1funding_1outpoint(JNIEnv *env, jclass clz, int64_t this_arg) {
30957         LDKInMemorySigner this_arg_conv;
30958         this_arg_conv.inner = untag_ptr(this_arg);
30959         this_arg_conv.is_owned = ptr_is_owned(this_arg);
30960         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30961         this_arg_conv.is_owned = false;
30962         LDKOutPoint ret_var = InMemorySigner_funding_outpoint(&this_arg_conv);
30963         int64_t ret_ref = 0;
30964         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30965         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30966         return ret_ref;
30967 }
30968
30969 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1channel_1parameters(JNIEnv *env, jclass clz, int64_t this_arg) {
30970         LDKInMemorySigner this_arg_conv;
30971         this_arg_conv.inner = untag_ptr(this_arg);
30972         this_arg_conv.is_owned = ptr_is_owned(this_arg);
30973         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30974         this_arg_conv.is_owned = false;
30975         LDKChannelTransactionParameters ret_var = InMemorySigner_get_channel_parameters(&this_arg_conv);
30976         int64_t ret_ref = 0;
30977         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30978         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
30979         return ret_ref;
30980 }
30981
30982 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1opt_1anchors(JNIEnv *env, jclass clz, int64_t this_arg) {
30983         LDKInMemorySigner this_arg_conv;
30984         this_arg_conv.inner = untag_ptr(this_arg);
30985         this_arg_conv.is_owned = ptr_is_owned(this_arg);
30986         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30987         this_arg_conv.is_owned = false;
30988         jboolean ret_conv = InMemorySigner_opt_anchors(&this_arg_conv);
30989         return ret_conv;
30990 }
30991
30992 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) {
30993         LDKInMemorySigner this_arg_conv;
30994         this_arg_conv.inner = untag_ptr(this_arg);
30995         this_arg_conv.is_owned = ptr_is_owned(this_arg);
30996         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
30997         this_arg_conv.is_owned = false;
30998         LDKTransaction spend_tx_ref;
30999         spend_tx_ref.datalen = (*env)->GetArrayLength(env, spend_tx);
31000         spend_tx_ref.data = MALLOC(spend_tx_ref.datalen, "LDKTransaction Bytes");
31001         (*env)->GetByteArrayRegion(env, spend_tx, 0, spend_tx_ref.datalen, spend_tx_ref.data);
31002         spend_tx_ref.data_is_owned = true;
31003         LDKStaticPaymentOutputDescriptor descriptor_conv;
31004         descriptor_conv.inner = untag_ptr(descriptor);
31005         descriptor_conv.is_owned = ptr_is_owned(descriptor);
31006         CHECK_INNER_FIELD_ACCESS_OR_NULL(descriptor_conv);
31007         descriptor_conv.is_owned = false;
31008         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
31009         *ret_conv = InMemorySigner_sign_counterparty_payment_input(&this_arg_conv, spend_tx_ref, input_idx, &descriptor_conv);
31010         return tag_ptr(ret_conv, true);
31011 }
31012
31013 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) {
31014         LDKInMemorySigner this_arg_conv;
31015         this_arg_conv.inner = untag_ptr(this_arg);
31016         this_arg_conv.is_owned = ptr_is_owned(this_arg);
31017         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31018         this_arg_conv.is_owned = false;
31019         LDKTransaction spend_tx_ref;
31020         spend_tx_ref.datalen = (*env)->GetArrayLength(env, spend_tx);
31021         spend_tx_ref.data = MALLOC(spend_tx_ref.datalen, "LDKTransaction Bytes");
31022         (*env)->GetByteArrayRegion(env, spend_tx, 0, spend_tx_ref.datalen, spend_tx_ref.data);
31023         spend_tx_ref.data_is_owned = true;
31024         LDKDelayedPaymentOutputDescriptor descriptor_conv;
31025         descriptor_conv.inner = untag_ptr(descriptor);
31026         descriptor_conv.is_owned = ptr_is_owned(descriptor);
31027         CHECK_INNER_FIELD_ACCESS_OR_NULL(descriptor_conv);
31028         descriptor_conv.is_owned = false;
31029         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
31030         *ret_conv = InMemorySigner_sign_dynamic_p2wsh_input(&this_arg_conv, spend_tx_ref, input_idx, &descriptor_conv);
31031         return tag_ptr(ret_conv, true);
31032 }
31033
31034 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1as_1BaseSign(JNIEnv *env, jclass clz, int64_t this_arg) {
31035         LDKInMemorySigner this_arg_conv;
31036         this_arg_conv.inner = untag_ptr(this_arg);
31037         this_arg_conv.is_owned = ptr_is_owned(this_arg);
31038         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31039         this_arg_conv.is_owned = false;
31040         LDKBaseSign* ret_ret = MALLOC(sizeof(LDKBaseSign), "LDKBaseSign");
31041         *ret_ret = InMemorySigner_as_BaseSign(&this_arg_conv);
31042         return tag_ptr(ret_ret, true);
31043 }
31044
31045 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1as_1Sign(JNIEnv *env, jclass clz, int64_t this_arg) {
31046         LDKInMemorySigner this_arg_conv;
31047         this_arg_conv.inner = untag_ptr(this_arg);
31048         this_arg_conv.is_owned = ptr_is_owned(this_arg);
31049         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31050         this_arg_conv.is_owned = false;
31051         LDKSign* ret_ret = MALLOC(sizeof(LDKSign), "LDKSign");
31052         *ret_ret = InMemorySigner_as_Sign(&this_arg_conv);
31053         return tag_ptr(ret_ret, true);
31054 }
31055
31056 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1write(JNIEnv *env, jclass clz, int64_t obj) {
31057         LDKInMemorySigner obj_conv;
31058         obj_conv.inner = untag_ptr(obj);
31059         obj_conv.is_owned = ptr_is_owned(obj);
31060         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31061         obj_conv.is_owned = false;
31062         LDKCVec_u8Z ret_var = InMemorySigner_write(&obj_conv);
31063         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
31064         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
31065         CVec_u8Z_free(ret_var);
31066         return ret_arr;
31067 }
31068
31069 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1read(JNIEnv *env, jclass clz, int8_tArray ser, int8_tArray arg) {
31070         LDKu8slice ser_ref;
31071         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
31072         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
31073         LDKSecretKey arg_ref;
31074         CHECK((*env)->GetArrayLength(env, arg) == 32);
31075         (*env)->GetByteArrayRegion(env, arg, 0, 32, arg_ref.bytes);
31076         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
31077         *ret_conv = InMemorySigner_read(ser_ref, arg_ref);
31078         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
31079         return tag_ptr(ret_conv, true);
31080 }
31081
31082 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_KeysManager_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
31083         LDKKeysManager this_obj_conv;
31084         this_obj_conv.inner = untag_ptr(this_obj);
31085         this_obj_conv.is_owned = ptr_is_owned(this_obj);
31086         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31087         KeysManager_free(this_obj_conv);
31088 }
31089
31090 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) {
31091         unsigned char seed_arr[32];
31092         CHECK((*env)->GetArrayLength(env, seed) == 32);
31093         (*env)->GetByteArrayRegion(env, seed, 0, 32, seed_arr);
31094         unsigned char (*seed_ref)[32] = &seed_arr;
31095         LDKKeysManager ret_var = KeysManager_new(seed_ref, starting_time_secs, starting_time_nanos);
31096         int64_t ret_ref = 0;
31097         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31098         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
31099         return ret_ref;
31100 }
31101
31102 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) {
31103         LDKKeysManager this_arg_conv;
31104         this_arg_conv.inner = untag_ptr(this_arg);
31105         this_arg_conv.is_owned = ptr_is_owned(this_arg);
31106         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31107         this_arg_conv.is_owned = false;
31108         unsigned char params_arr[32];
31109         CHECK((*env)->GetArrayLength(env, params) == 32);
31110         (*env)->GetByteArrayRegion(env, params, 0, 32, params_arr);
31111         unsigned char (*params_ref)[32] = &params_arr;
31112         LDKInMemorySigner ret_var = KeysManager_derive_channel_keys(&this_arg_conv, channel_value_satoshis, params_ref);
31113         int64_t ret_ref = 0;
31114         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31115         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
31116         return ret_ref;
31117 }
31118
31119 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) {
31120         LDKKeysManager this_arg_conv;
31121         this_arg_conv.inner = untag_ptr(this_arg);
31122         this_arg_conv.is_owned = ptr_is_owned(this_arg);
31123         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31124         this_arg_conv.is_owned = false;
31125         LDKCVec_SpendableOutputDescriptorZ descriptors_constr;
31126         descriptors_constr.datalen = (*env)->GetArrayLength(env, descriptors);
31127         if (descriptors_constr.datalen > 0)
31128                 descriptors_constr.data = MALLOC(descriptors_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
31129         else
31130                 descriptors_constr.data = NULL;
31131         int64_t* descriptors_vals = (*env)->GetLongArrayElements (env, descriptors, NULL);
31132         for (size_t b = 0; b < descriptors_constr.datalen; b++) {
31133                 int64_t descriptors_conv_27 = descriptors_vals[b];
31134                 void* descriptors_conv_27_ptr = untag_ptr(descriptors_conv_27);
31135                 CHECK_ACCESS(descriptors_conv_27_ptr);
31136                 LDKSpendableOutputDescriptor descriptors_conv_27_conv = *(LDKSpendableOutputDescriptor*)(descriptors_conv_27_ptr);
31137                 descriptors_conv_27_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)untag_ptr(descriptors_conv_27));
31138                 descriptors_constr.data[b] = descriptors_conv_27_conv;
31139         }
31140         (*env)->ReleaseLongArrayElements(env, descriptors, descriptors_vals, 0);
31141         LDKCVec_TxOutZ outputs_constr;
31142         outputs_constr.datalen = (*env)->GetArrayLength(env, outputs);
31143         if (outputs_constr.datalen > 0)
31144                 outputs_constr.data = MALLOC(outputs_constr.datalen * sizeof(LDKTxOut), "LDKCVec_TxOutZ Elements");
31145         else
31146                 outputs_constr.data = NULL;
31147         int64_t* outputs_vals = (*env)->GetLongArrayElements (env, outputs, NULL);
31148         for (size_t h = 0; h < outputs_constr.datalen; h++) {
31149                 int64_t outputs_conv_7 = outputs_vals[h];
31150                 void* outputs_conv_7_ptr = untag_ptr(outputs_conv_7);
31151                 CHECK_ACCESS(outputs_conv_7_ptr);
31152                 LDKTxOut outputs_conv_7_conv = *(LDKTxOut*)(outputs_conv_7_ptr);
31153                 outputs_conv_7_conv = TxOut_clone((LDKTxOut*)untag_ptr(outputs_conv_7));
31154                 outputs_constr.data[h] = outputs_conv_7_conv;
31155         }
31156         (*env)->ReleaseLongArrayElements(env, outputs, outputs_vals, 0);
31157         LDKCVec_u8Z change_destination_script_ref;
31158         change_destination_script_ref.datalen = (*env)->GetArrayLength(env, change_destination_script);
31159         change_destination_script_ref.data = MALLOC(change_destination_script_ref.datalen, "LDKCVec_u8Z Bytes");
31160         (*env)->GetByteArrayRegion(env, change_destination_script, 0, change_destination_script_ref.datalen, change_destination_script_ref.data);
31161         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
31162         *ret_conv = KeysManager_spend_spendable_outputs(&this_arg_conv, descriptors_constr, outputs_constr, change_destination_script_ref, feerate_sat_per_1000_weight);
31163         return tag_ptr(ret_conv, true);
31164 }
31165
31166 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_KeysManager_1as_1KeysInterface(JNIEnv *env, jclass clz, int64_t this_arg) {
31167         LDKKeysManager this_arg_conv;
31168         this_arg_conv.inner = untag_ptr(this_arg);
31169         this_arg_conv.is_owned = ptr_is_owned(this_arg);
31170         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31171         this_arg_conv.is_owned = false;
31172         LDKKeysInterface* ret_ret = MALLOC(sizeof(LDKKeysInterface), "LDKKeysInterface");
31173         *ret_ret = KeysManager_as_KeysInterface(&this_arg_conv);
31174         return tag_ptr(ret_ret, true);
31175 }
31176
31177 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PhantomKeysManager_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
31178         LDKPhantomKeysManager this_obj_conv;
31179         this_obj_conv.inner = untag_ptr(this_obj);
31180         this_obj_conv.is_owned = ptr_is_owned(this_obj);
31181         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31182         PhantomKeysManager_free(this_obj_conv);
31183 }
31184
31185 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PhantomKeysManager_1as_1KeysInterface(JNIEnv *env, jclass clz, int64_t this_arg) {
31186         LDKPhantomKeysManager this_arg_conv;
31187         this_arg_conv.inner = untag_ptr(this_arg);
31188         this_arg_conv.is_owned = ptr_is_owned(this_arg);
31189         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31190         this_arg_conv.is_owned = false;
31191         LDKKeysInterface* ret_ret = MALLOC(sizeof(LDKKeysInterface), "LDKKeysInterface");
31192         *ret_ret = PhantomKeysManager_as_KeysInterface(&this_arg_conv);
31193         return tag_ptr(ret_ret, true);
31194 }
31195
31196 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) {
31197         unsigned char seed_arr[32];
31198         CHECK((*env)->GetArrayLength(env, seed) == 32);
31199         (*env)->GetByteArrayRegion(env, seed, 0, 32, seed_arr);
31200         unsigned char (*seed_ref)[32] = &seed_arr;
31201         unsigned char cross_node_seed_arr[32];
31202         CHECK((*env)->GetArrayLength(env, cross_node_seed) == 32);
31203         (*env)->GetByteArrayRegion(env, cross_node_seed, 0, 32, cross_node_seed_arr);
31204         unsigned char (*cross_node_seed_ref)[32] = &cross_node_seed_arr;
31205         LDKPhantomKeysManager ret_var = PhantomKeysManager_new(seed_ref, starting_time_secs, starting_time_nanos, cross_node_seed_ref);
31206         int64_t ret_ref = 0;
31207         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31208         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
31209         return ret_ref;
31210 }
31211
31212 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) {
31213         LDKPhantomKeysManager this_arg_conv;
31214         this_arg_conv.inner = untag_ptr(this_arg);
31215         this_arg_conv.is_owned = ptr_is_owned(this_arg);
31216         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31217         this_arg_conv.is_owned = false;
31218         LDKCVec_SpendableOutputDescriptorZ descriptors_constr;
31219         descriptors_constr.datalen = (*env)->GetArrayLength(env, descriptors);
31220         if (descriptors_constr.datalen > 0)
31221                 descriptors_constr.data = MALLOC(descriptors_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
31222         else
31223                 descriptors_constr.data = NULL;
31224         int64_t* descriptors_vals = (*env)->GetLongArrayElements (env, descriptors, NULL);
31225         for (size_t b = 0; b < descriptors_constr.datalen; b++) {
31226                 int64_t descriptors_conv_27 = descriptors_vals[b];
31227                 void* descriptors_conv_27_ptr = untag_ptr(descriptors_conv_27);
31228                 CHECK_ACCESS(descriptors_conv_27_ptr);
31229                 LDKSpendableOutputDescriptor descriptors_conv_27_conv = *(LDKSpendableOutputDescriptor*)(descriptors_conv_27_ptr);
31230                 descriptors_conv_27_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)untag_ptr(descriptors_conv_27));
31231                 descriptors_constr.data[b] = descriptors_conv_27_conv;
31232         }
31233         (*env)->ReleaseLongArrayElements(env, descriptors, descriptors_vals, 0);
31234         LDKCVec_TxOutZ outputs_constr;
31235         outputs_constr.datalen = (*env)->GetArrayLength(env, outputs);
31236         if (outputs_constr.datalen > 0)
31237                 outputs_constr.data = MALLOC(outputs_constr.datalen * sizeof(LDKTxOut), "LDKCVec_TxOutZ Elements");
31238         else
31239                 outputs_constr.data = NULL;
31240         int64_t* outputs_vals = (*env)->GetLongArrayElements (env, outputs, NULL);
31241         for (size_t h = 0; h < outputs_constr.datalen; h++) {
31242                 int64_t outputs_conv_7 = outputs_vals[h];
31243                 void* outputs_conv_7_ptr = untag_ptr(outputs_conv_7);
31244                 CHECK_ACCESS(outputs_conv_7_ptr);
31245                 LDKTxOut outputs_conv_7_conv = *(LDKTxOut*)(outputs_conv_7_ptr);
31246                 outputs_conv_7_conv = TxOut_clone((LDKTxOut*)untag_ptr(outputs_conv_7));
31247                 outputs_constr.data[h] = outputs_conv_7_conv;
31248         }
31249         (*env)->ReleaseLongArrayElements(env, outputs, outputs_vals, 0);
31250         LDKCVec_u8Z change_destination_script_ref;
31251         change_destination_script_ref.datalen = (*env)->GetArrayLength(env, change_destination_script);
31252         change_destination_script_ref.data = MALLOC(change_destination_script_ref.datalen, "LDKCVec_u8Z Bytes");
31253         (*env)->GetByteArrayRegion(env, change_destination_script, 0, change_destination_script_ref.datalen, change_destination_script_ref.data);
31254         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
31255         *ret_conv = PhantomKeysManager_spend_spendable_outputs(&this_arg_conv, descriptors_constr, outputs_constr, change_destination_script_ref, feerate_sat_per_1000_weight);
31256         return tag_ptr(ret_conv, true);
31257 }
31258
31259 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) {
31260         LDKPhantomKeysManager this_arg_conv;
31261         this_arg_conv.inner = untag_ptr(this_arg);
31262         this_arg_conv.is_owned = ptr_is_owned(this_arg);
31263         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31264         this_arg_conv.is_owned = false;
31265         unsigned char params_arr[32];
31266         CHECK((*env)->GetArrayLength(env, params) == 32);
31267         (*env)->GetByteArrayRegion(env, params, 0, 32, params_arr);
31268         unsigned char (*params_ref)[32] = &params_arr;
31269         LDKInMemorySigner ret_var = PhantomKeysManager_derive_channel_keys(&this_arg_conv, channel_value_satoshis, params_ref);
31270         int64_t ret_ref = 0;
31271         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31272         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
31273         return ret_ref;
31274 }
31275
31276 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
31277         LDKChannelManager this_obj_conv;
31278         this_obj_conv.inner = untag_ptr(this_obj);
31279         this_obj_conv.is_owned = ptr_is_owned(this_obj);
31280         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31281         ChannelManager_free(this_obj_conv);
31282 }
31283
31284 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
31285         LDKChainParameters this_obj_conv;
31286         this_obj_conv.inner = untag_ptr(this_obj);
31287         this_obj_conv.is_owned = ptr_is_owned(this_obj);
31288         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31289         ChainParameters_free(this_obj_conv);
31290 }
31291
31292 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ChainParameters_1get_1network(JNIEnv *env, jclass clz, int64_t this_ptr) {
31293         LDKChainParameters this_ptr_conv;
31294         this_ptr_conv.inner = untag_ptr(this_ptr);
31295         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31296         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31297         this_ptr_conv.is_owned = false;
31298         jclass ret_conv = LDKNetwork_to_java(env, ChainParameters_get_network(&this_ptr_conv));
31299         return ret_conv;
31300 }
31301
31302 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainParameters_1set_1network(JNIEnv *env, jclass clz, int64_t this_ptr, jclass val) {
31303         LDKChainParameters this_ptr_conv;
31304         this_ptr_conv.inner = untag_ptr(this_ptr);
31305         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31306         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31307         this_ptr_conv.is_owned = false;
31308         LDKNetwork val_conv = LDKNetwork_from_java(env, val);
31309         ChainParameters_set_network(&this_ptr_conv, val_conv);
31310 }
31311
31312 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainParameters_1get_1best_1block(JNIEnv *env, jclass clz, int64_t this_ptr) {
31313         LDKChainParameters this_ptr_conv;
31314         this_ptr_conv.inner = untag_ptr(this_ptr);
31315         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31316         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31317         this_ptr_conv.is_owned = false;
31318         LDKBestBlock ret_var = ChainParameters_get_best_block(&this_ptr_conv);
31319         int64_t ret_ref = 0;
31320         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31321         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
31322         return ret_ref;
31323 }
31324
31325 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainParameters_1set_1best_1block(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
31326         LDKChainParameters this_ptr_conv;
31327         this_ptr_conv.inner = untag_ptr(this_ptr);
31328         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31329         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31330         this_ptr_conv.is_owned = false;
31331         LDKBestBlock val_conv;
31332         val_conv.inner = untag_ptr(val);
31333         val_conv.is_owned = ptr_is_owned(val);
31334         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
31335         val_conv = BestBlock_clone(&val_conv);
31336         ChainParameters_set_best_block(&this_ptr_conv, val_conv);
31337 }
31338
31339 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainParameters_1new(JNIEnv *env, jclass clz, jclass network_arg, int64_t best_block_arg) {
31340         LDKNetwork network_arg_conv = LDKNetwork_from_java(env, network_arg);
31341         LDKBestBlock best_block_arg_conv;
31342         best_block_arg_conv.inner = untag_ptr(best_block_arg);
31343         best_block_arg_conv.is_owned = ptr_is_owned(best_block_arg);
31344         CHECK_INNER_FIELD_ACCESS_OR_NULL(best_block_arg_conv);
31345         best_block_arg_conv = BestBlock_clone(&best_block_arg_conv);
31346         LDKChainParameters ret_var = ChainParameters_new(network_arg_conv, best_block_arg_conv);
31347         int64_t ret_ref = 0;
31348         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31349         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
31350         return ret_ref;
31351 }
31352
31353 static inline uint64_t ChainParameters_clone_ptr(LDKChainParameters *NONNULL_PTR arg) {
31354         LDKChainParameters ret_var = ChainParameters_clone(arg);
31355         int64_t ret_ref = 0;
31356         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31357         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
31358         return ret_ref;
31359 }
31360 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainParameters_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
31361         LDKChainParameters arg_conv;
31362         arg_conv.inner = untag_ptr(arg);
31363         arg_conv.is_owned = ptr_is_owned(arg);
31364         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
31365         arg_conv.is_owned = false;
31366         int64_t ret_conv = ChainParameters_clone_ptr(&arg_conv);
31367         return ret_conv;
31368 }
31369
31370 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainParameters_1clone(JNIEnv *env, jclass clz, int64_t orig) {
31371         LDKChainParameters orig_conv;
31372         orig_conv.inner = untag_ptr(orig);
31373         orig_conv.is_owned = ptr_is_owned(orig);
31374         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
31375         orig_conv.is_owned = false;
31376         LDKChainParameters ret_var = ChainParameters_clone(&orig_conv);
31377         int64_t ret_ref = 0;
31378         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31379         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
31380         return ret_ref;
31381 }
31382
31383 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
31384         LDKCounterpartyForwardingInfo this_obj_conv;
31385         this_obj_conv.inner = untag_ptr(this_obj);
31386         this_obj_conv.is_owned = ptr_is_owned(this_obj);
31387         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31388         CounterpartyForwardingInfo_free(this_obj_conv);
31389 }
31390
31391 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1get_1fee_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
31392         LDKCounterpartyForwardingInfo this_ptr_conv;
31393         this_ptr_conv.inner = untag_ptr(this_ptr);
31394         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31395         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31396         this_ptr_conv.is_owned = false;
31397         int32_t ret_conv = CounterpartyForwardingInfo_get_fee_base_msat(&this_ptr_conv);
31398         return ret_conv;
31399 }
31400
31401 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1set_1fee_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
31402         LDKCounterpartyForwardingInfo this_ptr_conv;
31403         this_ptr_conv.inner = untag_ptr(this_ptr);
31404         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31405         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31406         this_ptr_conv.is_owned = false;
31407         CounterpartyForwardingInfo_set_fee_base_msat(&this_ptr_conv, val);
31408 }
31409
31410 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1get_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr) {
31411         LDKCounterpartyForwardingInfo this_ptr_conv;
31412         this_ptr_conv.inner = untag_ptr(this_ptr);
31413         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31414         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31415         this_ptr_conv.is_owned = false;
31416         int32_t ret_conv = CounterpartyForwardingInfo_get_fee_proportional_millionths(&this_ptr_conv);
31417         return ret_conv;
31418 }
31419
31420 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1set_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
31421         LDKCounterpartyForwardingInfo this_ptr_conv;
31422         this_ptr_conv.inner = untag_ptr(this_ptr);
31423         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31424         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31425         this_ptr_conv.is_owned = false;
31426         CounterpartyForwardingInfo_set_fee_proportional_millionths(&this_ptr_conv, val);
31427 }
31428
31429 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
31430         LDKCounterpartyForwardingInfo this_ptr_conv;
31431         this_ptr_conv.inner = untag_ptr(this_ptr);
31432         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31433         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31434         this_ptr_conv.is_owned = false;
31435         int16_t ret_conv = CounterpartyForwardingInfo_get_cltv_expiry_delta(&this_ptr_conv);
31436         return ret_conv;
31437 }
31438
31439 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
31440         LDKCounterpartyForwardingInfo this_ptr_conv;
31441         this_ptr_conv.inner = untag_ptr(this_ptr);
31442         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31443         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31444         this_ptr_conv.is_owned = false;
31445         CounterpartyForwardingInfo_set_cltv_expiry_delta(&this_ptr_conv, val);
31446 }
31447
31448 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) {
31449         LDKCounterpartyForwardingInfo ret_var = CounterpartyForwardingInfo_new(fee_base_msat_arg, fee_proportional_millionths_arg, cltv_expiry_delta_arg);
31450         int64_t ret_ref = 0;
31451         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31452         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
31453         return ret_ref;
31454 }
31455
31456 static inline uint64_t CounterpartyForwardingInfo_clone_ptr(LDKCounterpartyForwardingInfo *NONNULL_PTR arg) {
31457         LDKCounterpartyForwardingInfo ret_var = CounterpartyForwardingInfo_clone(arg);
31458         int64_t ret_ref = 0;
31459         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31460         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
31461         return ret_ref;
31462 }
31463 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
31464         LDKCounterpartyForwardingInfo arg_conv;
31465         arg_conv.inner = untag_ptr(arg);
31466         arg_conv.is_owned = ptr_is_owned(arg);
31467         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
31468         arg_conv.is_owned = false;
31469         int64_t ret_conv = CounterpartyForwardingInfo_clone_ptr(&arg_conv);
31470         return ret_conv;
31471 }
31472
31473 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
31474         LDKCounterpartyForwardingInfo orig_conv;
31475         orig_conv.inner = untag_ptr(orig);
31476         orig_conv.is_owned = ptr_is_owned(orig);
31477         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
31478         orig_conv.is_owned = false;
31479         LDKCounterpartyForwardingInfo ret_var = CounterpartyForwardingInfo_clone(&orig_conv);
31480         int64_t ret_ref = 0;
31481         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31482         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
31483         return ret_ref;
31484 }
31485
31486 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
31487         LDKChannelCounterparty this_obj_conv;
31488         this_obj_conv.inner = untag_ptr(this_obj);
31489         this_obj_conv.is_owned = ptr_is_owned(this_obj);
31490         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31491         ChannelCounterparty_free(this_obj_conv);
31492 }
31493
31494 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1get_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
31495         LDKChannelCounterparty this_ptr_conv;
31496         this_ptr_conv.inner = untag_ptr(this_ptr);
31497         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31498         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31499         this_ptr_conv.is_owned = false;
31500         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
31501         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelCounterparty_get_node_id(&this_ptr_conv).compressed_form);
31502         return ret_arr;
31503 }
31504
31505 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1set_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
31506         LDKChannelCounterparty this_ptr_conv;
31507         this_ptr_conv.inner = untag_ptr(this_ptr);
31508         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31509         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31510         this_ptr_conv.is_owned = false;
31511         LDKPublicKey val_ref;
31512         CHECK((*env)->GetArrayLength(env, val) == 33);
31513         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
31514         ChannelCounterparty_set_node_id(&this_ptr_conv, val_ref);
31515 }
31516
31517 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
31518         LDKChannelCounterparty this_ptr_conv;
31519         this_ptr_conv.inner = untag_ptr(this_ptr);
31520         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31521         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31522         this_ptr_conv.is_owned = false;
31523         LDKInitFeatures ret_var = ChannelCounterparty_get_features(&this_ptr_conv);
31524         int64_t ret_ref = 0;
31525         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31526         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
31527         return ret_ref;
31528 }
31529
31530 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
31531         LDKChannelCounterparty this_ptr_conv;
31532         this_ptr_conv.inner = untag_ptr(this_ptr);
31533         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31534         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31535         this_ptr_conv.is_owned = false;
31536         LDKInitFeatures val_conv;
31537         val_conv.inner = untag_ptr(val);
31538         val_conv.is_owned = ptr_is_owned(val);
31539         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
31540         val_conv = InitFeatures_clone(&val_conv);
31541         ChannelCounterparty_set_features(&this_ptr_conv, val_conv);
31542 }
31543
31544 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1get_1unspendable_1punishment_1reserve(JNIEnv *env, jclass clz, int64_t this_ptr) {
31545         LDKChannelCounterparty this_ptr_conv;
31546         this_ptr_conv.inner = untag_ptr(this_ptr);
31547         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31548         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31549         this_ptr_conv.is_owned = false;
31550         int64_t ret_conv = ChannelCounterparty_get_unspendable_punishment_reserve(&this_ptr_conv);
31551         return ret_conv;
31552 }
31553
31554 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1set_1unspendable_1punishment_1reserve(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
31555         LDKChannelCounterparty this_ptr_conv;
31556         this_ptr_conv.inner = untag_ptr(this_ptr);
31557         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31558         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31559         this_ptr_conv.is_owned = false;
31560         ChannelCounterparty_set_unspendable_punishment_reserve(&this_ptr_conv, val);
31561 }
31562
31563 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1get_1forwarding_1info(JNIEnv *env, jclass clz, int64_t this_ptr) {
31564         LDKChannelCounterparty this_ptr_conv;
31565         this_ptr_conv.inner = untag_ptr(this_ptr);
31566         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31567         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31568         this_ptr_conv.is_owned = false;
31569         LDKCounterpartyForwardingInfo ret_var = ChannelCounterparty_get_forwarding_info(&this_ptr_conv);
31570         int64_t ret_ref = 0;
31571         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31572         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
31573         return ret_ref;
31574 }
31575
31576 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1set_1forwarding_1info(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
31577         LDKChannelCounterparty this_ptr_conv;
31578         this_ptr_conv.inner = untag_ptr(this_ptr);
31579         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31580         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31581         this_ptr_conv.is_owned = false;
31582         LDKCounterpartyForwardingInfo val_conv;
31583         val_conv.inner = untag_ptr(val);
31584         val_conv.is_owned = ptr_is_owned(val);
31585         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
31586         val_conv = CounterpartyForwardingInfo_clone(&val_conv);
31587         ChannelCounterparty_set_forwarding_info(&this_ptr_conv, val_conv);
31588 }
31589
31590 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1get_1outbound_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
31591         LDKChannelCounterparty this_ptr_conv;
31592         this_ptr_conv.inner = untag_ptr(this_ptr);
31593         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31594         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31595         this_ptr_conv.is_owned = false;
31596         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
31597         *ret_copy = ChannelCounterparty_get_outbound_htlc_minimum_msat(&this_ptr_conv);
31598         int64_t ret_ref = tag_ptr(ret_copy, true);
31599         return ret_ref;
31600 }
31601
31602 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) {
31603         LDKChannelCounterparty this_ptr_conv;
31604         this_ptr_conv.inner = untag_ptr(this_ptr);
31605         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31606         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31607         this_ptr_conv.is_owned = false;
31608         void* val_ptr = untag_ptr(val);
31609         CHECK_ACCESS(val_ptr);
31610         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
31611         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(val));
31612         ChannelCounterparty_set_outbound_htlc_minimum_msat(&this_ptr_conv, val_conv);
31613 }
31614
31615 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1get_1outbound_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
31616         LDKChannelCounterparty this_ptr_conv;
31617         this_ptr_conv.inner = untag_ptr(this_ptr);
31618         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31619         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31620         this_ptr_conv.is_owned = false;
31621         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
31622         *ret_copy = ChannelCounterparty_get_outbound_htlc_maximum_msat(&this_ptr_conv);
31623         int64_t ret_ref = tag_ptr(ret_copy, true);
31624         return ret_ref;
31625 }
31626
31627 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) {
31628         LDKChannelCounterparty this_ptr_conv;
31629         this_ptr_conv.inner = untag_ptr(this_ptr);
31630         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31631         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31632         this_ptr_conv.is_owned = false;
31633         void* val_ptr = untag_ptr(val);
31634         CHECK_ACCESS(val_ptr);
31635         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
31636         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(val));
31637         ChannelCounterparty_set_outbound_htlc_maximum_msat(&this_ptr_conv, val_conv);
31638 }
31639
31640 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) {
31641         LDKPublicKey node_id_arg_ref;
31642         CHECK((*env)->GetArrayLength(env, node_id_arg) == 33);
31643         (*env)->GetByteArrayRegion(env, node_id_arg, 0, 33, node_id_arg_ref.compressed_form);
31644         LDKInitFeatures features_arg_conv;
31645         features_arg_conv.inner = untag_ptr(features_arg);
31646         features_arg_conv.is_owned = ptr_is_owned(features_arg);
31647         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_arg_conv);
31648         features_arg_conv = InitFeatures_clone(&features_arg_conv);
31649         LDKCounterpartyForwardingInfo forwarding_info_arg_conv;
31650         forwarding_info_arg_conv.inner = untag_ptr(forwarding_info_arg);
31651         forwarding_info_arg_conv.is_owned = ptr_is_owned(forwarding_info_arg);
31652         CHECK_INNER_FIELD_ACCESS_OR_NULL(forwarding_info_arg_conv);
31653         forwarding_info_arg_conv = CounterpartyForwardingInfo_clone(&forwarding_info_arg_conv);
31654         void* outbound_htlc_minimum_msat_arg_ptr = untag_ptr(outbound_htlc_minimum_msat_arg);
31655         CHECK_ACCESS(outbound_htlc_minimum_msat_arg_ptr);
31656         LDKCOption_u64Z outbound_htlc_minimum_msat_arg_conv = *(LDKCOption_u64Z*)(outbound_htlc_minimum_msat_arg_ptr);
31657         outbound_htlc_minimum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(outbound_htlc_minimum_msat_arg));
31658         void* outbound_htlc_maximum_msat_arg_ptr = untag_ptr(outbound_htlc_maximum_msat_arg);
31659         CHECK_ACCESS(outbound_htlc_maximum_msat_arg_ptr);
31660         LDKCOption_u64Z outbound_htlc_maximum_msat_arg_conv = *(LDKCOption_u64Z*)(outbound_htlc_maximum_msat_arg_ptr);
31661         outbound_htlc_maximum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(outbound_htlc_maximum_msat_arg));
31662         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);
31663         int64_t ret_ref = 0;
31664         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31665         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
31666         return ret_ref;
31667 }
31668
31669 static inline uint64_t ChannelCounterparty_clone_ptr(LDKChannelCounterparty *NONNULL_PTR arg) {
31670         LDKChannelCounterparty ret_var = ChannelCounterparty_clone(arg);
31671         int64_t ret_ref = 0;
31672         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31673         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
31674         return ret_ref;
31675 }
31676 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
31677         LDKChannelCounterparty arg_conv;
31678         arg_conv.inner = untag_ptr(arg);
31679         arg_conv.is_owned = ptr_is_owned(arg);
31680         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
31681         arg_conv.is_owned = false;
31682         int64_t ret_conv = ChannelCounterparty_clone_ptr(&arg_conv);
31683         return ret_conv;
31684 }
31685
31686 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1clone(JNIEnv *env, jclass clz, int64_t orig) {
31687         LDKChannelCounterparty orig_conv;
31688         orig_conv.inner = untag_ptr(orig);
31689         orig_conv.is_owned = ptr_is_owned(orig);
31690         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
31691         orig_conv.is_owned = false;
31692         LDKChannelCounterparty ret_var = ChannelCounterparty_clone(&orig_conv);
31693         int64_t ret_ref = 0;
31694         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31695         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
31696         return ret_ref;
31697 }
31698
31699 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
31700         LDKChannelDetails this_obj_conv;
31701         this_obj_conv.inner = untag_ptr(this_obj);
31702         this_obj_conv.is_owned = ptr_is_owned(this_obj);
31703         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31704         ChannelDetails_free(this_obj_conv);
31705 }
31706
31707 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
31708         LDKChannelDetails this_ptr_conv;
31709         this_ptr_conv.inner = untag_ptr(this_ptr);
31710         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31711         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31712         this_ptr_conv.is_owned = false;
31713         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
31714         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ChannelDetails_get_channel_id(&this_ptr_conv));
31715         return ret_arr;
31716 }
31717
31718 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
31719         LDKChannelDetails this_ptr_conv;
31720         this_ptr_conv.inner = untag_ptr(this_ptr);
31721         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31722         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31723         this_ptr_conv.is_owned = false;
31724         LDKThirtyTwoBytes val_ref;
31725         CHECK((*env)->GetArrayLength(env, val) == 32);
31726         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
31727         ChannelDetails_set_channel_id(&this_ptr_conv, val_ref);
31728 }
31729
31730 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1counterparty(JNIEnv *env, jclass clz, int64_t this_ptr) {
31731         LDKChannelDetails this_ptr_conv;
31732         this_ptr_conv.inner = untag_ptr(this_ptr);
31733         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31734         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31735         this_ptr_conv.is_owned = false;
31736         LDKChannelCounterparty ret_var = ChannelDetails_get_counterparty(&this_ptr_conv);
31737         int64_t ret_ref = 0;
31738         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31739         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
31740         return ret_ref;
31741 }
31742
31743 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1counterparty(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
31744         LDKChannelDetails this_ptr_conv;
31745         this_ptr_conv.inner = untag_ptr(this_ptr);
31746         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31747         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31748         this_ptr_conv.is_owned = false;
31749         LDKChannelCounterparty val_conv;
31750         val_conv.inner = untag_ptr(val);
31751         val_conv.is_owned = ptr_is_owned(val);
31752         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
31753         val_conv = ChannelCounterparty_clone(&val_conv);
31754         ChannelDetails_set_counterparty(&this_ptr_conv, val_conv);
31755 }
31756
31757 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1funding_1txo(JNIEnv *env, jclass clz, int64_t this_ptr) {
31758         LDKChannelDetails this_ptr_conv;
31759         this_ptr_conv.inner = untag_ptr(this_ptr);
31760         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31761         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31762         this_ptr_conv.is_owned = false;
31763         LDKOutPoint ret_var = ChannelDetails_get_funding_txo(&this_ptr_conv);
31764         int64_t ret_ref = 0;
31765         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31766         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
31767         return ret_ref;
31768 }
31769
31770 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1funding_1txo(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
31771         LDKChannelDetails this_ptr_conv;
31772         this_ptr_conv.inner = untag_ptr(this_ptr);
31773         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31774         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31775         this_ptr_conv.is_owned = false;
31776         LDKOutPoint val_conv;
31777         val_conv.inner = untag_ptr(val);
31778         val_conv.is_owned = ptr_is_owned(val);
31779         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
31780         val_conv = OutPoint_clone(&val_conv);
31781         ChannelDetails_set_funding_txo(&this_ptr_conv, val_conv);
31782 }
31783
31784 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1channel_1type(JNIEnv *env, jclass clz, int64_t this_ptr) {
31785         LDKChannelDetails this_ptr_conv;
31786         this_ptr_conv.inner = untag_ptr(this_ptr);
31787         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31788         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31789         this_ptr_conv.is_owned = false;
31790         LDKChannelTypeFeatures ret_var = ChannelDetails_get_channel_type(&this_ptr_conv);
31791         int64_t ret_ref = 0;
31792         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31793         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
31794         return ret_ref;
31795 }
31796
31797 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1channel_1type(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
31798         LDKChannelDetails this_ptr_conv;
31799         this_ptr_conv.inner = untag_ptr(this_ptr);
31800         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31801         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31802         this_ptr_conv.is_owned = false;
31803         LDKChannelTypeFeatures val_conv;
31804         val_conv.inner = untag_ptr(val);
31805         val_conv.is_owned = ptr_is_owned(val);
31806         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
31807         val_conv = ChannelTypeFeatures_clone(&val_conv);
31808         ChannelDetails_set_channel_type(&this_ptr_conv, val_conv);
31809 }
31810
31811 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
31812         LDKChannelDetails this_ptr_conv;
31813         this_ptr_conv.inner = untag_ptr(this_ptr);
31814         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31815         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31816         this_ptr_conv.is_owned = false;
31817         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
31818         *ret_copy = ChannelDetails_get_short_channel_id(&this_ptr_conv);
31819         int64_t ret_ref = tag_ptr(ret_copy, true);
31820         return ret_ref;
31821 }
31822
31823 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
31824         LDKChannelDetails this_ptr_conv;
31825         this_ptr_conv.inner = untag_ptr(this_ptr);
31826         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31827         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31828         this_ptr_conv.is_owned = false;
31829         void* val_ptr = untag_ptr(val);
31830         CHECK_ACCESS(val_ptr);
31831         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
31832         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(val));
31833         ChannelDetails_set_short_channel_id(&this_ptr_conv, val_conv);
31834 }
31835
31836 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1outbound_1scid_1alias(JNIEnv *env, jclass clz, int64_t this_ptr) {
31837         LDKChannelDetails this_ptr_conv;
31838         this_ptr_conv.inner = untag_ptr(this_ptr);
31839         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31840         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31841         this_ptr_conv.is_owned = false;
31842         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
31843         *ret_copy = ChannelDetails_get_outbound_scid_alias(&this_ptr_conv);
31844         int64_t ret_ref = tag_ptr(ret_copy, true);
31845         return ret_ref;
31846 }
31847
31848 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1outbound_1scid_1alias(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
31849         LDKChannelDetails this_ptr_conv;
31850         this_ptr_conv.inner = untag_ptr(this_ptr);
31851         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31852         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31853         this_ptr_conv.is_owned = false;
31854         void* val_ptr = untag_ptr(val);
31855         CHECK_ACCESS(val_ptr);
31856         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
31857         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(val));
31858         ChannelDetails_set_outbound_scid_alias(&this_ptr_conv, val_conv);
31859 }
31860
31861 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1inbound_1scid_1alias(JNIEnv *env, jclass clz, int64_t this_ptr) {
31862         LDKChannelDetails this_ptr_conv;
31863         this_ptr_conv.inner = untag_ptr(this_ptr);
31864         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31865         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31866         this_ptr_conv.is_owned = false;
31867         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
31868         *ret_copy = ChannelDetails_get_inbound_scid_alias(&this_ptr_conv);
31869         int64_t ret_ref = tag_ptr(ret_copy, true);
31870         return ret_ref;
31871 }
31872
31873 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1inbound_1scid_1alias(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
31874         LDKChannelDetails this_ptr_conv;
31875         this_ptr_conv.inner = untag_ptr(this_ptr);
31876         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31877         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31878         this_ptr_conv.is_owned = false;
31879         void* val_ptr = untag_ptr(val);
31880         CHECK_ACCESS(val_ptr);
31881         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
31882         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(val));
31883         ChannelDetails_set_inbound_scid_alias(&this_ptr_conv, val_conv);
31884 }
31885
31886 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
31887         LDKChannelDetails this_ptr_conv;
31888         this_ptr_conv.inner = untag_ptr(this_ptr);
31889         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31890         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31891         this_ptr_conv.is_owned = false;
31892         int64_t ret_conv = ChannelDetails_get_channel_value_satoshis(&this_ptr_conv);
31893         return ret_conv;
31894 }
31895
31896 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
31897         LDKChannelDetails this_ptr_conv;
31898         this_ptr_conv.inner = untag_ptr(this_ptr);
31899         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31900         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31901         this_ptr_conv.is_owned = false;
31902         ChannelDetails_set_channel_value_satoshis(&this_ptr_conv, val);
31903 }
31904
31905 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1unspendable_1punishment_1reserve(JNIEnv *env, jclass clz, int64_t this_ptr) {
31906         LDKChannelDetails this_ptr_conv;
31907         this_ptr_conv.inner = untag_ptr(this_ptr);
31908         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31909         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31910         this_ptr_conv.is_owned = false;
31911         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
31912         *ret_copy = ChannelDetails_get_unspendable_punishment_reserve(&this_ptr_conv);
31913         int64_t ret_ref = tag_ptr(ret_copy, true);
31914         return ret_ref;
31915 }
31916
31917 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1unspendable_1punishment_1reserve(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
31918         LDKChannelDetails this_ptr_conv;
31919         this_ptr_conv.inner = untag_ptr(this_ptr);
31920         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31921         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31922         this_ptr_conv.is_owned = false;
31923         void* val_ptr = untag_ptr(val);
31924         CHECK_ACCESS(val_ptr);
31925         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
31926         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(val));
31927         ChannelDetails_set_unspendable_punishment_reserve(&this_ptr_conv, val_conv);
31928 }
31929
31930 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1user_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
31931         LDKChannelDetails this_ptr_conv;
31932         this_ptr_conv.inner = untag_ptr(this_ptr);
31933         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31934         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31935         this_ptr_conv.is_owned = false;
31936         int8_tArray ret_arr = (*env)->NewByteArray(env, 16);
31937         (*env)->SetByteArrayRegion(env, ret_arr, 0, 16, ChannelDetails_get_user_channel_id(&this_ptr_conv).le_bytes);
31938         return ret_arr;
31939 }
31940
31941 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1user_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
31942         LDKChannelDetails this_ptr_conv;
31943         this_ptr_conv.inner = untag_ptr(this_ptr);
31944         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31945         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31946         this_ptr_conv.is_owned = false;
31947         LDKU128 val_ref;
31948         CHECK((*env)->GetArrayLength(env, val) == 16);
31949         (*env)->GetByteArrayRegion(env, val, 0, 16, val_ref.le_bytes);
31950         ChannelDetails_set_user_channel_id(&this_ptr_conv, val_ref);
31951 }
31952
31953 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1balance_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
31954         LDKChannelDetails this_ptr_conv;
31955         this_ptr_conv.inner = untag_ptr(this_ptr);
31956         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31957         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31958         this_ptr_conv.is_owned = false;
31959         int64_t ret_conv = ChannelDetails_get_balance_msat(&this_ptr_conv);
31960         return ret_conv;
31961 }
31962
31963 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1balance_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
31964         LDKChannelDetails this_ptr_conv;
31965         this_ptr_conv.inner = untag_ptr(this_ptr);
31966         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31967         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31968         this_ptr_conv.is_owned = false;
31969         ChannelDetails_set_balance_msat(&this_ptr_conv, val);
31970 }
31971
31972 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1outbound_1capacity_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
31973         LDKChannelDetails this_ptr_conv;
31974         this_ptr_conv.inner = untag_ptr(this_ptr);
31975         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31976         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31977         this_ptr_conv.is_owned = false;
31978         int64_t ret_conv = ChannelDetails_get_outbound_capacity_msat(&this_ptr_conv);
31979         return ret_conv;
31980 }
31981
31982 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1outbound_1capacity_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
31983         LDKChannelDetails this_ptr_conv;
31984         this_ptr_conv.inner = untag_ptr(this_ptr);
31985         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31986         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31987         this_ptr_conv.is_owned = false;
31988         ChannelDetails_set_outbound_capacity_msat(&this_ptr_conv, val);
31989 }
31990
31991 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1next_1outbound_1htlc_1limit_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
31992         LDKChannelDetails this_ptr_conv;
31993         this_ptr_conv.inner = untag_ptr(this_ptr);
31994         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
31995         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31996         this_ptr_conv.is_owned = false;
31997         int64_t ret_conv = ChannelDetails_get_next_outbound_htlc_limit_msat(&this_ptr_conv);
31998         return ret_conv;
31999 }
32000
32001 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) {
32002         LDKChannelDetails this_ptr_conv;
32003         this_ptr_conv.inner = untag_ptr(this_ptr);
32004         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32005         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32006         this_ptr_conv.is_owned = false;
32007         ChannelDetails_set_next_outbound_htlc_limit_msat(&this_ptr_conv, val);
32008 }
32009
32010 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1inbound_1capacity_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
32011         LDKChannelDetails this_ptr_conv;
32012         this_ptr_conv.inner = untag_ptr(this_ptr);
32013         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32014         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32015         this_ptr_conv.is_owned = false;
32016         int64_t ret_conv = ChannelDetails_get_inbound_capacity_msat(&this_ptr_conv);
32017         return ret_conv;
32018 }
32019
32020 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1inbound_1capacity_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32021         LDKChannelDetails this_ptr_conv;
32022         this_ptr_conv.inner = untag_ptr(this_ptr);
32023         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32024         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32025         this_ptr_conv.is_owned = false;
32026         ChannelDetails_set_inbound_capacity_msat(&this_ptr_conv, val);
32027 }
32028
32029 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1confirmations_1required(JNIEnv *env, jclass clz, int64_t this_ptr) {
32030         LDKChannelDetails this_ptr_conv;
32031         this_ptr_conv.inner = untag_ptr(this_ptr);
32032         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32033         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32034         this_ptr_conv.is_owned = false;
32035         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
32036         *ret_copy = ChannelDetails_get_confirmations_required(&this_ptr_conv);
32037         int64_t ret_ref = tag_ptr(ret_copy, true);
32038         return ret_ref;
32039 }
32040
32041 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1confirmations_1required(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32042         LDKChannelDetails this_ptr_conv;
32043         this_ptr_conv.inner = untag_ptr(this_ptr);
32044         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32045         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32046         this_ptr_conv.is_owned = false;
32047         void* val_ptr = untag_ptr(val);
32048         CHECK_ACCESS(val_ptr);
32049         LDKCOption_u32Z val_conv = *(LDKCOption_u32Z*)(val_ptr);
32050         val_conv = COption_u32Z_clone((LDKCOption_u32Z*)untag_ptr(val));
32051         ChannelDetails_set_confirmations_required(&this_ptr_conv, val_conv);
32052 }
32053
32054 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1confirmations(JNIEnv *env, jclass clz, int64_t this_ptr) {
32055         LDKChannelDetails this_ptr_conv;
32056         this_ptr_conv.inner = untag_ptr(this_ptr);
32057         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32058         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32059         this_ptr_conv.is_owned = false;
32060         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
32061         *ret_copy = ChannelDetails_get_confirmations(&this_ptr_conv);
32062         int64_t ret_ref = tag_ptr(ret_copy, true);
32063         return ret_ref;
32064 }
32065
32066 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1confirmations(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32067         LDKChannelDetails this_ptr_conv;
32068         this_ptr_conv.inner = untag_ptr(this_ptr);
32069         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32070         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32071         this_ptr_conv.is_owned = false;
32072         void* val_ptr = untag_ptr(val);
32073         CHECK_ACCESS(val_ptr);
32074         LDKCOption_u32Z val_conv = *(LDKCOption_u32Z*)(val_ptr);
32075         val_conv = COption_u32Z_clone((LDKCOption_u32Z*)untag_ptr(val));
32076         ChannelDetails_set_confirmations(&this_ptr_conv, val_conv);
32077 }
32078
32079 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1force_1close_1spend_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
32080         LDKChannelDetails this_ptr_conv;
32081         this_ptr_conv.inner = untag_ptr(this_ptr);
32082         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32083         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32084         this_ptr_conv.is_owned = false;
32085         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
32086         *ret_copy = ChannelDetails_get_force_close_spend_delay(&this_ptr_conv);
32087         int64_t ret_ref = tag_ptr(ret_copy, true);
32088         return ret_ref;
32089 }
32090
32091 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) {
32092         LDKChannelDetails this_ptr_conv;
32093         this_ptr_conv.inner = untag_ptr(this_ptr);
32094         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32095         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32096         this_ptr_conv.is_owned = false;
32097         void* val_ptr = untag_ptr(val);
32098         CHECK_ACCESS(val_ptr);
32099         LDKCOption_u16Z val_conv = *(LDKCOption_u16Z*)(val_ptr);
32100         val_conv = COption_u16Z_clone((LDKCOption_u16Z*)untag_ptr(val));
32101         ChannelDetails_set_force_close_spend_delay(&this_ptr_conv, val_conv);
32102 }
32103
32104 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1is_1outbound(JNIEnv *env, jclass clz, int64_t this_ptr) {
32105         LDKChannelDetails this_ptr_conv;
32106         this_ptr_conv.inner = untag_ptr(this_ptr);
32107         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32108         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32109         this_ptr_conv.is_owned = false;
32110         jboolean ret_conv = ChannelDetails_get_is_outbound(&this_ptr_conv);
32111         return ret_conv;
32112 }
32113
32114 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1is_1outbound(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
32115         LDKChannelDetails this_ptr_conv;
32116         this_ptr_conv.inner = untag_ptr(this_ptr);
32117         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32118         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32119         this_ptr_conv.is_owned = false;
32120         ChannelDetails_set_is_outbound(&this_ptr_conv, val);
32121 }
32122
32123 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1is_1channel_1ready(JNIEnv *env, jclass clz, int64_t this_ptr) {
32124         LDKChannelDetails this_ptr_conv;
32125         this_ptr_conv.inner = untag_ptr(this_ptr);
32126         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32127         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32128         this_ptr_conv.is_owned = false;
32129         jboolean ret_conv = ChannelDetails_get_is_channel_ready(&this_ptr_conv);
32130         return ret_conv;
32131 }
32132
32133 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1is_1channel_1ready(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
32134         LDKChannelDetails this_ptr_conv;
32135         this_ptr_conv.inner = untag_ptr(this_ptr);
32136         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32137         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32138         this_ptr_conv.is_owned = false;
32139         ChannelDetails_set_is_channel_ready(&this_ptr_conv, val);
32140 }
32141
32142 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1is_1usable(JNIEnv *env, jclass clz, int64_t this_ptr) {
32143         LDKChannelDetails this_ptr_conv;
32144         this_ptr_conv.inner = untag_ptr(this_ptr);
32145         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32146         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32147         this_ptr_conv.is_owned = false;
32148         jboolean ret_conv = ChannelDetails_get_is_usable(&this_ptr_conv);
32149         return ret_conv;
32150 }
32151
32152 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1is_1usable(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
32153         LDKChannelDetails this_ptr_conv;
32154         this_ptr_conv.inner = untag_ptr(this_ptr);
32155         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32156         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32157         this_ptr_conv.is_owned = false;
32158         ChannelDetails_set_is_usable(&this_ptr_conv, val);
32159 }
32160
32161 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1is_1public(JNIEnv *env, jclass clz, int64_t this_ptr) {
32162         LDKChannelDetails this_ptr_conv;
32163         this_ptr_conv.inner = untag_ptr(this_ptr);
32164         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32165         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32166         this_ptr_conv.is_owned = false;
32167         jboolean ret_conv = ChannelDetails_get_is_public(&this_ptr_conv);
32168         return ret_conv;
32169 }
32170
32171 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1is_1public(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
32172         LDKChannelDetails this_ptr_conv;
32173         this_ptr_conv.inner = untag_ptr(this_ptr);
32174         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32175         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32176         this_ptr_conv.is_owned = false;
32177         ChannelDetails_set_is_public(&this_ptr_conv, val);
32178 }
32179
32180 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1inbound_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
32181         LDKChannelDetails this_ptr_conv;
32182         this_ptr_conv.inner = untag_ptr(this_ptr);
32183         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32184         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32185         this_ptr_conv.is_owned = false;
32186         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
32187         *ret_copy = ChannelDetails_get_inbound_htlc_minimum_msat(&this_ptr_conv);
32188         int64_t ret_ref = tag_ptr(ret_copy, true);
32189         return ret_ref;
32190 }
32191
32192 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) {
32193         LDKChannelDetails this_ptr_conv;
32194         this_ptr_conv.inner = untag_ptr(this_ptr);
32195         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32196         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32197         this_ptr_conv.is_owned = false;
32198         void* val_ptr = untag_ptr(val);
32199         CHECK_ACCESS(val_ptr);
32200         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
32201         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(val));
32202         ChannelDetails_set_inbound_htlc_minimum_msat(&this_ptr_conv, val_conv);
32203 }
32204
32205 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1inbound_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
32206         LDKChannelDetails this_ptr_conv;
32207         this_ptr_conv.inner = untag_ptr(this_ptr);
32208         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32209         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32210         this_ptr_conv.is_owned = false;
32211         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
32212         *ret_copy = ChannelDetails_get_inbound_htlc_maximum_msat(&this_ptr_conv);
32213         int64_t ret_ref = tag_ptr(ret_copy, true);
32214         return ret_ref;
32215 }
32216
32217 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) {
32218         LDKChannelDetails this_ptr_conv;
32219         this_ptr_conv.inner = untag_ptr(this_ptr);
32220         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32221         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32222         this_ptr_conv.is_owned = false;
32223         void* val_ptr = untag_ptr(val);
32224         CHECK_ACCESS(val_ptr);
32225         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
32226         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(val));
32227         ChannelDetails_set_inbound_htlc_maximum_msat(&this_ptr_conv, val_conv);
32228 }
32229
32230 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1config(JNIEnv *env, jclass clz, int64_t this_ptr) {
32231         LDKChannelDetails this_ptr_conv;
32232         this_ptr_conv.inner = untag_ptr(this_ptr);
32233         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32234         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32235         this_ptr_conv.is_owned = false;
32236         LDKChannelConfig ret_var = ChannelDetails_get_config(&this_ptr_conv);
32237         int64_t ret_ref = 0;
32238         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32239         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
32240         return ret_ref;
32241 }
32242
32243 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1config(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32244         LDKChannelDetails this_ptr_conv;
32245         this_ptr_conv.inner = untag_ptr(this_ptr);
32246         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32247         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32248         this_ptr_conv.is_owned = false;
32249         LDKChannelConfig val_conv;
32250         val_conv.inner = untag_ptr(val);
32251         val_conv.is_owned = ptr_is_owned(val);
32252         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
32253         val_conv = ChannelConfig_clone(&val_conv);
32254         ChannelDetails_set_config(&this_ptr_conv, val_conv);
32255 }
32256
32257 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, int8_tArray 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 confirmations_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) {
32258         LDKThirtyTwoBytes channel_id_arg_ref;
32259         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
32260         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
32261         LDKChannelCounterparty counterparty_arg_conv;
32262         counterparty_arg_conv.inner = untag_ptr(counterparty_arg);
32263         counterparty_arg_conv.is_owned = ptr_is_owned(counterparty_arg);
32264         CHECK_INNER_FIELD_ACCESS_OR_NULL(counterparty_arg_conv);
32265         counterparty_arg_conv = ChannelCounterparty_clone(&counterparty_arg_conv);
32266         LDKOutPoint funding_txo_arg_conv;
32267         funding_txo_arg_conv.inner = untag_ptr(funding_txo_arg);
32268         funding_txo_arg_conv.is_owned = ptr_is_owned(funding_txo_arg);
32269         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_arg_conv);
32270         funding_txo_arg_conv = OutPoint_clone(&funding_txo_arg_conv);
32271         LDKChannelTypeFeatures channel_type_arg_conv;
32272         channel_type_arg_conv.inner = untag_ptr(channel_type_arg);
32273         channel_type_arg_conv.is_owned = ptr_is_owned(channel_type_arg);
32274         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_type_arg_conv);
32275         channel_type_arg_conv = ChannelTypeFeatures_clone(&channel_type_arg_conv);
32276         void* short_channel_id_arg_ptr = untag_ptr(short_channel_id_arg);
32277         CHECK_ACCESS(short_channel_id_arg_ptr);
32278         LDKCOption_u64Z short_channel_id_arg_conv = *(LDKCOption_u64Z*)(short_channel_id_arg_ptr);
32279         short_channel_id_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(short_channel_id_arg));
32280         void* outbound_scid_alias_arg_ptr = untag_ptr(outbound_scid_alias_arg);
32281         CHECK_ACCESS(outbound_scid_alias_arg_ptr);
32282         LDKCOption_u64Z outbound_scid_alias_arg_conv = *(LDKCOption_u64Z*)(outbound_scid_alias_arg_ptr);
32283         outbound_scid_alias_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(outbound_scid_alias_arg));
32284         void* inbound_scid_alias_arg_ptr = untag_ptr(inbound_scid_alias_arg);
32285         CHECK_ACCESS(inbound_scid_alias_arg_ptr);
32286         LDKCOption_u64Z inbound_scid_alias_arg_conv = *(LDKCOption_u64Z*)(inbound_scid_alias_arg_ptr);
32287         inbound_scid_alias_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(inbound_scid_alias_arg));
32288         void* unspendable_punishment_reserve_arg_ptr = untag_ptr(unspendable_punishment_reserve_arg);
32289         CHECK_ACCESS(unspendable_punishment_reserve_arg_ptr);
32290         LDKCOption_u64Z unspendable_punishment_reserve_arg_conv = *(LDKCOption_u64Z*)(unspendable_punishment_reserve_arg_ptr);
32291         LDKU128 user_channel_id_arg_ref;
32292         CHECK((*env)->GetArrayLength(env, user_channel_id_arg) == 16);
32293         (*env)->GetByteArrayRegion(env, user_channel_id_arg, 0, 16, user_channel_id_arg_ref.le_bytes);
32294         void* confirmations_required_arg_ptr = untag_ptr(confirmations_required_arg);
32295         CHECK_ACCESS(confirmations_required_arg_ptr);
32296         LDKCOption_u32Z confirmations_required_arg_conv = *(LDKCOption_u32Z*)(confirmations_required_arg_ptr);
32297         confirmations_required_arg_conv = COption_u32Z_clone((LDKCOption_u32Z*)untag_ptr(confirmations_required_arg));
32298         void* confirmations_arg_ptr = untag_ptr(confirmations_arg);
32299         CHECK_ACCESS(confirmations_arg_ptr);
32300         LDKCOption_u32Z confirmations_arg_conv = *(LDKCOption_u32Z*)(confirmations_arg_ptr);
32301         confirmations_arg_conv = COption_u32Z_clone((LDKCOption_u32Z*)untag_ptr(confirmations_arg));
32302         void* force_close_spend_delay_arg_ptr = untag_ptr(force_close_spend_delay_arg);
32303         CHECK_ACCESS(force_close_spend_delay_arg_ptr);
32304         LDKCOption_u16Z force_close_spend_delay_arg_conv = *(LDKCOption_u16Z*)(force_close_spend_delay_arg_ptr);
32305         force_close_spend_delay_arg_conv = COption_u16Z_clone((LDKCOption_u16Z*)untag_ptr(force_close_spend_delay_arg));
32306         void* inbound_htlc_minimum_msat_arg_ptr = untag_ptr(inbound_htlc_minimum_msat_arg);
32307         CHECK_ACCESS(inbound_htlc_minimum_msat_arg_ptr);
32308         LDKCOption_u64Z inbound_htlc_minimum_msat_arg_conv = *(LDKCOption_u64Z*)(inbound_htlc_minimum_msat_arg_ptr);
32309         inbound_htlc_minimum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(inbound_htlc_minimum_msat_arg));
32310         void* inbound_htlc_maximum_msat_arg_ptr = untag_ptr(inbound_htlc_maximum_msat_arg);
32311         CHECK_ACCESS(inbound_htlc_maximum_msat_arg_ptr);
32312         LDKCOption_u64Z inbound_htlc_maximum_msat_arg_conv = *(LDKCOption_u64Z*)(inbound_htlc_maximum_msat_arg_ptr);
32313         inbound_htlc_maximum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(inbound_htlc_maximum_msat_arg));
32314         LDKChannelConfig config_arg_conv;
32315         config_arg_conv.inner = untag_ptr(config_arg);
32316         config_arg_conv.is_owned = ptr_is_owned(config_arg);
32317         CHECK_INNER_FIELD_ACCESS_OR_NULL(config_arg_conv);
32318         config_arg_conv = ChannelConfig_clone(&config_arg_conv);
32319         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_ref, balance_msat_arg, outbound_capacity_msat_arg, next_outbound_htlc_limit_msat_arg, inbound_capacity_msat_arg, confirmations_required_arg_conv, confirmations_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);
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 static inline uint64_t ChannelDetails_clone_ptr(LDKChannelDetails *NONNULL_PTR arg) {
32327         LDKChannelDetails ret_var = ChannelDetails_clone(arg);
32328         int64_t ret_ref = 0;
32329         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32330         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
32331         return ret_ref;
32332 }
32333 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
32334         LDKChannelDetails arg_conv;
32335         arg_conv.inner = untag_ptr(arg);
32336         arg_conv.is_owned = ptr_is_owned(arg);
32337         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
32338         arg_conv.is_owned = false;
32339         int64_t ret_conv = ChannelDetails_clone_ptr(&arg_conv);
32340         return ret_conv;
32341 }
32342
32343 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1clone(JNIEnv *env, jclass clz, int64_t orig) {
32344         LDKChannelDetails orig_conv;
32345         orig_conv.inner = untag_ptr(orig);
32346         orig_conv.is_owned = ptr_is_owned(orig);
32347         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
32348         orig_conv.is_owned = false;
32349         LDKChannelDetails ret_var = ChannelDetails_clone(&orig_conv);
32350         int64_t ret_ref = 0;
32351         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32352         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
32353         return ret_ref;
32354 }
32355
32356 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1inbound_1payment_1scid(JNIEnv *env, jclass clz, int64_t this_arg) {
32357         LDKChannelDetails this_arg_conv;
32358         this_arg_conv.inner = untag_ptr(this_arg);
32359         this_arg_conv.is_owned = ptr_is_owned(this_arg);
32360         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32361         this_arg_conv.is_owned = false;
32362         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
32363         *ret_copy = ChannelDetails_get_inbound_payment_scid(&this_arg_conv);
32364         int64_t ret_ref = tag_ptr(ret_copy, true);
32365         return ret_ref;
32366 }
32367
32368 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1outbound_1payment_1scid(JNIEnv *env, jclass clz, int64_t this_arg) {
32369         LDKChannelDetails this_arg_conv;
32370         this_arg_conv.inner = untag_ptr(this_arg);
32371         this_arg_conv.is_owned = ptr_is_owned(this_arg);
32372         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32373         this_arg_conv.is_owned = false;
32374         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
32375         *ret_copy = ChannelDetails_get_outbound_payment_scid(&this_arg_conv);
32376         int64_t ret_ref = tag_ptr(ret_copy, true);
32377         return ret_ref;
32378 }
32379
32380 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
32381         if (!ptr_is_owned(this_ptr)) return;
32382         void* this_ptr_ptr = untag_ptr(this_ptr);
32383         CHECK_ACCESS(this_ptr_ptr);
32384         LDKPaymentSendFailure this_ptr_conv = *(LDKPaymentSendFailure*)(this_ptr_ptr);
32385         FREE(untag_ptr(this_ptr));
32386         PaymentSendFailure_free(this_ptr_conv);
32387 }
32388
32389 static inline uint64_t PaymentSendFailure_clone_ptr(LDKPaymentSendFailure *NONNULL_PTR arg) {
32390         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
32391         *ret_copy = PaymentSendFailure_clone(arg);
32392         int64_t ret_ref = tag_ptr(ret_copy, true);
32393         return ret_ref;
32394 }
32395 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
32396         LDKPaymentSendFailure* arg_conv = (LDKPaymentSendFailure*)untag_ptr(arg);
32397         int64_t ret_conv = PaymentSendFailure_clone_ptr(arg_conv);
32398         return ret_conv;
32399 }
32400
32401 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1clone(JNIEnv *env, jclass clz, int64_t orig) {
32402         LDKPaymentSendFailure* orig_conv = (LDKPaymentSendFailure*)untag_ptr(orig);
32403         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
32404         *ret_copy = PaymentSendFailure_clone(orig_conv);
32405         int64_t ret_ref = tag_ptr(ret_copy, true);
32406         return ret_ref;
32407 }
32408
32409 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1parameter_1error(JNIEnv *env, jclass clz, int64_t a) {
32410         void* a_ptr = untag_ptr(a);
32411         CHECK_ACCESS(a_ptr);
32412         LDKAPIError a_conv = *(LDKAPIError*)(a_ptr);
32413         a_conv = APIError_clone((LDKAPIError*)untag_ptr(a));
32414         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
32415         *ret_copy = PaymentSendFailure_parameter_error(a_conv);
32416         int64_t ret_ref = tag_ptr(ret_copy, true);
32417         return ret_ref;
32418 }
32419
32420 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1path_1parameter_1error(JNIEnv *env, jclass clz, int64_tArray a) {
32421         LDKCVec_CResult_NoneAPIErrorZZ a_constr;
32422         a_constr.datalen = (*env)->GetArrayLength(env, a);
32423         if (a_constr.datalen > 0)
32424                 a_constr.data = MALLOC(a_constr.datalen * sizeof(LDKCResult_NoneAPIErrorZ), "LDKCVec_CResult_NoneAPIErrorZZ Elements");
32425         else
32426                 a_constr.data = NULL;
32427         int64_t* a_vals = (*env)->GetLongArrayElements (env, a, NULL);
32428         for (size_t w = 0; w < a_constr.datalen; w++) {
32429                 int64_t a_conv_22 = a_vals[w];
32430                 void* a_conv_22_ptr = untag_ptr(a_conv_22);
32431                 CHECK_ACCESS(a_conv_22_ptr);
32432                 LDKCResult_NoneAPIErrorZ a_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(a_conv_22_ptr);
32433                 a_conv_22_conv = CResult_NoneAPIErrorZ_clone((LDKCResult_NoneAPIErrorZ*)untag_ptr(a_conv_22));
32434                 a_constr.data[w] = a_conv_22_conv;
32435         }
32436         (*env)->ReleaseLongArrayElements(env, a, a_vals, 0);
32437         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
32438         *ret_copy = PaymentSendFailure_path_parameter_error(a_constr);
32439         int64_t ret_ref = tag_ptr(ret_copy, true);
32440         return ret_ref;
32441 }
32442
32443 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1all_1failed_1resend_1safe(JNIEnv *env, jclass clz, int64_tArray a) {
32444         LDKCVec_APIErrorZ a_constr;
32445         a_constr.datalen = (*env)->GetArrayLength(env, a);
32446         if (a_constr.datalen > 0)
32447                 a_constr.data = MALLOC(a_constr.datalen * sizeof(LDKAPIError), "LDKCVec_APIErrorZ Elements");
32448         else
32449                 a_constr.data = NULL;
32450         int64_t* a_vals = (*env)->GetLongArrayElements (env, a, NULL);
32451         for (size_t k = 0; k < a_constr.datalen; k++) {
32452                 int64_t a_conv_10 = a_vals[k];
32453                 void* a_conv_10_ptr = untag_ptr(a_conv_10);
32454                 CHECK_ACCESS(a_conv_10_ptr);
32455                 LDKAPIError a_conv_10_conv = *(LDKAPIError*)(a_conv_10_ptr);
32456                 a_conv_10_conv = APIError_clone((LDKAPIError*)untag_ptr(a_conv_10));
32457                 a_constr.data[k] = a_conv_10_conv;
32458         }
32459         (*env)->ReleaseLongArrayElements(env, a, a_vals, 0);
32460         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
32461         *ret_copy = PaymentSendFailure_all_failed_resend_safe(a_constr);
32462         int64_t ret_ref = tag_ptr(ret_copy, true);
32463         return ret_ref;
32464 }
32465
32466 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1duplicate_1payment(JNIEnv *env, jclass clz) {
32467         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
32468         *ret_copy = PaymentSendFailure_duplicate_payment();
32469         int64_t ret_ref = tag_ptr(ret_copy, true);
32470         return ret_ref;
32471 }
32472
32473 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) {
32474         LDKCVec_CResult_NoneAPIErrorZZ results_constr;
32475         results_constr.datalen = (*env)->GetArrayLength(env, results);
32476         if (results_constr.datalen > 0)
32477                 results_constr.data = MALLOC(results_constr.datalen * sizeof(LDKCResult_NoneAPIErrorZ), "LDKCVec_CResult_NoneAPIErrorZZ Elements");
32478         else
32479                 results_constr.data = NULL;
32480         int64_t* results_vals = (*env)->GetLongArrayElements (env, results, NULL);
32481         for (size_t w = 0; w < results_constr.datalen; w++) {
32482                 int64_t results_conv_22 = results_vals[w];
32483                 void* results_conv_22_ptr = untag_ptr(results_conv_22);
32484                 CHECK_ACCESS(results_conv_22_ptr);
32485                 LDKCResult_NoneAPIErrorZ results_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(results_conv_22_ptr);
32486                 results_constr.data[w] = results_conv_22_conv;
32487         }
32488         (*env)->ReleaseLongArrayElements(env, results, results_vals, 0);
32489         LDKRouteParameters failed_paths_retry_conv;
32490         failed_paths_retry_conv.inner = untag_ptr(failed_paths_retry);
32491         failed_paths_retry_conv.is_owned = ptr_is_owned(failed_paths_retry);
32492         CHECK_INNER_FIELD_ACCESS_OR_NULL(failed_paths_retry_conv);
32493         failed_paths_retry_conv = RouteParameters_clone(&failed_paths_retry_conv);
32494         LDKThirtyTwoBytes payment_id_ref;
32495         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
32496         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
32497         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
32498         *ret_copy = PaymentSendFailure_partial_failure(results_constr, failed_paths_retry_conv, payment_id_ref);
32499         int64_t ret_ref = tag_ptr(ret_copy, true);
32500         return ret_ref;
32501 }
32502
32503 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
32504         LDKPhantomRouteHints this_obj_conv;
32505         this_obj_conv.inner = untag_ptr(this_obj);
32506         this_obj_conv.is_owned = ptr_is_owned(this_obj);
32507         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32508         PhantomRouteHints_free(this_obj_conv);
32509 }
32510
32511 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1get_1channels(JNIEnv *env, jclass clz, int64_t this_ptr) {
32512         LDKPhantomRouteHints this_ptr_conv;
32513         this_ptr_conv.inner = untag_ptr(this_ptr);
32514         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32515         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32516         this_ptr_conv.is_owned = false;
32517         LDKCVec_ChannelDetailsZ ret_var = PhantomRouteHints_get_channels(&this_ptr_conv);
32518         int64_tArray ret_arr = NULL;
32519         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
32520         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
32521         for (size_t q = 0; q < ret_var.datalen; q++) {
32522                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
32523                 int64_t ret_conv_16_ref = 0;
32524                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
32525                 ret_conv_16_ref = tag_ptr(ret_conv_16_var.inner, ret_conv_16_var.is_owned);
32526                 ret_arr_ptr[q] = ret_conv_16_ref;
32527         }
32528         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
32529         FREE(ret_var.data);
32530         return ret_arr;
32531 }
32532
32533 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1set_1channels(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
32534         LDKPhantomRouteHints this_ptr_conv;
32535         this_ptr_conv.inner = untag_ptr(this_ptr);
32536         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32537         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32538         this_ptr_conv.is_owned = false;
32539         LDKCVec_ChannelDetailsZ val_constr;
32540         val_constr.datalen = (*env)->GetArrayLength(env, val);
32541         if (val_constr.datalen > 0)
32542                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
32543         else
32544                 val_constr.data = NULL;
32545         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
32546         for (size_t q = 0; q < val_constr.datalen; q++) {
32547                 int64_t val_conv_16 = val_vals[q];
32548                 LDKChannelDetails val_conv_16_conv;
32549                 val_conv_16_conv.inner = untag_ptr(val_conv_16);
32550                 val_conv_16_conv.is_owned = ptr_is_owned(val_conv_16);
32551                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_16_conv);
32552                 val_conv_16_conv = ChannelDetails_clone(&val_conv_16_conv);
32553                 val_constr.data[q] = val_conv_16_conv;
32554         }
32555         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
32556         PhantomRouteHints_set_channels(&this_ptr_conv, val_constr);
32557 }
32558
32559 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1get_1phantom_1scid(JNIEnv *env, jclass clz, int64_t this_ptr) {
32560         LDKPhantomRouteHints this_ptr_conv;
32561         this_ptr_conv.inner = untag_ptr(this_ptr);
32562         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32563         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32564         this_ptr_conv.is_owned = false;
32565         int64_t ret_conv = PhantomRouteHints_get_phantom_scid(&this_ptr_conv);
32566         return ret_conv;
32567 }
32568
32569 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1set_1phantom_1scid(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32570         LDKPhantomRouteHints this_ptr_conv;
32571         this_ptr_conv.inner = untag_ptr(this_ptr);
32572         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32573         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32574         this_ptr_conv.is_owned = false;
32575         PhantomRouteHints_set_phantom_scid(&this_ptr_conv, val);
32576 }
32577
32578 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1get_1real_1node_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
32579         LDKPhantomRouteHints this_ptr_conv;
32580         this_ptr_conv.inner = untag_ptr(this_ptr);
32581         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32582         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32583         this_ptr_conv.is_owned = false;
32584         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
32585         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, PhantomRouteHints_get_real_node_pubkey(&this_ptr_conv).compressed_form);
32586         return ret_arr;
32587 }
32588
32589 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1set_1real_1node_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
32590         LDKPhantomRouteHints this_ptr_conv;
32591         this_ptr_conv.inner = untag_ptr(this_ptr);
32592         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
32593         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32594         this_ptr_conv.is_owned = false;
32595         LDKPublicKey val_ref;
32596         CHECK((*env)->GetArrayLength(env, val) == 33);
32597         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
32598         PhantomRouteHints_set_real_node_pubkey(&this_ptr_conv, val_ref);
32599 }
32600
32601 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) {
32602         LDKCVec_ChannelDetailsZ channels_arg_constr;
32603         channels_arg_constr.datalen = (*env)->GetArrayLength(env, channels_arg);
32604         if (channels_arg_constr.datalen > 0)
32605                 channels_arg_constr.data = MALLOC(channels_arg_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
32606         else
32607                 channels_arg_constr.data = NULL;
32608         int64_t* channels_arg_vals = (*env)->GetLongArrayElements (env, channels_arg, NULL);
32609         for (size_t q = 0; q < channels_arg_constr.datalen; q++) {
32610                 int64_t channels_arg_conv_16 = channels_arg_vals[q];
32611                 LDKChannelDetails channels_arg_conv_16_conv;
32612                 channels_arg_conv_16_conv.inner = untag_ptr(channels_arg_conv_16);
32613                 channels_arg_conv_16_conv.is_owned = ptr_is_owned(channels_arg_conv_16);
32614                 CHECK_INNER_FIELD_ACCESS_OR_NULL(channels_arg_conv_16_conv);
32615                 channels_arg_conv_16_conv = ChannelDetails_clone(&channels_arg_conv_16_conv);
32616                 channels_arg_constr.data[q] = channels_arg_conv_16_conv;
32617         }
32618         (*env)->ReleaseLongArrayElements(env, channels_arg, channels_arg_vals, 0);
32619         LDKPublicKey real_node_pubkey_arg_ref;
32620         CHECK((*env)->GetArrayLength(env, real_node_pubkey_arg) == 33);
32621         (*env)->GetByteArrayRegion(env, real_node_pubkey_arg, 0, 33, real_node_pubkey_arg_ref.compressed_form);
32622         LDKPhantomRouteHints ret_var = PhantomRouteHints_new(channels_arg_constr, phantom_scid_arg, real_node_pubkey_arg_ref);
32623         int64_t ret_ref = 0;
32624         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32625         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
32626         return ret_ref;
32627 }
32628
32629 static inline uint64_t PhantomRouteHints_clone_ptr(LDKPhantomRouteHints *NONNULL_PTR arg) {
32630         LDKPhantomRouteHints ret_var = PhantomRouteHints_clone(arg);
32631         int64_t ret_ref = 0;
32632         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32633         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
32634         return ret_ref;
32635 }
32636 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
32637         LDKPhantomRouteHints arg_conv;
32638         arg_conv.inner = untag_ptr(arg);
32639         arg_conv.is_owned = ptr_is_owned(arg);
32640         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
32641         arg_conv.is_owned = false;
32642         int64_t ret_conv = PhantomRouteHints_clone_ptr(&arg_conv);
32643         return ret_conv;
32644 }
32645
32646 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1clone(JNIEnv *env, jclass clz, int64_t orig) {
32647         LDKPhantomRouteHints orig_conv;
32648         orig_conv.inner = untag_ptr(orig);
32649         orig_conv.is_owned = ptr_is_owned(orig);
32650         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
32651         orig_conv.is_owned = false;
32652         LDKPhantomRouteHints ret_var = PhantomRouteHints_clone(&orig_conv);
32653         int64_t ret_ref = 0;
32654         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32655         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
32656         return ret_ref;
32657 }
32658
32659 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) {
32660         void* fee_est_ptr = untag_ptr(fee_est);
32661         CHECK_ACCESS(fee_est_ptr);
32662         LDKFeeEstimator fee_est_conv = *(LDKFeeEstimator*)(fee_est_ptr);
32663         if (fee_est_conv.free == LDKFeeEstimator_JCalls_free) {
32664                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
32665                 LDKFeeEstimator_JCalls_cloned(&fee_est_conv);
32666         }
32667         void* chain_monitor_ptr = untag_ptr(chain_monitor);
32668         CHECK_ACCESS(chain_monitor_ptr);
32669         LDKWatch chain_monitor_conv = *(LDKWatch*)(chain_monitor_ptr);
32670         if (chain_monitor_conv.free == LDKWatch_JCalls_free) {
32671                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
32672                 LDKWatch_JCalls_cloned(&chain_monitor_conv);
32673         }
32674         void* tx_broadcaster_ptr = untag_ptr(tx_broadcaster);
32675         CHECK_ACCESS(tx_broadcaster_ptr);
32676         LDKBroadcasterInterface tx_broadcaster_conv = *(LDKBroadcasterInterface*)(tx_broadcaster_ptr);
32677         if (tx_broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
32678                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
32679                 LDKBroadcasterInterface_JCalls_cloned(&tx_broadcaster_conv);
32680         }
32681         void* logger_ptr = untag_ptr(logger);
32682         CHECK_ACCESS(logger_ptr);
32683         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
32684         if (logger_conv.free == LDKLogger_JCalls_free) {
32685                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
32686                 LDKLogger_JCalls_cloned(&logger_conv);
32687         }
32688         void* keys_manager_ptr = untag_ptr(keys_manager);
32689         CHECK_ACCESS(keys_manager_ptr);
32690         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
32691         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
32692                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
32693                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
32694         }
32695         LDKUserConfig config_conv;
32696         config_conv.inner = untag_ptr(config);
32697         config_conv.is_owned = ptr_is_owned(config);
32698         CHECK_INNER_FIELD_ACCESS_OR_NULL(config_conv);
32699         config_conv = UserConfig_clone(&config_conv);
32700         LDKChainParameters params_conv;
32701         params_conv.inner = untag_ptr(params);
32702         params_conv.is_owned = ptr_is_owned(params);
32703         CHECK_INNER_FIELD_ACCESS_OR_NULL(params_conv);
32704         params_conv = ChainParameters_clone(&params_conv);
32705         LDKChannelManager ret_var = ChannelManager_new(fee_est_conv, chain_monitor_conv, tx_broadcaster_conv, logger_conv, keys_manager_conv, config_conv, params_conv);
32706         int64_t ret_ref = 0;
32707         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32708         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
32709         return ret_ref;
32710 }
32711
32712 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1get_1current_1default_1configuration(JNIEnv *env, jclass clz, int64_t this_arg) {
32713         LDKChannelManager this_arg_conv;
32714         this_arg_conv.inner = untag_ptr(this_arg);
32715         this_arg_conv.is_owned = ptr_is_owned(this_arg);
32716         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32717         this_arg_conv.is_owned = false;
32718         LDKUserConfig ret_var = ChannelManager_get_current_default_configuration(&this_arg_conv);
32719         int64_t ret_ref = 0;
32720         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32721         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
32722         return ret_ref;
32723 }
32724
32725 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, int8_tArray user_channel_id, int64_t override_config) {
32726         LDKChannelManager this_arg_conv;
32727         this_arg_conv.inner = untag_ptr(this_arg);
32728         this_arg_conv.is_owned = ptr_is_owned(this_arg);
32729         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32730         this_arg_conv.is_owned = false;
32731         LDKPublicKey their_network_key_ref;
32732         CHECK((*env)->GetArrayLength(env, their_network_key) == 33);
32733         (*env)->GetByteArrayRegion(env, their_network_key, 0, 33, their_network_key_ref.compressed_form);
32734         LDKU128 user_channel_id_ref;
32735         CHECK((*env)->GetArrayLength(env, user_channel_id) == 16);
32736         (*env)->GetByteArrayRegion(env, user_channel_id, 0, 16, user_channel_id_ref.le_bytes);
32737         LDKUserConfig override_config_conv;
32738         override_config_conv.inner = untag_ptr(override_config);
32739         override_config_conv.is_owned = ptr_is_owned(override_config);
32740         CHECK_INNER_FIELD_ACCESS_OR_NULL(override_config_conv);
32741         override_config_conv = UserConfig_clone(&override_config_conv);
32742         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
32743         *ret_conv = ChannelManager_create_channel(&this_arg_conv, their_network_key_ref, channel_value_satoshis, push_msat, user_channel_id_ref, override_config_conv);
32744         return tag_ptr(ret_conv, true);
32745 }
32746
32747 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1list_1channels(JNIEnv *env, jclass clz, int64_t this_arg) {
32748         LDKChannelManager this_arg_conv;
32749         this_arg_conv.inner = untag_ptr(this_arg);
32750         this_arg_conv.is_owned = ptr_is_owned(this_arg);
32751         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32752         this_arg_conv.is_owned = false;
32753         LDKCVec_ChannelDetailsZ ret_var = ChannelManager_list_channels(&this_arg_conv);
32754         int64_tArray ret_arr = NULL;
32755         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
32756         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
32757         for (size_t q = 0; q < ret_var.datalen; q++) {
32758                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
32759                 int64_t ret_conv_16_ref = 0;
32760                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
32761                 ret_conv_16_ref = tag_ptr(ret_conv_16_var.inner, ret_conv_16_var.is_owned);
32762                 ret_arr_ptr[q] = ret_conv_16_ref;
32763         }
32764         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
32765         FREE(ret_var.data);
32766         return ret_arr;
32767 }
32768
32769 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1list_1usable_1channels(JNIEnv *env, jclass clz, int64_t this_arg) {
32770         LDKChannelManager this_arg_conv;
32771         this_arg_conv.inner = untag_ptr(this_arg);
32772         this_arg_conv.is_owned = ptr_is_owned(this_arg);
32773         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32774         this_arg_conv.is_owned = false;
32775         LDKCVec_ChannelDetailsZ ret_var = ChannelManager_list_usable_channels(&this_arg_conv);
32776         int64_tArray ret_arr = NULL;
32777         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
32778         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
32779         for (size_t q = 0; q < ret_var.datalen; q++) {
32780                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
32781                 int64_t ret_conv_16_ref = 0;
32782                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
32783                 ret_conv_16_ref = tag_ptr(ret_conv_16_var.inner, ret_conv_16_var.is_owned);
32784                 ret_arr_ptr[q] = ret_conv_16_ref;
32785         }
32786         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
32787         FREE(ret_var.data);
32788         return ret_arr;
32789 }
32790
32791 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) {
32792         LDKChannelManager this_arg_conv;
32793         this_arg_conv.inner = untag_ptr(this_arg);
32794         this_arg_conv.is_owned = ptr_is_owned(this_arg);
32795         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32796         this_arg_conv.is_owned = false;
32797         unsigned char channel_id_arr[32];
32798         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
32799         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_arr);
32800         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
32801         LDKPublicKey counterparty_node_id_ref;
32802         CHECK((*env)->GetArrayLength(env, counterparty_node_id) == 33);
32803         (*env)->GetByteArrayRegion(env, counterparty_node_id, 0, 33, counterparty_node_id_ref.compressed_form);
32804         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
32805         *ret_conv = ChannelManager_close_channel(&this_arg_conv, channel_id_ref, counterparty_node_id_ref);
32806         return tag_ptr(ret_conv, true);
32807 }
32808
32809 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) {
32810         LDKChannelManager this_arg_conv;
32811         this_arg_conv.inner = untag_ptr(this_arg);
32812         this_arg_conv.is_owned = ptr_is_owned(this_arg);
32813         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32814         this_arg_conv.is_owned = false;
32815         unsigned char channel_id_arr[32];
32816         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
32817         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_arr);
32818         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
32819         LDKPublicKey counterparty_node_id_ref;
32820         CHECK((*env)->GetArrayLength(env, counterparty_node_id) == 33);
32821         (*env)->GetByteArrayRegion(env, counterparty_node_id, 0, 33, counterparty_node_id_ref.compressed_form);
32822         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
32823         *ret_conv = ChannelManager_close_channel_with_target_feerate(&this_arg_conv, channel_id_ref, counterparty_node_id_ref, target_feerate_sats_per_1000_weight);
32824         return tag_ptr(ret_conv, true);
32825 }
32826
32827 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) {
32828         LDKChannelManager this_arg_conv;
32829         this_arg_conv.inner = untag_ptr(this_arg);
32830         this_arg_conv.is_owned = ptr_is_owned(this_arg);
32831         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32832         this_arg_conv.is_owned = false;
32833         unsigned char channel_id_arr[32];
32834         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
32835         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_arr);
32836         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
32837         LDKPublicKey counterparty_node_id_ref;
32838         CHECK((*env)->GetArrayLength(env, counterparty_node_id) == 33);
32839         (*env)->GetByteArrayRegion(env, counterparty_node_id, 0, 33, counterparty_node_id_ref.compressed_form);
32840         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
32841         *ret_conv = ChannelManager_force_close_broadcasting_latest_txn(&this_arg_conv, channel_id_ref, counterparty_node_id_ref);
32842         return tag_ptr(ret_conv, true);
32843 }
32844
32845 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) {
32846         LDKChannelManager this_arg_conv;
32847         this_arg_conv.inner = untag_ptr(this_arg);
32848         this_arg_conv.is_owned = ptr_is_owned(this_arg);
32849         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32850         this_arg_conv.is_owned = false;
32851         unsigned char channel_id_arr[32];
32852         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
32853         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_arr);
32854         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
32855         LDKPublicKey counterparty_node_id_ref;
32856         CHECK((*env)->GetArrayLength(env, counterparty_node_id) == 33);
32857         (*env)->GetByteArrayRegion(env, counterparty_node_id, 0, 33, counterparty_node_id_ref.compressed_form);
32858         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
32859         *ret_conv = ChannelManager_force_close_without_broadcasting_txn(&this_arg_conv, channel_id_ref, counterparty_node_id_ref);
32860         return tag_ptr(ret_conv, true);
32861 }
32862
32863 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1force_1close_1all_1channels_1broadcasting_1latest_1txn(JNIEnv *env, jclass clz, int64_t this_arg) {
32864         LDKChannelManager this_arg_conv;
32865         this_arg_conv.inner = untag_ptr(this_arg);
32866         this_arg_conv.is_owned = ptr_is_owned(this_arg);
32867         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32868         this_arg_conv.is_owned = false;
32869         ChannelManager_force_close_all_channels_broadcasting_latest_txn(&this_arg_conv);
32870 }
32871
32872 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1force_1close_1all_1channels_1without_1broadcasting_1txn(JNIEnv *env, jclass clz, int64_t this_arg) {
32873         LDKChannelManager this_arg_conv;
32874         this_arg_conv.inner = untag_ptr(this_arg);
32875         this_arg_conv.is_owned = ptr_is_owned(this_arg);
32876         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32877         this_arg_conv.is_owned = false;
32878         ChannelManager_force_close_all_channels_without_broadcasting_txn(&this_arg_conv);
32879 }
32880
32881 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, int8_tArray payment_id) {
32882         LDKChannelManager this_arg_conv;
32883         this_arg_conv.inner = untag_ptr(this_arg);
32884         this_arg_conv.is_owned = ptr_is_owned(this_arg);
32885         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32886         this_arg_conv.is_owned = false;
32887         LDKRoute route_conv;
32888         route_conv.inner = untag_ptr(route);
32889         route_conv.is_owned = ptr_is_owned(route);
32890         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
32891         route_conv.is_owned = false;
32892         LDKThirtyTwoBytes payment_hash_ref;
32893         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
32894         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
32895         LDKThirtyTwoBytes payment_secret_ref;
32896         CHECK((*env)->GetArrayLength(env, payment_secret) == 32);
32897         (*env)->GetByteArrayRegion(env, payment_secret, 0, 32, payment_secret_ref.data);
32898         LDKThirtyTwoBytes payment_id_ref;
32899         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
32900         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
32901         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
32902         *ret_conv = ChannelManager_send_payment(&this_arg_conv, &route_conv, payment_hash_ref, payment_secret_ref, payment_id_ref);
32903         return tag_ptr(ret_conv, true);
32904 }
32905
32906 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) {
32907         LDKChannelManager this_arg_conv;
32908         this_arg_conv.inner = untag_ptr(this_arg);
32909         this_arg_conv.is_owned = ptr_is_owned(this_arg);
32910         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32911         this_arg_conv.is_owned = false;
32912         LDKRoute route_conv;
32913         route_conv.inner = untag_ptr(route);
32914         route_conv.is_owned = ptr_is_owned(route);
32915         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
32916         route_conv.is_owned = false;
32917         LDKThirtyTwoBytes payment_id_ref;
32918         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
32919         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
32920         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
32921         *ret_conv = ChannelManager_retry_payment(&this_arg_conv, &route_conv, payment_id_ref);
32922         return tag_ptr(ret_conv, true);
32923 }
32924
32925 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1abandon_1payment(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray payment_id) {
32926         LDKChannelManager this_arg_conv;
32927         this_arg_conv.inner = untag_ptr(this_arg);
32928         this_arg_conv.is_owned = ptr_is_owned(this_arg);
32929         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32930         this_arg_conv.is_owned = false;
32931         LDKThirtyTwoBytes payment_id_ref;
32932         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
32933         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
32934         ChannelManager_abandon_payment(&this_arg_conv, payment_id_ref);
32935 }
32936
32937 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, int8_tArray payment_id) {
32938         LDKChannelManager this_arg_conv;
32939         this_arg_conv.inner = untag_ptr(this_arg);
32940         this_arg_conv.is_owned = ptr_is_owned(this_arg);
32941         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32942         this_arg_conv.is_owned = false;
32943         LDKRoute route_conv;
32944         route_conv.inner = untag_ptr(route);
32945         route_conv.is_owned = ptr_is_owned(route);
32946         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
32947         route_conv.is_owned = false;
32948         LDKThirtyTwoBytes payment_preimage_ref;
32949         CHECK((*env)->GetArrayLength(env, payment_preimage) == 32);
32950         (*env)->GetByteArrayRegion(env, payment_preimage, 0, 32, payment_preimage_ref.data);
32951         LDKThirtyTwoBytes payment_id_ref;
32952         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
32953         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
32954         LDKCResult_PaymentHashPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentHashPaymentSendFailureZ), "LDKCResult_PaymentHashPaymentSendFailureZ");
32955         *ret_conv = ChannelManager_send_spontaneous_payment(&this_arg_conv, &route_conv, payment_preimage_ref, payment_id_ref);
32956         return tag_ptr(ret_conv, true);
32957 }
32958
32959 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1send_1probe(JNIEnv *env, jclass clz, int64_t this_arg, int64_tArray hops) {
32960         LDKChannelManager this_arg_conv;
32961         this_arg_conv.inner = untag_ptr(this_arg);
32962         this_arg_conv.is_owned = ptr_is_owned(this_arg);
32963         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32964         this_arg_conv.is_owned = false;
32965         LDKCVec_RouteHopZ hops_constr;
32966         hops_constr.datalen = (*env)->GetArrayLength(env, hops);
32967         if (hops_constr.datalen > 0)
32968                 hops_constr.data = MALLOC(hops_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
32969         else
32970                 hops_constr.data = NULL;
32971         int64_t* hops_vals = (*env)->GetLongArrayElements (env, hops, NULL);
32972         for (size_t k = 0; k < hops_constr.datalen; k++) {
32973                 int64_t hops_conv_10 = hops_vals[k];
32974                 LDKRouteHop hops_conv_10_conv;
32975                 hops_conv_10_conv.inner = untag_ptr(hops_conv_10);
32976                 hops_conv_10_conv.is_owned = ptr_is_owned(hops_conv_10);
32977                 CHECK_INNER_FIELD_ACCESS_OR_NULL(hops_conv_10_conv);
32978                 hops_conv_10_conv = RouteHop_clone(&hops_conv_10_conv);
32979                 hops_constr.data[k] = hops_conv_10_conv;
32980         }
32981         (*env)->ReleaseLongArrayElements(env, hops, hops_vals, 0);
32982         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
32983         *ret_conv = ChannelManager_send_probe(&this_arg_conv, hops_constr);
32984         return tag_ptr(ret_conv, true);
32985 }
32986
32987 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) {
32988         LDKChannelManager this_arg_conv;
32989         this_arg_conv.inner = untag_ptr(this_arg);
32990         this_arg_conv.is_owned = ptr_is_owned(this_arg);
32991         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32992         this_arg_conv.is_owned = false;
32993         unsigned char temporary_channel_id_arr[32];
32994         CHECK((*env)->GetArrayLength(env, temporary_channel_id) == 32);
32995         (*env)->GetByteArrayRegion(env, temporary_channel_id, 0, 32, temporary_channel_id_arr);
32996         unsigned char (*temporary_channel_id_ref)[32] = &temporary_channel_id_arr;
32997         LDKPublicKey counterparty_node_id_ref;
32998         CHECK((*env)->GetArrayLength(env, counterparty_node_id) == 33);
32999         (*env)->GetByteArrayRegion(env, counterparty_node_id, 0, 33, counterparty_node_id_ref.compressed_form);
33000         LDKTransaction funding_transaction_ref;
33001         funding_transaction_ref.datalen = (*env)->GetArrayLength(env, funding_transaction);
33002         funding_transaction_ref.data = MALLOC(funding_transaction_ref.datalen, "LDKTransaction Bytes");
33003         (*env)->GetByteArrayRegion(env, funding_transaction, 0, funding_transaction_ref.datalen, funding_transaction_ref.data);
33004         funding_transaction_ref.data_is_owned = true;
33005         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
33006         *ret_conv = ChannelManager_funding_transaction_generated(&this_arg_conv, temporary_channel_id_ref, counterparty_node_id_ref, funding_transaction_ref);
33007         return tag_ptr(ret_conv, true);
33008 }
33009
33010 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) {
33011         LDKChannelManager this_arg_conv;
33012         this_arg_conv.inner = untag_ptr(this_arg);
33013         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33014         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33015         this_arg_conv.is_owned = false;
33016         LDKPublicKey counterparty_node_id_ref;
33017         CHECK((*env)->GetArrayLength(env, counterparty_node_id) == 33);
33018         (*env)->GetByteArrayRegion(env, counterparty_node_id, 0, 33, counterparty_node_id_ref.compressed_form);
33019         LDKCVec_ThirtyTwoBytesZ channel_ids_constr;
33020         channel_ids_constr.datalen = (*env)->GetArrayLength(env, channel_ids);
33021         if (channel_ids_constr.datalen > 0)
33022                 channel_ids_constr.data = MALLOC(channel_ids_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_ThirtyTwoBytesZ Elements");
33023         else
33024                 channel_ids_constr.data = NULL;
33025         for (size_t i = 0; i < channel_ids_constr.datalen; i++) {
33026                 int8_tArray channel_ids_conv_8 = (*env)->GetObjectArrayElement(env, channel_ids, i);
33027                 LDKThirtyTwoBytes channel_ids_conv_8_ref;
33028                 CHECK((*env)->GetArrayLength(env, channel_ids_conv_8) == 32);
33029                 (*env)->GetByteArrayRegion(env, channel_ids_conv_8, 0, 32, channel_ids_conv_8_ref.data);
33030                 channel_ids_constr.data[i] = channel_ids_conv_8_ref;
33031         }
33032         LDKChannelConfig config_conv;
33033         config_conv.inner = untag_ptr(config);
33034         config_conv.is_owned = ptr_is_owned(config);
33035         CHECK_INNER_FIELD_ACCESS_OR_NULL(config_conv);
33036         config_conv.is_owned = false;
33037         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
33038         *ret_conv = ChannelManager_update_channel_config(&this_arg_conv, counterparty_node_id_ref, channel_ids_constr, &config_conv);
33039         return tag_ptr(ret_conv, true);
33040 }
33041
33042 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1forward_1intercepted_1htlc(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray intercept_id, int8_tArray next_hop_channel_id, int8_tArray _next_node_id, int64_t amt_to_forward_msat) {
33043         LDKChannelManager this_arg_conv;
33044         this_arg_conv.inner = untag_ptr(this_arg);
33045         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33046         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33047         this_arg_conv.is_owned = false;
33048         LDKThirtyTwoBytes intercept_id_ref;
33049         CHECK((*env)->GetArrayLength(env, intercept_id) == 32);
33050         (*env)->GetByteArrayRegion(env, intercept_id, 0, 32, intercept_id_ref.data);
33051         unsigned char next_hop_channel_id_arr[32];
33052         CHECK((*env)->GetArrayLength(env, next_hop_channel_id) == 32);
33053         (*env)->GetByteArrayRegion(env, next_hop_channel_id, 0, 32, next_hop_channel_id_arr);
33054         unsigned char (*next_hop_channel_id_ref)[32] = &next_hop_channel_id_arr;
33055         LDKPublicKey _next_node_id_ref;
33056         CHECK((*env)->GetArrayLength(env, _next_node_id) == 33);
33057         (*env)->GetByteArrayRegion(env, _next_node_id, 0, 33, _next_node_id_ref.compressed_form);
33058         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
33059         *ret_conv = ChannelManager_forward_intercepted_htlc(&this_arg_conv, intercept_id_ref, next_hop_channel_id_ref, _next_node_id_ref, amt_to_forward_msat);
33060         return tag_ptr(ret_conv, true);
33061 }
33062
33063 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1fail_1intercepted_1htlc(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray intercept_id) {
33064         LDKChannelManager this_arg_conv;
33065         this_arg_conv.inner = untag_ptr(this_arg);
33066         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33067         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33068         this_arg_conv.is_owned = false;
33069         LDKThirtyTwoBytes intercept_id_ref;
33070         CHECK((*env)->GetArrayLength(env, intercept_id) == 32);
33071         (*env)->GetByteArrayRegion(env, intercept_id, 0, 32, intercept_id_ref.data);
33072         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
33073         *ret_conv = ChannelManager_fail_intercepted_htlc(&this_arg_conv, intercept_id_ref);
33074         return tag_ptr(ret_conv, true);
33075 }
33076
33077 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1process_1pending_1htlc_1forwards(JNIEnv *env, jclass clz, int64_t this_arg) {
33078         LDKChannelManager this_arg_conv;
33079         this_arg_conv.inner = untag_ptr(this_arg);
33080         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33081         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33082         this_arg_conv.is_owned = false;
33083         ChannelManager_process_pending_htlc_forwards(&this_arg_conv);
33084 }
33085
33086 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1timer_1tick_1occurred(JNIEnv *env, jclass clz, int64_t this_arg) {
33087         LDKChannelManager this_arg_conv;
33088         this_arg_conv.inner = untag_ptr(this_arg);
33089         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33090         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33091         this_arg_conv.is_owned = false;
33092         ChannelManager_timer_tick_occurred(&this_arg_conv);
33093 }
33094
33095 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1fail_1htlc_1backwards(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray payment_hash) {
33096         LDKChannelManager this_arg_conv;
33097         this_arg_conv.inner = untag_ptr(this_arg);
33098         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33099         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33100         this_arg_conv.is_owned = false;
33101         unsigned char payment_hash_arr[32];
33102         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
33103         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_arr);
33104         unsigned char (*payment_hash_ref)[32] = &payment_hash_arr;
33105         ChannelManager_fail_htlc_backwards(&this_arg_conv, payment_hash_ref);
33106 }
33107
33108 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1claim_1funds(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray payment_preimage) {
33109         LDKChannelManager this_arg_conv;
33110         this_arg_conv.inner = untag_ptr(this_arg);
33111         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33112         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33113         this_arg_conv.is_owned = false;
33114         LDKThirtyTwoBytes payment_preimage_ref;
33115         CHECK((*env)->GetArrayLength(env, payment_preimage) == 32);
33116         (*env)->GetByteArrayRegion(env, payment_preimage, 0, 32, payment_preimage_ref.data);
33117         ChannelManager_claim_funds(&this_arg_conv, payment_preimage_ref);
33118 }
33119
33120 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1get_1our_1node_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
33121         LDKChannelManager this_arg_conv;
33122         this_arg_conv.inner = untag_ptr(this_arg);
33123         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33124         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33125         this_arg_conv.is_owned = false;
33126         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
33127         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelManager_get_our_node_id(&this_arg_conv).compressed_form);
33128         return ret_arr;
33129 }
33130
33131 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, int8_tArray user_channel_id) {
33132         LDKChannelManager this_arg_conv;
33133         this_arg_conv.inner = untag_ptr(this_arg);
33134         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33135         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33136         this_arg_conv.is_owned = false;
33137         unsigned char temporary_channel_id_arr[32];
33138         CHECK((*env)->GetArrayLength(env, temporary_channel_id) == 32);
33139         (*env)->GetByteArrayRegion(env, temporary_channel_id, 0, 32, temporary_channel_id_arr);
33140         unsigned char (*temporary_channel_id_ref)[32] = &temporary_channel_id_arr;
33141         LDKPublicKey counterparty_node_id_ref;
33142         CHECK((*env)->GetArrayLength(env, counterparty_node_id) == 33);
33143         (*env)->GetByteArrayRegion(env, counterparty_node_id, 0, 33, counterparty_node_id_ref.compressed_form);
33144         LDKU128 user_channel_id_ref;
33145         CHECK((*env)->GetArrayLength(env, user_channel_id) == 16);
33146         (*env)->GetByteArrayRegion(env, user_channel_id, 0, 16, user_channel_id_ref.le_bytes);
33147         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
33148         *ret_conv = ChannelManager_accept_inbound_channel(&this_arg_conv, temporary_channel_id_ref, counterparty_node_id_ref, user_channel_id_ref);
33149         return tag_ptr(ret_conv, true);
33150 }
33151
33152 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, int8_tArray user_channel_id) {
33153         LDKChannelManager this_arg_conv;
33154         this_arg_conv.inner = untag_ptr(this_arg);
33155         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33156         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33157         this_arg_conv.is_owned = false;
33158         unsigned char temporary_channel_id_arr[32];
33159         CHECK((*env)->GetArrayLength(env, temporary_channel_id) == 32);
33160         (*env)->GetByteArrayRegion(env, temporary_channel_id, 0, 32, temporary_channel_id_arr);
33161         unsigned char (*temporary_channel_id_ref)[32] = &temporary_channel_id_arr;
33162         LDKPublicKey counterparty_node_id_ref;
33163         CHECK((*env)->GetArrayLength(env, counterparty_node_id) == 33);
33164         (*env)->GetByteArrayRegion(env, counterparty_node_id, 0, 33, counterparty_node_id_ref.compressed_form);
33165         LDKU128 user_channel_id_ref;
33166         CHECK((*env)->GetArrayLength(env, user_channel_id) == 16);
33167         (*env)->GetByteArrayRegion(env, user_channel_id, 0, 16, user_channel_id_ref.le_bytes);
33168         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
33169         *ret_conv = ChannelManager_accept_inbound_channel_from_trusted_peer_0conf(&this_arg_conv, temporary_channel_id_ref, counterparty_node_id_ref, user_channel_id_ref);
33170         return tag_ptr(ret_conv, true);
33171 }
33172
33173 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) {
33174         LDKChannelManager this_arg_conv;
33175         this_arg_conv.inner = untag_ptr(this_arg);
33176         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33177         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33178         this_arg_conv.is_owned = false;
33179         void* min_value_msat_ptr = untag_ptr(min_value_msat);
33180         CHECK_ACCESS(min_value_msat_ptr);
33181         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
33182         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(min_value_msat));
33183         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
33184         *ret_conv = ChannelManager_create_inbound_payment(&this_arg_conv, min_value_msat_conv, invoice_expiry_delta_secs);
33185         return tag_ptr(ret_conv, true);
33186 }
33187
33188 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) {
33189         LDKChannelManager this_arg_conv;
33190         this_arg_conv.inner = untag_ptr(this_arg);
33191         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33192         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33193         this_arg_conv.is_owned = false;
33194         void* min_value_msat_ptr = untag_ptr(min_value_msat);
33195         CHECK_ACCESS(min_value_msat_ptr);
33196         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
33197         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(min_value_msat));
33198         LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZ");
33199         *ret_conv = ChannelManager_create_inbound_payment_legacy(&this_arg_conv, min_value_msat_conv, invoice_expiry_delta_secs);
33200         return tag_ptr(ret_conv, true);
33201 }
33202
33203 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) {
33204         LDKChannelManager this_arg_conv;
33205         this_arg_conv.inner = untag_ptr(this_arg);
33206         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33207         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33208         this_arg_conv.is_owned = false;
33209         LDKThirtyTwoBytes payment_hash_ref;
33210         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
33211         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
33212         void* min_value_msat_ptr = untag_ptr(min_value_msat);
33213         CHECK_ACCESS(min_value_msat_ptr);
33214         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
33215         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(min_value_msat));
33216         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
33217         *ret_conv = ChannelManager_create_inbound_payment_for_hash(&this_arg_conv, payment_hash_ref, min_value_msat_conv, invoice_expiry_delta_secs);
33218         return tag_ptr(ret_conv, true);
33219 }
33220
33221 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) {
33222         LDKChannelManager this_arg_conv;
33223         this_arg_conv.inner = untag_ptr(this_arg);
33224         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33225         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33226         this_arg_conv.is_owned = false;
33227         LDKThirtyTwoBytes payment_hash_ref;
33228         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
33229         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
33230         void* min_value_msat_ptr = untag_ptr(min_value_msat);
33231         CHECK_ACCESS(min_value_msat_ptr);
33232         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
33233         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(min_value_msat));
33234         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
33235         *ret_conv = ChannelManager_create_inbound_payment_for_hash_legacy(&this_arg_conv, payment_hash_ref, min_value_msat_conv, invoice_expiry_delta_secs);
33236         return tag_ptr(ret_conv, true);
33237 }
33238
33239 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) {
33240         LDKChannelManager this_arg_conv;
33241         this_arg_conv.inner = untag_ptr(this_arg);
33242         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33243         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33244         this_arg_conv.is_owned = false;
33245         LDKThirtyTwoBytes payment_hash_ref;
33246         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
33247         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
33248         LDKThirtyTwoBytes payment_secret_ref;
33249         CHECK((*env)->GetArrayLength(env, payment_secret) == 32);
33250         (*env)->GetByteArrayRegion(env, payment_secret, 0, 32, payment_secret_ref.data);
33251         LDKCResult_PaymentPreimageAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentPreimageAPIErrorZ), "LDKCResult_PaymentPreimageAPIErrorZ");
33252         *ret_conv = ChannelManager_get_payment_preimage(&this_arg_conv, payment_hash_ref, payment_secret_ref);
33253         return tag_ptr(ret_conv, true);
33254 }
33255
33256 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1get_1phantom_1scid(JNIEnv *env, jclass clz, int64_t this_arg) {
33257         LDKChannelManager this_arg_conv;
33258         this_arg_conv.inner = untag_ptr(this_arg);
33259         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33260         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33261         this_arg_conv.is_owned = false;
33262         int64_t ret_conv = ChannelManager_get_phantom_scid(&this_arg_conv);
33263         return ret_conv;
33264 }
33265
33266 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1get_1phantom_1route_1hints(JNIEnv *env, jclass clz, int64_t this_arg) {
33267         LDKChannelManager this_arg_conv;
33268         this_arg_conv.inner = untag_ptr(this_arg);
33269         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33270         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33271         this_arg_conv.is_owned = false;
33272         LDKPhantomRouteHints ret_var = ChannelManager_get_phantom_route_hints(&this_arg_conv);
33273         int64_t ret_ref = 0;
33274         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33275         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
33276         return ret_ref;
33277 }
33278
33279 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1get_1intercept_1scid(JNIEnv *env, jclass clz, int64_t this_arg) {
33280         LDKChannelManager this_arg_conv;
33281         this_arg_conv.inner = untag_ptr(this_arg);
33282         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33283         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33284         this_arg_conv.is_owned = false;
33285         int64_t ret_conv = ChannelManager_get_intercept_scid(&this_arg_conv);
33286         return ret_conv;
33287 }
33288
33289 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1compute_1inflight_1htlcs(JNIEnv *env, jclass clz, int64_t this_arg) {
33290         LDKChannelManager this_arg_conv;
33291         this_arg_conv.inner = untag_ptr(this_arg);
33292         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33293         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33294         this_arg_conv.is_owned = false;
33295         LDKInFlightHtlcs ret_var = ChannelManager_compute_inflight_htlcs(&this_arg_conv);
33296         int64_t ret_ref = 0;
33297         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33298         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
33299         return ret_ref;
33300 }
33301
33302 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
33303         LDKChannelManager this_arg_conv;
33304         this_arg_conv.inner = untag_ptr(this_arg);
33305         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33306         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33307         this_arg_conv.is_owned = false;
33308         LDKMessageSendEventsProvider* ret_ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
33309         *ret_ret = ChannelManager_as_MessageSendEventsProvider(&this_arg_conv);
33310         return tag_ptr(ret_ret, true);
33311 }
33312
33313 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1EventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
33314         LDKChannelManager this_arg_conv;
33315         this_arg_conv.inner = untag_ptr(this_arg);
33316         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33317         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33318         this_arg_conv.is_owned = false;
33319         LDKEventsProvider* ret_ret = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
33320         *ret_ret = ChannelManager_as_EventsProvider(&this_arg_conv);
33321         return tag_ptr(ret_ret, true);
33322 }
33323
33324 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1Listen(JNIEnv *env, jclass clz, int64_t this_arg) {
33325         LDKChannelManager this_arg_conv;
33326         this_arg_conv.inner = untag_ptr(this_arg);
33327         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33328         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33329         this_arg_conv.is_owned = false;
33330         LDKListen* ret_ret = MALLOC(sizeof(LDKListen), "LDKListen");
33331         *ret_ret = ChannelManager_as_Listen(&this_arg_conv);
33332         return tag_ptr(ret_ret, true);
33333 }
33334
33335 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1Confirm(JNIEnv *env, jclass clz, int64_t this_arg) {
33336         LDKChannelManager this_arg_conv;
33337         this_arg_conv.inner = untag_ptr(this_arg);
33338         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33339         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33340         this_arg_conv.is_owned = false;
33341         LDKConfirm* ret_ret = MALLOC(sizeof(LDKConfirm), "LDKConfirm");
33342         *ret_ret = ChannelManager_as_Confirm(&this_arg_conv);
33343         return tag_ptr(ret_ret, true);
33344 }
33345
33346 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) {
33347         LDKChannelManager this_arg_conv;
33348         this_arg_conv.inner = untag_ptr(this_arg);
33349         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33350         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33351         this_arg_conv.is_owned = false;
33352         jboolean ret_conv = ChannelManager_await_persistable_update_timeout(&this_arg_conv, max_wait);
33353         return ret_conv;
33354 }
33355
33356 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1await_1persistable_1update(JNIEnv *env, jclass clz, int64_t this_arg) {
33357         LDKChannelManager this_arg_conv;
33358         this_arg_conv.inner = untag_ptr(this_arg);
33359         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33360         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33361         this_arg_conv.is_owned = false;
33362         ChannelManager_await_persistable_update(&this_arg_conv);
33363 }
33364
33365 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1get_1persistable_1update_1future(JNIEnv *env, jclass clz, int64_t this_arg) {
33366         LDKChannelManager this_arg_conv;
33367         this_arg_conv.inner = untag_ptr(this_arg);
33368         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33369         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33370         this_arg_conv.is_owned = false;
33371         LDKFuture ret_var = ChannelManager_get_persistable_update_future(&this_arg_conv);
33372         int64_t ret_ref = 0;
33373         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33374         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
33375         return ret_ref;
33376 }
33377
33378 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1current_1best_1block(JNIEnv *env, jclass clz, int64_t this_arg) {
33379         LDKChannelManager this_arg_conv;
33380         this_arg_conv.inner = untag_ptr(this_arg);
33381         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33382         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33383         this_arg_conv.is_owned = false;
33384         LDKBestBlock ret_var = ChannelManager_current_best_block(&this_arg_conv);
33385         int64_t ret_ref = 0;
33386         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33387         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
33388         return ret_ref;
33389 }
33390
33391 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1ChannelMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
33392         LDKChannelManager this_arg_conv;
33393         this_arg_conv.inner = untag_ptr(this_arg);
33394         this_arg_conv.is_owned = ptr_is_owned(this_arg);
33395         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33396         this_arg_conv.is_owned = false;
33397         LDKChannelMessageHandler* ret_ret = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
33398         *ret_ret = ChannelManager_as_ChannelMessageHandler(&this_arg_conv);
33399         return tag_ptr(ret_ret, true);
33400 }
33401
33402 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_provided_1node_1features(JNIEnv *env, jclass clz) {
33403         LDKNodeFeatures ret_var = provided_node_features();
33404         int64_t ret_ref = 0;
33405         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33406         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
33407         return ret_ref;
33408 }
33409
33410 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_provided_1channel_1features(JNIEnv *env, jclass clz) {
33411         LDKChannelFeatures ret_var = provided_channel_features();
33412         int64_t ret_ref = 0;
33413         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33414         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
33415         return ret_ref;
33416 }
33417
33418 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_provided_1init_1features(JNIEnv *env, jclass clz) {
33419         LDKInitFeatures ret_var = provided_init_features();
33420         int64_t ret_ref = 0;
33421         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33422         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
33423         return ret_ref;
33424 }
33425
33426 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1write(JNIEnv *env, jclass clz, int64_t obj) {
33427         LDKCounterpartyForwardingInfo obj_conv;
33428         obj_conv.inner = untag_ptr(obj);
33429         obj_conv.is_owned = ptr_is_owned(obj);
33430         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33431         obj_conv.is_owned = false;
33432         LDKCVec_u8Z ret_var = CounterpartyForwardingInfo_write(&obj_conv);
33433         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
33434         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
33435         CVec_u8Z_free(ret_var);
33436         return ret_arr;
33437 }
33438
33439 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
33440         LDKu8slice ser_ref;
33441         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
33442         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
33443         LDKCResult_CounterpartyForwardingInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyForwardingInfoDecodeErrorZ), "LDKCResult_CounterpartyForwardingInfoDecodeErrorZ");
33444         *ret_conv = CounterpartyForwardingInfo_read(ser_ref);
33445         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
33446         return tag_ptr(ret_conv, true);
33447 }
33448
33449 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1write(JNIEnv *env, jclass clz, int64_t obj) {
33450         LDKChannelCounterparty obj_conv;
33451         obj_conv.inner = untag_ptr(obj);
33452         obj_conv.is_owned = ptr_is_owned(obj);
33453         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33454         obj_conv.is_owned = false;
33455         LDKCVec_u8Z ret_var = ChannelCounterparty_write(&obj_conv);
33456         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
33457         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
33458         CVec_u8Z_free(ret_var);
33459         return ret_arr;
33460 }
33461
33462 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
33463         LDKu8slice ser_ref;
33464         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
33465         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
33466         LDKCResult_ChannelCounterpartyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelCounterpartyDecodeErrorZ), "LDKCResult_ChannelCounterpartyDecodeErrorZ");
33467         *ret_conv = ChannelCounterparty_read(ser_ref);
33468         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
33469         return tag_ptr(ret_conv, true);
33470 }
33471
33472 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1write(JNIEnv *env, jclass clz, int64_t obj) {
33473         LDKChannelDetails obj_conv;
33474         obj_conv.inner = untag_ptr(obj);
33475         obj_conv.is_owned = ptr_is_owned(obj);
33476         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33477         obj_conv.is_owned = false;
33478         LDKCVec_u8Z ret_var = ChannelDetails_write(&obj_conv);
33479         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
33480         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
33481         CVec_u8Z_free(ret_var);
33482         return ret_arr;
33483 }
33484
33485 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
33486         LDKu8slice ser_ref;
33487         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
33488         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
33489         LDKCResult_ChannelDetailsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelDetailsDecodeErrorZ), "LDKCResult_ChannelDetailsDecodeErrorZ");
33490         *ret_conv = ChannelDetails_read(ser_ref);
33491         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
33492         return tag_ptr(ret_conv, true);
33493 }
33494
33495 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1write(JNIEnv *env, jclass clz, int64_t obj) {
33496         LDKPhantomRouteHints obj_conv;
33497         obj_conv.inner = untag_ptr(obj);
33498         obj_conv.is_owned = ptr_is_owned(obj);
33499         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33500         obj_conv.is_owned = false;
33501         LDKCVec_u8Z ret_var = PhantomRouteHints_write(&obj_conv);
33502         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
33503         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
33504         CVec_u8Z_free(ret_var);
33505         return ret_arr;
33506 }
33507
33508 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PhantomRouteHints_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
33509         LDKu8slice ser_ref;
33510         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
33511         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
33512         LDKCResult_PhantomRouteHintsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PhantomRouteHintsDecodeErrorZ), "LDKCResult_PhantomRouteHintsDecodeErrorZ");
33513         *ret_conv = PhantomRouteHints_read(ser_ref);
33514         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
33515         return tag_ptr(ret_conv, true);
33516 }
33517
33518 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1write(JNIEnv *env, jclass clz, int64_t obj) {
33519         LDKChannelManager obj_conv;
33520         obj_conv.inner = untag_ptr(obj);
33521         obj_conv.is_owned = ptr_is_owned(obj);
33522         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33523         obj_conv.is_owned = false;
33524         LDKCVec_u8Z ret_var = ChannelManager_write(&obj_conv);
33525         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
33526         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
33527         CVec_u8Z_free(ret_var);
33528         return ret_arr;
33529 }
33530
33531 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
33532         LDKChannelManagerReadArgs this_obj_conv;
33533         this_obj_conv.inner = untag_ptr(this_obj);
33534         this_obj_conv.is_owned = ptr_is_owned(this_obj);
33535         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33536         ChannelManagerReadArgs_free(this_obj_conv);
33537 }
33538
33539 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1keys_1manager(JNIEnv *env, jclass clz, int64_t this_ptr) {
33540         LDKChannelManagerReadArgs this_ptr_conv;
33541         this_ptr_conv.inner = untag_ptr(this_ptr);
33542         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33543         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33544         this_ptr_conv.is_owned = false;
33545         // WARNING: This object doesn't live past this scope, needs clone!
33546         int64_t ret_ret = tag_ptr(ChannelManagerReadArgs_get_keys_manager(&this_ptr_conv), false);
33547         return ret_ret;
33548 }
33549
33550 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1keys_1manager(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
33551         LDKChannelManagerReadArgs this_ptr_conv;
33552         this_ptr_conv.inner = untag_ptr(this_ptr);
33553         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33554         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33555         this_ptr_conv.is_owned = false;
33556         void* val_ptr = untag_ptr(val);
33557         CHECK_ACCESS(val_ptr);
33558         LDKKeysInterface val_conv = *(LDKKeysInterface*)(val_ptr);
33559         if (val_conv.free == LDKKeysInterface_JCalls_free) {
33560                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
33561                 LDKKeysInterface_JCalls_cloned(&val_conv);
33562         }
33563         ChannelManagerReadArgs_set_keys_manager(&this_ptr_conv, val_conv);
33564 }
33565
33566 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1fee_1estimator(JNIEnv *env, jclass clz, int64_t this_ptr) {
33567         LDKChannelManagerReadArgs 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         // WARNING: This object doesn't live past this scope, needs clone!
33573         int64_t ret_ret = tag_ptr(ChannelManagerReadArgs_get_fee_estimator(&this_ptr_conv), false);
33574         return ret_ret;
33575 }
33576
33577 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1fee_1estimator(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
33578         LDKChannelManagerReadArgs this_ptr_conv;
33579         this_ptr_conv.inner = untag_ptr(this_ptr);
33580         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33581         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33582         this_ptr_conv.is_owned = false;
33583         void* val_ptr = untag_ptr(val);
33584         CHECK_ACCESS(val_ptr);
33585         LDKFeeEstimator val_conv = *(LDKFeeEstimator*)(val_ptr);
33586         if (val_conv.free == LDKFeeEstimator_JCalls_free) {
33587                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
33588                 LDKFeeEstimator_JCalls_cloned(&val_conv);
33589         }
33590         ChannelManagerReadArgs_set_fee_estimator(&this_ptr_conv, val_conv);
33591 }
33592
33593 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1chain_1monitor(JNIEnv *env, jclass clz, int64_t this_ptr) {
33594         LDKChannelManagerReadArgs this_ptr_conv;
33595         this_ptr_conv.inner = untag_ptr(this_ptr);
33596         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33597         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33598         this_ptr_conv.is_owned = false;
33599         // WARNING: This object doesn't live past this scope, needs clone!
33600         int64_t ret_ret = tag_ptr(ChannelManagerReadArgs_get_chain_monitor(&this_ptr_conv), false);
33601         return ret_ret;
33602 }
33603
33604 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1chain_1monitor(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
33605         LDKChannelManagerReadArgs 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         void* val_ptr = untag_ptr(val);
33611         CHECK_ACCESS(val_ptr);
33612         LDKWatch val_conv = *(LDKWatch*)(val_ptr);
33613         if (val_conv.free == LDKWatch_JCalls_free) {
33614                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
33615                 LDKWatch_JCalls_cloned(&val_conv);
33616         }
33617         ChannelManagerReadArgs_set_chain_monitor(&this_ptr_conv, val_conv);
33618 }
33619
33620 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1tx_1broadcaster(JNIEnv *env, jclass clz, int64_t this_ptr) {
33621         LDKChannelManagerReadArgs this_ptr_conv;
33622         this_ptr_conv.inner = untag_ptr(this_ptr);
33623         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33624         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33625         this_ptr_conv.is_owned = false;
33626         // WARNING: This object doesn't live past this scope, needs clone!
33627         int64_t ret_ret = tag_ptr(ChannelManagerReadArgs_get_tx_broadcaster(&this_ptr_conv), false);
33628         return ret_ret;
33629 }
33630
33631 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1tx_1broadcaster(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
33632         LDKChannelManagerReadArgs this_ptr_conv;
33633         this_ptr_conv.inner = untag_ptr(this_ptr);
33634         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33635         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33636         this_ptr_conv.is_owned = false;
33637         void* val_ptr = untag_ptr(val);
33638         CHECK_ACCESS(val_ptr);
33639         LDKBroadcasterInterface val_conv = *(LDKBroadcasterInterface*)(val_ptr);
33640         if (val_conv.free == LDKBroadcasterInterface_JCalls_free) {
33641                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
33642                 LDKBroadcasterInterface_JCalls_cloned(&val_conv);
33643         }
33644         ChannelManagerReadArgs_set_tx_broadcaster(&this_ptr_conv, val_conv);
33645 }
33646
33647 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1logger(JNIEnv *env, jclass clz, int64_t this_ptr) {
33648         LDKChannelManagerReadArgs this_ptr_conv;
33649         this_ptr_conv.inner = untag_ptr(this_ptr);
33650         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33651         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33652         this_ptr_conv.is_owned = false;
33653         // WARNING: This object doesn't live past this scope, needs clone!
33654         int64_t ret_ret = tag_ptr(ChannelManagerReadArgs_get_logger(&this_ptr_conv), false);
33655         return ret_ret;
33656 }
33657
33658 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1logger(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
33659         LDKChannelManagerReadArgs this_ptr_conv;
33660         this_ptr_conv.inner = untag_ptr(this_ptr);
33661         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33662         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33663         this_ptr_conv.is_owned = false;
33664         void* val_ptr = untag_ptr(val);
33665         CHECK_ACCESS(val_ptr);
33666         LDKLogger val_conv = *(LDKLogger*)(val_ptr);
33667         if (val_conv.free == LDKLogger_JCalls_free) {
33668                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
33669                 LDKLogger_JCalls_cloned(&val_conv);
33670         }
33671         ChannelManagerReadArgs_set_logger(&this_ptr_conv, val_conv);
33672 }
33673
33674 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1default_1config(JNIEnv *env, jclass clz, int64_t this_ptr) {
33675         LDKChannelManagerReadArgs this_ptr_conv;
33676         this_ptr_conv.inner = untag_ptr(this_ptr);
33677         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33678         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33679         this_ptr_conv.is_owned = false;
33680         LDKUserConfig ret_var = ChannelManagerReadArgs_get_default_config(&this_ptr_conv);
33681         int64_t ret_ref = 0;
33682         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33683         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
33684         return ret_ref;
33685 }
33686
33687 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1default_1config(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
33688         LDKChannelManagerReadArgs this_ptr_conv;
33689         this_ptr_conv.inner = untag_ptr(this_ptr);
33690         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33691         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33692         this_ptr_conv.is_owned = false;
33693         LDKUserConfig val_conv;
33694         val_conv.inner = untag_ptr(val);
33695         val_conv.is_owned = ptr_is_owned(val);
33696         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
33697         val_conv = UserConfig_clone(&val_conv);
33698         ChannelManagerReadArgs_set_default_config(&this_ptr_conv, val_conv);
33699 }
33700
33701 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) {
33702         void* keys_manager_ptr = untag_ptr(keys_manager);
33703         CHECK_ACCESS(keys_manager_ptr);
33704         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
33705         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
33706                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
33707                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
33708         }
33709         void* fee_estimator_ptr = untag_ptr(fee_estimator);
33710         CHECK_ACCESS(fee_estimator_ptr);
33711         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
33712         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
33713                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
33714                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
33715         }
33716         void* chain_monitor_ptr = untag_ptr(chain_monitor);
33717         CHECK_ACCESS(chain_monitor_ptr);
33718         LDKWatch chain_monitor_conv = *(LDKWatch*)(chain_monitor_ptr);
33719         if (chain_monitor_conv.free == LDKWatch_JCalls_free) {
33720                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
33721                 LDKWatch_JCalls_cloned(&chain_monitor_conv);
33722         }
33723         void* tx_broadcaster_ptr = untag_ptr(tx_broadcaster);
33724         CHECK_ACCESS(tx_broadcaster_ptr);
33725         LDKBroadcasterInterface tx_broadcaster_conv = *(LDKBroadcasterInterface*)(tx_broadcaster_ptr);
33726         if (tx_broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
33727                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
33728                 LDKBroadcasterInterface_JCalls_cloned(&tx_broadcaster_conv);
33729         }
33730         void* logger_ptr = untag_ptr(logger);
33731         CHECK_ACCESS(logger_ptr);
33732         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
33733         if (logger_conv.free == LDKLogger_JCalls_free) {
33734                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
33735                 LDKLogger_JCalls_cloned(&logger_conv);
33736         }
33737         LDKUserConfig default_config_conv;
33738         default_config_conv.inner = untag_ptr(default_config);
33739         default_config_conv.is_owned = ptr_is_owned(default_config);
33740         CHECK_INNER_FIELD_ACCESS_OR_NULL(default_config_conv);
33741         default_config_conv = UserConfig_clone(&default_config_conv);
33742         LDKCVec_ChannelMonitorZ channel_monitors_constr;
33743         channel_monitors_constr.datalen = (*env)->GetArrayLength(env, channel_monitors);
33744         if (channel_monitors_constr.datalen > 0)
33745                 channel_monitors_constr.data = MALLOC(channel_monitors_constr.datalen * sizeof(LDKChannelMonitor), "LDKCVec_ChannelMonitorZ Elements");
33746         else
33747                 channel_monitors_constr.data = NULL;
33748         int64_t* channel_monitors_vals = (*env)->GetLongArrayElements (env, channel_monitors, NULL);
33749         for (size_t q = 0; q < channel_monitors_constr.datalen; q++) {
33750                 int64_t channel_monitors_conv_16 = channel_monitors_vals[q];
33751                 LDKChannelMonitor channel_monitors_conv_16_conv;
33752                 channel_monitors_conv_16_conv.inner = untag_ptr(channel_monitors_conv_16);
33753                 channel_monitors_conv_16_conv.is_owned = ptr_is_owned(channel_monitors_conv_16);
33754                 CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_monitors_conv_16_conv);
33755                 channel_monitors_conv_16_conv.is_owned = false;
33756                 channel_monitors_constr.data[q] = channel_monitors_conv_16_conv;
33757         }
33758         (*env)->ReleaseLongArrayElements(env, channel_monitors, channel_monitors_vals, 0);
33759         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);
33760         int64_t ret_ref = 0;
33761         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33762         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
33763         return ret_ref;
33764 }
33765
33766 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelManagerZ_1read(JNIEnv *env, jclass clz, int8_tArray ser, int64_t arg) {
33767         LDKu8slice ser_ref;
33768         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
33769         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
33770         LDKChannelManagerReadArgs arg_conv;
33771         arg_conv.inner = untag_ptr(arg);
33772         arg_conv.is_owned = ptr_is_owned(arg);
33773         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
33774         // WARNING: we need a move here but no clone is available for LDKChannelManagerReadArgs
33775         
33776         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
33777         *ret_conv = C2Tuple_BlockHashChannelManagerZ_read(ser_ref, arg_conv);
33778         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
33779         return tag_ptr(ret_conv, true);
33780 }
33781
33782 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ExpandedKey_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
33783         LDKExpandedKey this_obj_conv;
33784         this_obj_conv.inner = untag_ptr(this_obj);
33785         this_obj_conv.is_owned = ptr_is_owned(this_obj);
33786         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33787         ExpandedKey_free(this_obj_conv);
33788 }
33789
33790 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpandedKey_1new(JNIEnv *env, jclass clz, int8_tArray key_material) {
33791         unsigned char key_material_arr[32];
33792         CHECK((*env)->GetArrayLength(env, key_material) == 32);
33793         (*env)->GetByteArrayRegion(env, key_material, 0, 32, key_material_arr);
33794         unsigned char (*key_material_ref)[32] = &key_material_arr;
33795         LDKExpandedKey ret_var = ExpandedKey_new(key_material_ref);
33796         int64_t ret_ref = 0;
33797         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33798         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
33799         return ret_ref;
33800 }
33801
33802 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) {
33803         LDKExpandedKey keys_conv;
33804         keys_conv.inner = untag_ptr(keys);
33805         keys_conv.is_owned = ptr_is_owned(keys);
33806         CHECK_INNER_FIELD_ACCESS_OR_NULL(keys_conv);
33807         keys_conv.is_owned = false;
33808         void* min_value_msat_ptr = untag_ptr(min_value_msat);
33809         CHECK_ACCESS(min_value_msat_ptr);
33810         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
33811         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(min_value_msat));
33812         void* keys_manager_ptr = untag_ptr(keys_manager);
33813         if (ptr_is_owned(keys_manager)) { CHECK_ACCESS(keys_manager_ptr); }
33814         LDKKeysInterface* keys_manager_conv = (LDKKeysInterface*)keys_manager_ptr;
33815         LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ), "LDKCResult_C2Tuple_PaymentHashPaymentSecretZNoneZ");
33816         *ret_conv = create(&keys_conv, min_value_msat_conv, invoice_expiry_delta_secs, keys_manager_conv, current_time);
33817         return tag_ptr(ret_conv, true);
33818 }
33819
33820 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) {
33821         LDKExpandedKey keys_conv;
33822         keys_conv.inner = untag_ptr(keys);
33823         keys_conv.is_owned = ptr_is_owned(keys);
33824         CHECK_INNER_FIELD_ACCESS_OR_NULL(keys_conv);
33825         keys_conv.is_owned = false;
33826         void* min_value_msat_ptr = untag_ptr(min_value_msat);
33827         CHECK_ACCESS(min_value_msat_ptr);
33828         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
33829         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(min_value_msat));
33830         LDKThirtyTwoBytes payment_hash_ref;
33831         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
33832         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
33833         LDKCResult_PaymentSecretNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretNoneZ), "LDKCResult_PaymentSecretNoneZ");
33834         *ret_conv = create_from_hash(&keys_conv, min_value_msat_conv, payment_hash_ref, invoice_expiry_delta_secs, current_time);
33835         return tag_ptr(ret_conv, true);
33836 }
33837
33838 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DecodeError_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
33839         if (!ptr_is_owned(this_ptr)) return;
33840         void* this_ptr_ptr = untag_ptr(this_ptr);
33841         CHECK_ACCESS(this_ptr_ptr);
33842         LDKDecodeError this_ptr_conv = *(LDKDecodeError*)(this_ptr_ptr);
33843         FREE(untag_ptr(this_ptr));
33844         DecodeError_free(this_ptr_conv);
33845 }
33846
33847 static inline uint64_t DecodeError_clone_ptr(LDKDecodeError *NONNULL_PTR arg) {
33848         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
33849         *ret_copy = DecodeError_clone(arg);
33850         int64_t ret_ref = tag_ptr(ret_copy, true);
33851         return ret_ref;
33852 }
33853 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DecodeError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
33854         LDKDecodeError* arg_conv = (LDKDecodeError*)untag_ptr(arg);
33855         int64_t ret_conv = DecodeError_clone_ptr(arg_conv);
33856         return ret_conv;
33857 }
33858
33859 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DecodeError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
33860         LDKDecodeError* orig_conv = (LDKDecodeError*)untag_ptr(orig);
33861         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
33862         *ret_copy = DecodeError_clone(orig_conv);
33863         int64_t ret_ref = tag_ptr(ret_copy, true);
33864         return ret_ref;
33865 }
33866
33867 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DecodeError_1unknown_1version(JNIEnv *env, jclass clz) {
33868         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
33869         *ret_copy = DecodeError_unknown_version();
33870         int64_t ret_ref = tag_ptr(ret_copy, true);
33871         return ret_ref;
33872 }
33873
33874 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DecodeError_1unknown_1required_1feature(JNIEnv *env, jclass clz) {
33875         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
33876         *ret_copy = DecodeError_unknown_required_feature();
33877         int64_t ret_ref = tag_ptr(ret_copy, true);
33878         return ret_ref;
33879 }
33880
33881 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DecodeError_1invalid_1value(JNIEnv *env, jclass clz) {
33882         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
33883         *ret_copy = DecodeError_invalid_value();
33884         int64_t ret_ref = tag_ptr(ret_copy, true);
33885         return ret_ref;
33886 }
33887
33888 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DecodeError_1short_1read(JNIEnv *env, jclass clz) {
33889         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
33890         *ret_copy = DecodeError_short_read();
33891         int64_t ret_ref = tag_ptr(ret_copy, true);
33892         return ret_ref;
33893 }
33894
33895 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DecodeError_1bad_1length_1descriptor(JNIEnv *env, jclass clz) {
33896         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
33897         *ret_copy = DecodeError_bad_length_descriptor();
33898         int64_t ret_ref = tag_ptr(ret_copy, true);
33899         return ret_ref;
33900 }
33901
33902 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DecodeError_1io(JNIEnv *env, jclass clz, jclass a) {
33903         LDKIOError a_conv = LDKIOError_from_java(env, a);
33904         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
33905         *ret_copy = DecodeError_io(a_conv);
33906         int64_t ret_ref = tag_ptr(ret_copy, true);
33907         return ret_ref;
33908 }
33909
33910 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DecodeError_1unsupported_1compression(JNIEnv *env, jclass clz) {
33911         LDKDecodeError *ret_copy = MALLOC(sizeof(LDKDecodeError), "LDKDecodeError");
33912         *ret_copy = DecodeError_unsupported_compression();
33913         int64_t ret_ref = tag_ptr(ret_copy, true);
33914         return ret_ref;
33915 }
33916
33917 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_DecodeError_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
33918         LDKDecodeError* a_conv = (LDKDecodeError*)untag_ptr(a);
33919         LDKDecodeError* b_conv = (LDKDecodeError*)untag_ptr(b);
33920         jboolean ret_conv = DecodeError_eq(a_conv, b_conv);
33921         return ret_conv;
33922 }
33923
33924 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Init_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
33925         LDKInit this_obj_conv;
33926         this_obj_conv.inner = untag_ptr(this_obj);
33927         this_obj_conv.is_owned = ptr_is_owned(this_obj);
33928         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33929         Init_free(this_obj_conv);
33930 }
33931
33932 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
33933         LDKInit this_ptr_conv;
33934         this_ptr_conv.inner = untag_ptr(this_ptr);
33935         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33936         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33937         this_ptr_conv.is_owned = false;
33938         LDKInitFeatures ret_var = Init_get_features(&this_ptr_conv);
33939         int64_t ret_ref = 0;
33940         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33941         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
33942         return ret_ref;
33943 }
33944
33945 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Init_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
33946         LDKInit this_ptr_conv;
33947         this_ptr_conv.inner = untag_ptr(this_ptr);
33948         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33949         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33950         this_ptr_conv.is_owned = false;
33951         LDKInitFeatures val_conv;
33952         val_conv.inner = untag_ptr(val);
33953         val_conv.is_owned = ptr_is_owned(val);
33954         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
33955         val_conv = InitFeatures_clone(&val_conv);
33956         Init_set_features(&this_ptr_conv, val_conv);
33957 }
33958
33959 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1get_1remote_1network_1address(JNIEnv *env, jclass clz, int64_t this_ptr) {
33960         LDKInit 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         LDKCOption_NetAddressZ *ret_copy = MALLOC(sizeof(LDKCOption_NetAddressZ), "LDKCOption_NetAddressZ");
33966         *ret_copy = Init_get_remote_network_address(&this_ptr_conv);
33967         int64_t ret_ref = tag_ptr(ret_copy, true);
33968         return ret_ref;
33969 }
33970
33971 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Init_1set_1remote_1network_1address(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
33972         LDKInit this_ptr_conv;
33973         this_ptr_conv.inner = untag_ptr(this_ptr);
33974         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
33975         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33976         this_ptr_conv.is_owned = false;
33977         void* val_ptr = untag_ptr(val);
33978         CHECK_ACCESS(val_ptr);
33979         LDKCOption_NetAddressZ val_conv = *(LDKCOption_NetAddressZ*)(val_ptr);
33980         val_conv = COption_NetAddressZ_clone((LDKCOption_NetAddressZ*)untag_ptr(val));
33981         Init_set_remote_network_address(&this_ptr_conv, val_conv);
33982 }
33983
33984 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) {
33985         LDKInitFeatures features_arg_conv;
33986         features_arg_conv.inner = untag_ptr(features_arg);
33987         features_arg_conv.is_owned = ptr_is_owned(features_arg);
33988         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_arg_conv);
33989         features_arg_conv = InitFeatures_clone(&features_arg_conv);
33990         void* remote_network_address_arg_ptr = untag_ptr(remote_network_address_arg);
33991         CHECK_ACCESS(remote_network_address_arg_ptr);
33992         LDKCOption_NetAddressZ remote_network_address_arg_conv = *(LDKCOption_NetAddressZ*)(remote_network_address_arg_ptr);
33993         LDKInit ret_var = Init_new(features_arg_conv, remote_network_address_arg_conv);
33994         int64_t ret_ref = 0;
33995         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33996         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
33997         return ret_ref;
33998 }
33999
34000 static inline uint64_t Init_clone_ptr(LDKInit *NONNULL_PTR arg) {
34001         LDKInit ret_var = Init_clone(arg);
34002         int64_t ret_ref = 0;
34003         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34004         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34005         return ret_ref;
34006 }
34007 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
34008         LDKInit arg_conv;
34009         arg_conv.inner = untag_ptr(arg);
34010         arg_conv.is_owned = ptr_is_owned(arg);
34011         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34012         arg_conv.is_owned = false;
34013         int64_t ret_conv = Init_clone_ptr(&arg_conv);
34014         return ret_conv;
34015 }
34016
34017 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1clone(JNIEnv *env, jclass clz, int64_t orig) {
34018         LDKInit orig_conv;
34019         orig_conv.inner = untag_ptr(orig);
34020         orig_conv.is_owned = ptr_is_owned(orig);
34021         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34022         orig_conv.is_owned = false;
34023         LDKInit ret_var = Init_clone(&orig_conv);
34024         int64_t ret_ref = 0;
34025         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34026         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34027         return ret_ref;
34028 }
34029
34030 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Init_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
34031         LDKInit a_conv;
34032         a_conv.inner = untag_ptr(a);
34033         a_conv.is_owned = ptr_is_owned(a);
34034         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
34035         a_conv.is_owned = false;
34036         LDKInit b_conv;
34037         b_conv.inner = untag_ptr(b);
34038         b_conv.is_owned = ptr_is_owned(b);
34039         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
34040         b_conv.is_owned = false;
34041         jboolean ret_conv = Init_eq(&a_conv, &b_conv);
34042         return ret_conv;
34043 }
34044
34045 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
34046         LDKErrorMessage this_obj_conv;
34047         this_obj_conv.inner = untag_ptr(this_obj);
34048         this_obj_conv.is_owned = ptr_is_owned(this_obj);
34049         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34050         ErrorMessage_free(this_obj_conv);
34051 }
34052
34053 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
34054         LDKErrorMessage this_ptr_conv;
34055         this_ptr_conv.inner = untag_ptr(this_ptr);
34056         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34057         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34058         this_ptr_conv.is_owned = false;
34059         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
34060         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ErrorMessage_get_channel_id(&this_ptr_conv));
34061         return ret_arr;
34062 }
34063
34064 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
34065         LDKErrorMessage this_ptr_conv;
34066         this_ptr_conv.inner = untag_ptr(this_ptr);
34067         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34068         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34069         this_ptr_conv.is_owned = false;
34070         LDKThirtyTwoBytes val_ref;
34071         CHECK((*env)->GetArrayLength(env, val) == 32);
34072         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
34073         ErrorMessage_set_channel_id(&this_ptr_conv, val_ref);
34074 }
34075
34076 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1get_1data(JNIEnv *env, jclass clz, int64_t this_ptr) {
34077         LDKErrorMessage this_ptr_conv;
34078         this_ptr_conv.inner = untag_ptr(this_ptr);
34079         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34080         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34081         this_ptr_conv.is_owned = false;
34082         LDKStr ret_str = ErrorMessage_get_data(&this_ptr_conv);
34083         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
34084         Str_free(ret_str);
34085         return ret_conv;
34086 }
34087
34088 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1set_1data(JNIEnv *env, jclass clz, int64_t this_ptr, jstring val) {
34089         LDKErrorMessage this_ptr_conv;
34090         this_ptr_conv.inner = untag_ptr(this_ptr);
34091         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34092         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34093         this_ptr_conv.is_owned = false;
34094         LDKStr val_conv = java_to_owned_str(env, val);
34095         ErrorMessage_set_data(&this_ptr_conv, val_conv);
34096 }
34097
34098 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1new(JNIEnv *env, jclass clz, int8_tArray channel_id_arg, jstring data_arg) {
34099         LDKThirtyTwoBytes channel_id_arg_ref;
34100         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
34101         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
34102         LDKStr data_arg_conv = java_to_owned_str(env, data_arg);
34103         LDKErrorMessage ret_var = ErrorMessage_new(channel_id_arg_ref, data_arg_conv);
34104         int64_t ret_ref = 0;
34105         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34106         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34107         return ret_ref;
34108 }
34109
34110 static inline uint64_t ErrorMessage_clone_ptr(LDKErrorMessage *NONNULL_PTR arg) {
34111         LDKErrorMessage ret_var = ErrorMessage_clone(arg);
34112         int64_t ret_ref = 0;
34113         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34114         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34115         return ret_ref;
34116 }
34117 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
34118         LDKErrorMessage arg_conv;
34119         arg_conv.inner = untag_ptr(arg);
34120         arg_conv.is_owned = ptr_is_owned(arg);
34121         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34122         arg_conv.is_owned = false;
34123         int64_t ret_conv = ErrorMessage_clone_ptr(&arg_conv);
34124         return ret_conv;
34125 }
34126
34127 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1clone(JNIEnv *env, jclass clz, int64_t orig) {
34128         LDKErrorMessage orig_conv;
34129         orig_conv.inner = untag_ptr(orig);
34130         orig_conv.is_owned = ptr_is_owned(orig);
34131         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34132         orig_conv.is_owned = false;
34133         LDKErrorMessage ret_var = ErrorMessage_clone(&orig_conv);
34134         int64_t ret_ref = 0;
34135         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34136         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34137         return ret_ref;
34138 }
34139
34140 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
34141         LDKErrorMessage a_conv;
34142         a_conv.inner = untag_ptr(a);
34143         a_conv.is_owned = ptr_is_owned(a);
34144         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
34145         a_conv.is_owned = false;
34146         LDKErrorMessage b_conv;
34147         b_conv.inner = untag_ptr(b);
34148         b_conv.is_owned = ptr_is_owned(b);
34149         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
34150         b_conv.is_owned = false;
34151         jboolean ret_conv = ErrorMessage_eq(&a_conv, &b_conv);
34152         return ret_conv;
34153 }
34154
34155 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WarningMessage_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
34156         LDKWarningMessage this_obj_conv;
34157         this_obj_conv.inner = untag_ptr(this_obj);
34158         this_obj_conv.is_owned = ptr_is_owned(this_obj);
34159         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34160         WarningMessage_free(this_obj_conv);
34161 }
34162
34163 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_WarningMessage_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
34164         LDKWarningMessage this_ptr_conv;
34165         this_ptr_conv.inner = untag_ptr(this_ptr);
34166         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34167         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34168         this_ptr_conv.is_owned = false;
34169         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
34170         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *WarningMessage_get_channel_id(&this_ptr_conv));
34171         return ret_arr;
34172 }
34173
34174 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WarningMessage_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
34175         LDKWarningMessage this_ptr_conv;
34176         this_ptr_conv.inner = untag_ptr(this_ptr);
34177         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34178         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34179         this_ptr_conv.is_owned = false;
34180         LDKThirtyTwoBytes val_ref;
34181         CHECK((*env)->GetArrayLength(env, val) == 32);
34182         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
34183         WarningMessage_set_channel_id(&this_ptr_conv, val_ref);
34184 }
34185
34186 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_WarningMessage_1get_1data(JNIEnv *env, jclass clz, int64_t this_ptr) {
34187         LDKWarningMessage this_ptr_conv;
34188         this_ptr_conv.inner = untag_ptr(this_ptr);
34189         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34190         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34191         this_ptr_conv.is_owned = false;
34192         LDKStr ret_str = WarningMessage_get_data(&this_ptr_conv);
34193         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
34194         Str_free(ret_str);
34195         return ret_conv;
34196 }
34197
34198 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WarningMessage_1set_1data(JNIEnv *env, jclass clz, int64_t this_ptr, jstring val) {
34199         LDKWarningMessage this_ptr_conv;
34200         this_ptr_conv.inner = untag_ptr(this_ptr);
34201         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34202         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34203         this_ptr_conv.is_owned = false;
34204         LDKStr val_conv = java_to_owned_str(env, val);
34205         WarningMessage_set_data(&this_ptr_conv, val_conv);
34206 }
34207
34208 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WarningMessage_1new(JNIEnv *env, jclass clz, int8_tArray channel_id_arg, jstring data_arg) {
34209         LDKThirtyTwoBytes channel_id_arg_ref;
34210         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
34211         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
34212         LDKStr data_arg_conv = java_to_owned_str(env, data_arg);
34213         LDKWarningMessage ret_var = WarningMessage_new(channel_id_arg_ref, data_arg_conv);
34214         int64_t ret_ref = 0;
34215         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34216         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34217         return ret_ref;
34218 }
34219
34220 static inline uint64_t WarningMessage_clone_ptr(LDKWarningMessage *NONNULL_PTR arg) {
34221         LDKWarningMessage ret_var = WarningMessage_clone(arg);
34222         int64_t ret_ref = 0;
34223         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34224         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34225         return ret_ref;
34226 }
34227 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WarningMessage_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
34228         LDKWarningMessage arg_conv;
34229         arg_conv.inner = untag_ptr(arg);
34230         arg_conv.is_owned = ptr_is_owned(arg);
34231         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34232         arg_conv.is_owned = false;
34233         int64_t ret_conv = WarningMessage_clone_ptr(&arg_conv);
34234         return ret_conv;
34235 }
34236
34237 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WarningMessage_1clone(JNIEnv *env, jclass clz, int64_t orig) {
34238         LDKWarningMessage orig_conv;
34239         orig_conv.inner = untag_ptr(orig);
34240         orig_conv.is_owned = ptr_is_owned(orig);
34241         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34242         orig_conv.is_owned = false;
34243         LDKWarningMessage ret_var = WarningMessage_clone(&orig_conv);
34244         int64_t ret_ref = 0;
34245         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34246         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34247         return ret_ref;
34248 }
34249
34250 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_WarningMessage_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
34251         LDKWarningMessage a_conv;
34252         a_conv.inner = untag_ptr(a);
34253         a_conv.is_owned = ptr_is_owned(a);
34254         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
34255         a_conv.is_owned = false;
34256         LDKWarningMessage b_conv;
34257         b_conv.inner = untag_ptr(b);
34258         b_conv.is_owned = ptr_is_owned(b);
34259         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
34260         b_conv.is_owned = false;
34261         jboolean ret_conv = WarningMessage_eq(&a_conv, &b_conv);
34262         return ret_conv;
34263 }
34264
34265 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Ping_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
34266         LDKPing this_obj_conv;
34267         this_obj_conv.inner = untag_ptr(this_obj);
34268         this_obj_conv.is_owned = ptr_is_owned(this_obj);
34269         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34270         Ping_free(this_obj_conv);
34271 }
34272
34273 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_Ping_1get_1ponglen(JNIEnv *env, jclass clz, int64_t this_ptr) {
34274         LDKPing this_ptr_conv;
34275         this_ptr_conv.inner = untag_ptr(this_ptr);
34276         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34277         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34278         this_ptr_conv.is_owned = false;
34279         int16_t ret_conv = Ping_get_ponglen(&this_ptr_conv);
34280         return ret_conv;
34281 }
34282
34283 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Ping_1set_1ponglen(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
34284         LDKPing this_ptr_conv;
34285         this_ptr_conv.inner = untag_ptr(this_ptr);
34286         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34287         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34288         this_ptr_conv.is_owned = false;
34289         Ping_set_ponglen(&this_ptr_conv, val);
34290 }
34291
34292 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_Ping_1get_1byteslen(JNIEnv *env, jclass clz, int64_t this_ptr) {
34293         LDKPing this_ptr_conv;
34294         this_ptr_conv.inner = untag_ptr(this_ptr);
34295         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34296         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34297         this_ptr_conv.is_owned = false;
34298         int16_t ret_conv = Ping_get_byteslen(&this_ptr_conv);
34299         return ret_conv;
34300 }
34301
34302 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Ping_1set_1byteslen(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
34303         LDKPing this_ptr_conv;
34304         this_ptr_conv.inner = untag_ptr(this_ptr);
34305         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34306         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34307         this_ptr_conv.is_owned = false;
34308         Ping_set_byteslen(&this_ptr_conv, val);
34309 }
34310
34311 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Ping_1new(JNIEnv *env, jclass clz, int16_t ponglen_arg, int16_t byteslen_arg) {
34312         LDKPing ret_var = Ping_new(ponglen_arg, byteslen_arg);
34313         int64_t ret_ref = 0;
34314         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34315         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34316         return ret_ref;
34317 }
34318
34319 static inline uint64_t Ping_clone_ptr(LDKPing *NONNULL_PTR arg) {
34320         LDKPing ret_var = Ping_clone(arg);
34321         int64_t ret_ref = 0;
34322         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34323         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34324         return ret_ref;
34325 }
34326 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Ping_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
34327         LDKPing arg_conv;
34328         arg_conv.inner = untag_ptr(arg);
34329         arg_conv.is_owned = ptr_is_owned(arg);
34330         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34331         arg_conv.is_owned = false;
34332         int64_t ret_conv = Ping_clone_ptr(&arg_conv);
34333         return ret_conv;
34334 }
34335
34336 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Ping_1clone(JNIEnv *env, jclass clz, int64_t orig) {
34337         LDKPing orig_conv;
34338         orig_conv.inner = untag_ptr(orig);
34339         orig_conv.is_owned = ptr_is_owned(orig);
34340         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34341         orig_conv.is_owned = false;
34342         LDKPing ret_var = Ping_clone(&orig_conv);
34343         int64_t ret_ref = 0;
34344         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34345         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34346         return ret_ref;
34347 }
34348
34349 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Ping_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
34350         LDKPing a_conv;
34351         a_conv.inner = untag_ptr(a);
34352         a_conv.is_owned = ptr_is_owned(a);
34353         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
34354         a_conv.is_owned = false;
34355         LDKPing b_conv;
34356         b_conv.inner = untag_ptr(b);
34357         b_conv.is_owned = ptr_is_owned(b);
34358         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
34359         b_conv.is_owned = false;
34360         jboolean ret_conv = Ping_eq(&a_conv, &b_conv);
34361         return ret_conv;
34362 }
34363
34364 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Pong_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
34365         LDKPong this_obj_conv;
34366         this_obj_conv.inner = untag_ptr(this_obj);
34367         this_obj_conv.is_owned = ptr_is_owned(this_obj);
34368         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34369         Pong_free(this_obj_conv);
34370 }
34371
34372 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_Pong_1get_1byteslen(JNIEnv *env, jclass clz, int64_t this_ptr) {
34373         LDKPong this_ptr_conv;
34374         this_ptr_conv.inner = untag_ptr(this_ptr);
34375         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34376         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34377         this_ptr_conv.is_owned = false;
34378         int16_t ret_conv = Pong_get_byteslen(&this_ptr_conv);
34379         return ret_conv;
34380 }
34381
34382 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Pong_1set_1byteslen(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
34383         LDKPong this_ptr_conv;
34384         this_ptr_conv.inner = untag_ptr(this_ptr);
34385         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34386         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34387         this_ptr_conv.is_owned = false;
34388         Pong_set_byteslen(&this_ptr_conv, val);
34389 }
34390
34391 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Pong_1new(JNIEnv *env, jclass clz, int16_t byteslen_arg) {
34392         LDKPong ret_var = Pong_new(byteslen_arg);
34393         int64_t ret_ref = 0;
34394         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34395         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34396         return ret_ref;
34397 }
34398
34399 static inline uint64_t Pong_clone_ptr(LDKPong *NONNULL_PTR arg) {
34400         LDKPong ret_var = Pong_clone(arg);
34401         int64_t ret_ref = 0;
34402         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34403         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34404         return ret_ref;
34405 }
34406 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Pong_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
34407         LDKPong arg_conv;
34408         arg_conv.inner = untag_ptr(arg);
34409         arg_conv.is_owned = ptr_is_owned(arg);
34410         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34411         arg_conv.is_owned = false;
34412         int64_t ret_conv = Pong_clone_ptr(&arg_conv);
34413         return ret_conv;
34414 }
34415
34416 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Pong_1clone(JNIEnv *env, jclass clz, int64_t orig) {
34417         LDKPong orig_conv;
34418         orig_conv.inner = untag_ptr(orig);
34419         orig_conv.is_owned = ptr_is_owned(orig);
34420         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34421         orig_conv.is_owned = false;
34422         LDKPong ret_var = Pong_clone(&orig_conv);
34423         int64_t ret_ref = 0;
34424         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34425         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34426         return ret_ref;
34427 }
34428
34429 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Pong_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
34430         LDKPong a_conv;
34431         a_conv.inner = untag_ptr(a);
34432         a_conv.is_owned = ptr_is_owned(a);
34433         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
34434         a_conv.is_owned = false;
34435         LDKPong b_conv;
34436         b_conv.inner = untag_ptr(b);
34437         b_conv.is_owned = ptr_is_owned(b);
34438         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
34439         b_conv.is_owned = false;
34440         jboolean ret_conv = Pong_eq(&a_conv, &b_conv);
34441         return ret_conv;
34442 }
34443
34444 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
34445         LDKOpenChannel this_obj_conv;
34446         this_obj_conv.inner = untag_ptr(this_obj);
34447         this_obj_conv.is_owned = ptr_is_owned(this_obj);
34448         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34449         OpenChannel_free(this_obj_conv);
34450 }
34451
34452 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
34453         LDKOpenChannel this_ptr_conv;
34454         this_ptr_conv.inner = untag_ptr(this_ptr);
34455         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34456         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34457         this_ptr_conv.is_owned = false;
34458         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
34459         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *OpenChannel_get_chain_hash(&this_ptr_conv));
34460         return ret_arr;
34461 }
34462
34463 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
34464         LDKOpenChannel this_ptr_conv;
34465         this_ptr_conv.inner = untag_ptr(this_ptr);
34466         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34467         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34468         this_ptr_conv.is_owned = false;
34469         LDKThirtyTwoBytes val_ref;
34470         CHECK((*env)->GetArrayLength(env, val) == 32);
34471         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
34472         OpenChannel_set_chain_hash(&this_ptr_conv, val_ref);
34473 }
34474
34475 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
34476         LDKOpenChannel this_ptr_conv;
34477         this_ptr_conv.inner = untag_ptr(this_ptr);
34478         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34479         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34480         this_ptr_conv.is_owned = false;
34481         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
34482         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *OpenChannel_get_temporary_channel_id(&this_ptr_conv));
34483         return ret_arr;
34484 }
34485
34486 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
34487         LDKOpenChannel 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         LDKThirtyTwoBytes val_ref;
34493         CHECK((*env)->GetArrayLength(env, val) == 32);
34494         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
34495         OpenChannel_set_temporary_channel_id(&this_ptr_conv, val_ref);
34496 }
34497
34498 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
34499         LDKOpenChannel this_ptr_conv;
34500         this_ptr_conv.inner = untag_ptr(this_ptr);
34501         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34502         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34503         this_ptr_conv.is_owned = false;
34504         int64_t ret_conv = OpenChannel_get_funding_satoshis(&this_ptr_conv);
34505         return ret_conv;
34506 }
34507
34508 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
34509         LDKOpenChannel this_ptr_conv;
34510         this_ptr_conv.inner = untag_ptr(this_ptr);
34511         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34512         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34513         this_ptr_conv.is_owned = false;
34514         OpenChannel_set_funding_satoshis(&this_ptr_conv, val);
34515 }
34516
34517 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1push_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
34518         LDKOpenChannel this_ptr_conv;
34519         this_ptr_conv.inner = untag_ptr(this_ptr);
34520         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34521         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34522         this_ptr_conv.is_owned = false;
34523         int64_t ret_conv = OpenChannel_get_push_msat(&this_ptr_conv);
34524         return ret_conv;
34525 }
34526
34527 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1push_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
34528         LDKOpenChannel this_ptr_conv;
34529         this_ptr_conv.inner = untag_ptr(this_ptr);
34530         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34531         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34532         this_ptr_conv.is_owned = false;
34533         OpenChannel_set_push_msat(&this_ptr_conv, val);
34534 }
34535
34536 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1dust_1limit_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
34537         LDKOpenChannel this_ptr_conv;
34538         this_ptr_conv.inner = untag_ptr(this_ptr);
34539         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34540         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34541         this_ptr_conv.is_owned = false;
34542         int64_t ret_conv = OpenChannel_get_dust_limit_satoshis(&this_ptr_conv);
34543         return ret_conv;
34544 }
34545
34546 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1dust_1limit_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
34547         LDKOpenChannel this_ptr_conv;
34548         this_ptr_conv.inner = untag_ptr(this_ptr);
34549         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34550         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34551         this_ptr_conv.is_owned = false;
34552         OpenChannel_set_dust_limit_satoshis(&this_ptr_conv, val);
34553 }
34554
34555 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) {
34556         LDKOpenChannel this_ptr_conv;
34557         this_ptr_conv.inner = untag_ptr(this_ptr);
34558         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34559         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34560         this_ptr_conv.is_owned = false;
34561         int64_t ret_conv = OpenChannel_get_max_htlc_value_in_flight_msat(&this_ptr_conv);
34562         return ret_conv;
34563 }
34564
34565 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) {
34566         LDKOpenChannel this_ptr_conv;
34567         this_ptr_conv.inner = untag_ptr(this_ptr);
34568         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34569         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34570         this_ptr_conv.is_owned = false;
34571         OpenChannel_set_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
34572 }
34573
34574 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
34575         LDKOpenChannel this_ptr_conv;
34576         this_ptr_conv.inner = untag_ptr(this_ptr);
34577         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34578         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34579         this_ptr_conv.is_owned = false;
34580         int64_t ret_conv = OpenChannel_get_channel_reserve_satoshis(&this_ptr_conv);
34581         return ret_conv;
34582 }
34583
34584 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
34585         LDKOpenChannel this_ptr_conv;
34586         this_ptr_conv.inner = untag_ptr(this_ptr);
34587         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34588         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34589         this_ptr_conv.is_owned = false;
34590         OpenChannel_set_channel_reserve_satoshis(&this_ptr_conv, val);
34591 }
34592
34593 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
34594         LDKOpenChannel this_ptr_conv;
34595         this_ptr_conv.inner = untag_ptr(this_ptr);
34596         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34597         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34598         this_ptr_conv.is_owned = false;
34599         int64_t ret_conv = OpenChannel_get_htlc_minimum_msat(&this_ptr_conv);
34600         return ret_conv;
34601 }
34602
34603 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
34604         LDKOpenChannel this_ptr_conv;
34605         this_ptr_conv.inner = untag_ptr(this_ptr);
34606         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34607         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34608         this_ptr_conv.is_owned = false;
34609         OpenChannel_set_htlc_minimum_msat(&this_ptr_conv, val);
34610 }
34611
34612 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_ptr) {
34613         LDKOpenChannel this_ptr_conv;
34614         this_ptr_conv.inner = untag_ptr(this_ptr);
34615         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34616         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34617         this_ptr_conv.is_owned = false;
34618         int32_t ret_conv = OpenChannel_get_feerate_per_kw(&this_ptr_conv);
34619         return ret_conv;
34620 }
34621
34622 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
34623         LDKOpenChannel this_ptr_conv;
34624         this_ptr_conv.inner = untag_ptr(this_ptr);
34625         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34626         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34627         this_ptr_conv.is_owned = false;
34628         OpenChannel_set_feerate_per_kw(&this_ptr_conv, val);
34629 }
34630
34631 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
34632         LDKOpenChannel this_ptr_conv;
34633         this_ptr_conv.inner = untag_ptr(this_ptr);
34634         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34635         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34636         this_ptr_conv.is_owned = false;
34637         int16_t ret_conv = OpenChannel_get_to_self_delay(&this_ptr_conv);
34638         return ret_conv;
34639 }
34640
34641 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
34642         LDKOpenChannel this_ptr_conv;
34643         this_ptr_conv.inner = untag_ptr(this_ptr);
34644         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34645         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34646         this_ptr_conv.is_owned = false;
34647         OpenChannel_set_to_self_delay(&this_ptr_conv, val);
34648 }
34649
34650 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
34651         LDKOpenChannel this_ptr_conv;
34652         this_ptr_conv.inner = untag_ptr(this_ptr);
34653         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34654         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34655         this_ptr_conv.is_owned = false;
34656         int16_t ret_conv = OpenChannel_get_max_accepted_htlcs(&this_ptr_conv);
34657         return ret_conv;
34658 }
34659
34660 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
34661         LDKOpenChannel this_ptr_conv;
34662         this_ptr_conv.inner = untag_ptr(this_ptr);
34663         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34664         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34665         this_ptr_conv.is_owned = false;
34666         OpenChannel_set_max_accepted_htlcs(&this_ptr_conv, val);
34667 }
34668
34669 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
34670         LDKOpenChannel this_ptr_conv;
34671         this_ptr_conv.inner = untag_ptr(this_ptr);
34672         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34673         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34674         this_ptr_conv.is_owned = false;
34675         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
34676         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_funding_pubkey(&this_ptr_conv).compressed_form);
34677         return ret_arr;
34678 }
34679
34680 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
34681         LDKOpenChannel this_ptr_conv;
34682         this_ptr_conv.inner = untag_ptr(this_ptr);
34683         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34684         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34685         this_ptr_conv.is_owned = false;
34686         LDKPublicKey val_ref;
34687         CHECK((*env)->GetArrayLength(env, val) == 33);
34688         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
34689         OpenChannel_set_funding_pubkey(&this_ptr_conv, val_ref);
34690 }
34691
34692 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
34693         LDKOpenChannel this_ptr_conv;
34694         this_ptr_conv.inner = untag_ptr(this_ptr);
34695         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34696         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34697         this_ptr_conv.is_owned = false;
34698         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
34699         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_revocation_basepoint(&this_ptr_conv).compressed_form);
34700         return ret_arr;
34701 }
34702
34703 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
34704         LDKOpenChannel this_ptr_conv;
34705         this_ptr_conv.inner = untag_ptr(this_ptr);
34706         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34707         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34708         this_ptr_conv.is_owned = false;
34709         LDKPublicKey val_ref;
34710         CHECK((*env)->GetArrayLength(env, val) == 33);
34711         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
34712         OpenChannel_set_revocation_basepoint(&this_ptr_conv, val_ref);
34713 }
34714
34715 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
34716         LDKOpenChannel this_ptr_conv;
34717         this_ptr_conv.inner = untag_ptr(this_ptr);
34718         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34719         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34720         this_ptr_conv.is_owned = false;
34721         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
34722         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_payment_point(&this_ptr_conv).compressed_form);
34723         return ret_arr;
34724 }
34725
34726 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
34727         LDKOpenChannel this_ptr_conv;
34728         this_ptr_conv.inner = untag_ptr(this_ptr);
34729         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34730         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34731         this_ptr_conv.is_owned = false;
34732         LDKPublicKey val_ref;
34733         CHECK((*env)->GetArrayLength(env, val) == 33);
34734         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
34735         OpenChannel_set_payment_point(&this_ptr_conv, val_ref);
34736 }
34737
34738 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
34739         LDKOpenChannel this_ptr_conv;
34740         this_ptr_conv.inner = untag_ptr(this_ptr);
34741         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34742         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34743         this_ptr_conv.is_owned = false;
34744         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
34745         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form);
34746         return ret_arr;
34747 }
34748
34749 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
34750         LDKOpenChannel this_ptr_conv;
34751         this_ptr_conv.inner = untag_ptr(this_ptr);
34752         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34753         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34754         this_ptr_conv.is_owned = false;
34755         LDKPublicKey val_ref;
34756         CHECK((*env)->GetArrayLength(env, val) == 33);
34757         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
34758         OpenChannel_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
34759 }
34760
34761 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
34762         LDKOpenChannel this_ptr_conv;
34763         this_ptr_conv.inner = untag_ptr(this_ptr);
34764         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34765         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34766         this_ptr_conv.is_owned = false;
34767         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
34768         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_htlc_basepoint(&this_ptr_conv).compressed_form);
34769         return ret_arr;
34770 }
34771
34772 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
34773         LDKOpenChannel this_ptr_conv;
34774         this_ptr_conv.inner = untag_ptr(this_ptr);
34775         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34776         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34777         this_ptr_conv.is_owned = false;
34778         LDKPublicKey val_ref;
34779         CHECK((*env)->GetArrayLength(env, val) == 33);
34780         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
34781         OpenChannel_set_htlc_basepoint(&this_ptr_conv, val_ref);
34782 }
34783
34784 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1first_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
34785         LDKOpenChannel this_ptr_conv;
34786         this_ptr_conv.inner = untag_ptr(this_ptr);
34787         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34788         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34789         this_ptr_conv.is_owned = false;
34790         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
34791         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_first_per_commitment_point(&this_ptr_conv).compressed_form);
34792         return ret_arr;
34793 }
34794
34795 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) {
34796         LDKOpenChannel this_ptr_conv;
34797         this_ptr_conv.inner = untag_ptr(this_ptr);
34798         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34799         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34800         this_ptr_conv.is_owned = false;
34801         LDKPublicKey val_ref;
34802         CHECK((*env)->GetArrayLength(env, val) == 33);
34803         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
34804         OpenChannel_set_first_per_commitment_point(&this_ptr_conv, val_ref);
34805 }
34806
34807 JNIEXPORT int8_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1channel_1flags(JNIEnv *env, jclass clz, int64_t this_ptr) {
34808         LDKOpenChannel this_ptr_conv;
34809         this_ptr_conv.inner = untag_ptr(this_ptr);
34810         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34811         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34812         this_ptr_conv.is_owned = false;
34813         int8_t ret_conv = OpenChannel_get_channel_flags(&this_ptr_conv);
34814         return ret_conv;
34815 }
34816
34817 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1channel_1flags(JNIEnv *env, jclass clz, int64_t this_ptr, int8_t val) {
34818         LDKOpenChannel this_ptr_conv;
34819         this_ptr_conv.inner = untag_ptr(this_ptr);
34820         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34821         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34822         this_ptr_conv.is_owned = false;
34823         OpenChannel_set_channel_flags(&this_ptr_conv, val);
34824 }
34825
34826 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1channel_1type(JNIEnv *env, jclass clz, int64_t this_ptr) {
34827         LDKOpenChannel this_ptr_conv;
34828         this_ptr_conv.inner = untag_ptr(this_ptr);
34829         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34830         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34831         this_ptr_conv.is_owned = false;
34832         LDKChannelTypeFeatures ret_var = OpenChannel_get_channel_type(&this_ptr_conv);
34833         int64_t ret_ref = 0;
34834         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34835         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34836         return ret_ref;
34837 }
34838
34839 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1channel_1type(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
34840         LDKOpenChannel this_ptr_conv;
34841         this_ptr_conv.inner = untag_ptr(this_ptr);
34842         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34843         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34844         this_ptr_conv.is_owned = false;
34845         LDKChannelTypeFeatures val_conv;
34846         val_conv.inner = untag_ptr(val);
34847         val_conv.is_owned = ptr_is_owned(val);
34848         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
34849         val_conv = ChannelTypeFeatures_clone(&val_conv);
34850         OpenChannel_set_channel_type(&this_ptr_conv, val_conv);
34851 }
34852
34853 static inline uint64_t OpenChannel_clone_ptr(LDKOpenChannel *NONNULL_PTR arg) {
34854         LDKOpenChannel ret_var = OpenChannel_clone(arg);
34855         int64_t ret_ref = 0;
34856         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34857         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34858         return ret_ref;
34859 }
34860 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
34861         LDKOpenChannel arg_conv;
34862         arg_conv.inner = untag_ptr(arg);
34863         arg_conv.is_owned = ptr_is_owned(arg);
34864         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34865         arg_conv.is_owned = false;
34866         int64_t ret_conv = OpenChannel_clone_ptr(&arg_conv);
34867         return ret_conv;
34868 }
34869
34870 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1clone(JNIEnv *env, jclass clz, int64_t orig) {
34871         LDKOpenChannel orig_conv;
34872         orig_conv.inner = untag_ptr(orig);
34873         orig_conv.is_owned = ptr_is_owned(orig);
34874         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34875         orig_conv.is_owned = false;
34876         LDKOpenChannel ret_var = OpenChannel_clone(&orig_conv);
34877         int64_t ret_ref = 0;
34878         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34879         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
34880         return ret_ref;
34881 }
34882
34883 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_OpenChannel_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
34884         LDKOpenChannel a_conv;
34885         a_conv.inner = untag_ptr(a);
34886         a_conv.is_owned = ptr_is_owned(a);
34887         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
34888         a_conv.is_owned = false;
34889         LDKOpenChannel b_conv;
34890         b_conv.inner = untag_ptr(b);
34891         b_conv.is_owned = ptr_is_owned(b);
34892         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
34893         b_conv.is_owned = false;
34894         jboolean ret_conv = OpenChannel_eq(&a_conv, &b_conv);
34895         return ret_conv;
34896 }
34897
34898 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
34899         LDKAcceptChannel this_obj_conv;
34900         this_obj_conv.inner = untag_ptr(this_obj);
34901         this_obj_conv.is_owned = ptr_is_owned(this_obj);
34902         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34903         AcceptChannel_free(this_obj_conv);
34904 }
34905
34906 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
34907         LDKAcceptChannel this_ptr_conv;
34908         this_ptr_conv.inner = untag_ptr(this_ptr);
34909         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34910         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34911         this_ptr_conv.is_owned = false;
34912         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
34913         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *AcceptChannel_get_temporary_channel_id(&this_ptr_conv));
34914         return ret_arr;
34915 }
34916
34917 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
34918         LDKAcceptChannel this_ptr_conv;
34919         this_ptr_conv.inner = untag_ptr(this_ptr);
34920         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34921         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34922         this_ptr_conv.is_owned = false;
34923         LDKThirtyTwoBytes val_ref;
34924         CHECK((*env)->GetArrayLength(env, val) == 32);
34925         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
34926         AcceptChannel_set_temporary_channel_id(&this_ptr_conv, val_ref);
34927 }
34928
34929 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1dust_1limit_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
34930         LDKAcceptChannel this_ptr_conv;
34931         this_ptr_conv.inner = untag_ptr(this_ptr);
34932         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34933         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34934         this_ptr_conv.is_owned = false;
34935         int64_t ret_conv = AcceptChannel_get_dust_limit_satoshis(&this_ptr_conv);
34936         return ret_conv;
34937 }
34938
34939 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1dust_1limit_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
34940         LDKAcceptChannel this_ptr_conv;
34941         this_ptr_conv.inner = untag_ptr(this_ptr);
34942         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34943         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34944         this_ptr_conv.is_owned = false;
34945         AcceptChannel_set_dust_limit_satoshis(&this_ptr_conv, val);
34946 }
34947
34948 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) {
34949         LDKAcceptChannel this_ptr_conv;
34950         this_ptr_conv.inner = untag_ptr(this_ptr);
34951         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34952         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34953         this_ptr_conv.is_owned = false;
34954         int64_t ret_conv = AcceptChannel_get_max_htlc_value_in_flight_msat(&this_ptr_conv);
34955         return ret_conv;
34956 }
34957
34958 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) {
34959         LDKAcceptChannel this_ptr_conv;
34960         this_ptr_conv.inner = untag_ptr(this_ptr);
34961         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34962         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34963         this_ptr_conv.is_owned = false;
34964         AcceptChannel_set_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
34965 }
34966
34967 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
34968         LDKAcceptChannel this_ptr_conv;
34969         this_ptr_conv.inner = untag_ptr(this_ptr);
34970         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34971         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34972         this_ptr_conv.is_owned = false;
34973         int64_t ret_conv = AcceptChannel_get_channel_reserve_satoshis(&this_ptr_conv);
34974         return ret_conv;
34975 }
34976
34977 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
34978         LDKAcceptChannel this_ptr_conv;
34979         this_ptr_conv.inner = untag_ptr(this_ptr);
34980         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34981         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34982         this_ptr_conv.is_owned = false;
34983         AcceptChannel_set_channel_reserve_satoshis(&this_ptr_conv, val);
34984 }
34985
34986 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
34987         LDKAcceptChannel this_ptr_conv;
34988         this_ptr_conv.inner = untag_ptr(this_ptr);
34989         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
34990         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34991         this_ptr_conv.is_owned = false;
34992         int64_t ret_conv = AcceptChannel_get_htlc_minimum_msat(&this_ptr_conv);
34993         return ret_conv;
34994 }
34995
34996 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
34997         LDKAcceptChannel this_ptr_conv;
34998         this_ptr_conv.inner = untag_ptr(this_ptr);
34999         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35000         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35001         this_ptr_conv.is_owned = false;
35002         AcceptChannel_set_htlc_minimum_msat(&this_ptr_conv, val);
35003 }
35004
35005 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr) {
35006         LDKAcceptChannel this_ptr_conv;
35007         this_ptr_conv.inner = untag_ptr(this_ptr);
35008         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35009         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35010         this_ptr_conv.is_owned = false;
35011         int32_t ret_conv = AcceptChannel_get_minimum_depth(&this_ptr_conv);
35012         return ret_conv;
35013 }
35014
35015 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
35016         LDKAcceptChannel this_ptr_conv;
35017         this_ptr_conv.inner = untag_ptr(this_ptr);
35018         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35019         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35020         this_ptr_conv.is_owned = false;
35021         AcceptChannel_set_minimum_depth(&this_ptr_conv, val);
35022 }
35023
35024 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
35025         LDKAcceptChannel this_ptr_conv;
35026         this_ptr_conv.inner = untag_ptr(this_ptr);
35027         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35028         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35029         this_ptr_conv.is_owned = false;
35030         int16_t ret_conv = AcceptChannel_get_to_self_delay(&this_ptr_conv);
35031         return ret_conv;
35032 }
35033
35034 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
35035         LDKAcceptChannel this_ptr_conv;
35036         this_ptr_conv.inner = untag_ptr(this_ptr);
35037         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35038         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35039         this_ptr_conv.is_owned = false;
35040         AcceptChannel_set_to_self_delay(&this_ptr_conv, val);
35041 }
35042
35043 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
35044         LDKAcceptChannel this_ptr_conv;
35045         this_ptr_conv.inner = untag_ptr(this_ptr);
35046         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35047         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35048         this_ptr_conv.is_owned = false;
35049         int16_t ret_conv = AcceptChannel_get_max_accepted_htlcs(&this_ptr_conv);
35050         return ret_conv;
35051 }
35052
35053 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
35054         LDKAcceptChannel this_ptr_conv;
35055         this_ptr_conv.inner = untag_ptr(this_ptr);
35056         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35057         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35058         this_ptr_conv.is_owned = false;
35059         AcceptChannel_set_max_accepted_htlcs(&this_ptr_conv, val);
35060 }
35061
35062 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
35063         LDKAcceptChannel this_ptr_conv;
35064         this_ptr_conv.inner = untag_ptr(this_ptr);
35065         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35066         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35067         this_ptr_conv.is_owned = false;
35068         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
35069         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_funding_pubkey(&this_ptr_conv).compressed_form);
35070         return ret_arr;
35071 }
35072
35073 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
35074         LDKAcceptChannel this_ptr_conv;
35075         this_ptr_conv.inner = untag_ptr(this_ptr);
35076         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35077         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35078         this_ptr_conv.is_owned = false;
35079         LDKPublicKey val_ref;
35080         CHECK((*env)->GetArrayLength(env, val) == 33);
35081         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
35082         AcceptChannel_set_funding_pubkey(&this_ptr_conv, val_ref);
35083 }
35084
35085 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
35086         LDKAcceptChannel this_ptr_conv;
35087         this_ptr_conv.inner = untag_ptr(this_ptr);
35088         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35089         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35090         this_ptr_conv.is_owned = false;
35091         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
35092         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_revocation_basepoint(&this_ptr_conv).compressed_form);
35093         return ret_arr;
35094 }
35095
35096 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
35097         LDKAcceptChannel this_ptr_conv;
35098         this_ptr_conv.inner = untag_ptr(this_ptr);
35099         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35100         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35101         this_ptr_conv.is_owned = false;
35102         LDKPublicKey val_ref;
35103         CHECK((*env)->GetArrayLength(env, val) == 33);
35104         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
35105         AcceptChannel_set_revocation_basepoint(&this_ptr_conv, val_ref);
35106 }
35107
35108 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
35109         LDKAcceptChannel this_ptr_conv;
35110         this_ptr_conv.inner = untag_ptr(this_ptr);
35111         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35112         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35113         this_ptr_conv.is_owned = false;
35114         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
35115         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_payment_point(&this_ptr_conv).compressed_form);
35116         return ret_arr;
35117 }
35118
35119 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
35120         LDKAcceptChannel this_ptr_conv;
35121         this_ptr_conv.inner = untag_ptr(this_ptr);
35122         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35123         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35124         this_ptr_conv.is_owned = false;
35125         LDKPublicKey val_ref;
35126         CHECK((*env)->GetArrayLength(env, val) == 33);
35127         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
35128         AcceptChannel_set_payment_point(&this_ptr_conv, val_ref);
35129 }
35130
35131 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
35132         LDKAcceptChannel this_ptr_conv;
35133         this_ptr_conv.inner = untag_ptr(this_ptr);
35134         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35135         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35136         this_ptr_conv.is_owned = false;
35137         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
35138         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form);
35139         return ret_arr;
35140 }
35141
35142 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
35143         LDKAcceptChannel this_ptr_conv;
35144         this_ptr_conv.inner = untag_ptr(this_ptr);
35145         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35146         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35147         this_ptr_conv.is_owned = false;
35148         LDKPublicKey val_ref;
35149         CHECK((*env)->GetArrayLength(env, val) == 33);
35150         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
35151         AcceptChannel_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
35152 }
35153
35154 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
35155         LDKAcceptChannel this_ptr_conv;
35156         this_ptr_conv.inner = untag_ptr(this_ptr);
35157         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35158         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35159         this_ptr_conv.is_owned = false;
35160         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
35161         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_htlc_basepoint(&this_ptr_conv).compressed_form);
35162         return ret_arr;
35163 }
35164
35165 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
35166         LDKAcceptChannel this_ptr_conv;
35167         this_ptr_conv.inner = untag_ptr(this_ptr);
35168         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35169         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35170         this_ptr_conv.is_owned = false;
35171         LDKPublicKey val_ref;
35172         CHECK((*env)->GetArrayLength(env, val) == 33);
35173         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
35174         AcceptChannel_set_htlc_basepoint(&this_ptr_conv, val_ref);
35175 }
35176
35177 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1first_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
35178         LDKAcceptChannel this_ptr_conv;
35179         this_ptr_conv.inner = untag_ptr(this_ptr);
35180         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35181         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35182         this_ptr_conv.is_owned = false;
35183         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
35184         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_first_per_commitment_point(&this_ptr_conv).compressed_form);
35185         return ret_arr;
35186 }
35187
35188 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) {
35189         LDKAcceptChannel this_ptr_conv;
35190         this_ptr_conv.inner = untag_ptr(this_ptr);
35191         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35192         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35193         this_ptr_conv.is_owned = false;
35194         LDKPublicKey val_ref;
35195         CHECK((*env)->GetArrayLength(env, val) == 33);
35196         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
35197         AcceptChannel_set_first_per_commitment_point(&this_ptr_conv, val_ref);
35198 }
35199
35200 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1channel_1type(JNIEnv *env, jclass clz, int64_t this_ptr) {
35201         LDKAcceptChannel this_ptr_conv;
35202         this_ptr_conv.inner = untag_ptr(this_ptr);
35203         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35204         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35205         this_ptr_conv.is_owned = false;
35206         LDKChannelTypeFeatures ret_var = AcceptChannel_get_channel_type(&this_ptr_conv);
35207         int64_t ret_ref = 0;
35208         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35209         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
35210         return ret_ref;
35211 }
35212
35213 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1channel_1type(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
35214         LDKAcceptChannel this_ptr_conv;
35215         this_ptr_conv.inner = untag_ptr(this_ptr);
35216         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35217         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35218         this_ptr_conv.is_owned = false;
35219         LDKChannelTypeFeatures val_conv;
35220         val_conv.inner = untag_ptr(val);
35221         val_conv.is_owned = ptr_is_owned(val);
35222         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
35223         val_conv = ChannelTypeFeatures_clone(&val_conv);
35224         AcceptChannel_set_channel_type(&this_ptr_conv, val_conv);
35225 }
35226
35227 static inline uint64_t AcceptChannel_clone_ptr(LDKAcceptChannel *NONNULL_PTR arg) {
35228         LDKAcceptChannel ret_var = AcceptChannel_clone(arg);
35229         int64_t ret_ref = 0;
35230         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35231         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
35232         return ret_ref;
35233 }
35234 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
35235         LDKAcceptChannel arg_conv;
35236         arg_conv.inner = untag_ptr(arg);
35237         arg_conv.is_owned = ptr_is_owned(arg);
35238         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
35239         arg_conv.is_owned = false;
35240         int64_t ret_conv = AcceptChannel_clone_ptr(&arg_conv);
35241         return ret_conv;
35242 }
35243
35244 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1clone(JNIEnv *env, jclass clz, int64_t orig) {
35245         LDKAcceptChannel orig_conv;
35246         orig_conv.inner = untag_ptr(orig);
35247         orig_conv.is_owned = ptr_is_owned(orig);
35248         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
35249         orig_conv.is_owned = false;
35250         LDKAcceptChannel ret_var = AcceptChannel_clone(&orig_conv);
35251         int64_t ret_ref = 0;
35252         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35253         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
35254         return ret_ref;
35255 }
35256
35257 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
35258         LDKAcceptChannel a_conv;
35259         a_conv.inner = untag_ptr(a);
35260         a_conv.is_owned = ptr_is_owned(a);
35261         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
35262         a_conv.is_owned = false;
35263         LDKAcceptChannel b_conv;
35264         b_conv.inner = untag_ptr(b);
35265         b_conv.is_owned = ptr_is_owned(b);
35266         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
35267         b_conv.is_owned = false;
35268         jboolean ret_conv = AcceptChannel_eq(&a_conv, &b_conv);
35269         return ret_conv;
35270 }
35271
35272 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
35273         LDKFundingCreated this_obj_conv;
35274         this_obj_conv.inner = untag_ptr(this_obj);
35275         this_obj_conv.is_owned = ptr_is_owned(this_obj);
35276         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35277         FundingCreated_free(this_obj_conv);
35278 }
35279
35280 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingCreated_1get_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
35281         LDKFundingCreated this_ptr_conv;
35282         this_ptr_conv.inner = untag_ptr(this_ptr);
35283         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35284         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35285         this_ptr_conv.is_owned = false;
35286         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
35287         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *FundingCreated_get_temporary_channel_id(&this_ptr_conv));
35288         return ret_arr;
35289 }
35290
35291 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1set_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
35292         LDKFundingCreated this_ptr_conv;
35293         this_ptr_conv.inner = untag_ptr(this_ptr);
35294         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35295         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35296         this_ptr_conv.is_owned = false;
35297         LDKThirtyTwoBytes val_ref;
35298         CHECK((*env)->GetArrayLength(env, val) == 32);
35299         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
35300         FundingCreated_set_temporary_channel_id(&this_ptr_conv, val_ref);
35301 }
35302
35303 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingCreated_1get_1funding_1txid(JNIEnv *env, jclass clz, int64_t this_ptr) {
35304         LDKFundingCreated this_ptr_conv;
35305         this_ptr_conv.inner = untag_ptr(this_ptr);
35306         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35307         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35308         this_ptr_conv.is_owned = false;
35309         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
35310         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *FundingCreated_get_funding_txid(&this_ptr_conv));
35311         return ret_arr;
35312 }
35313
35314 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1set_1funding_1txid(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
35315         LDKFundingCreated this_ptr_conv;
35316         this_ptr_conv.inner = untag_ptr(this_ptr);
35317         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35318         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35319         this_ptr_conv.is_owned = false;
35320         LDKThirtyTwoBytes val_ref;
35321         CHECK((*env)->GetArrayLength(env, val) == 32);
35322         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
35323         FundingCreated_set_funding_txid(&this_ptr_conv, val_ref);
35324 }
35325
35326 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_FundingCreated_1get_1funding_1output_1index(JNIEnv *env, jclass clz, int64_t this_ptr) {
35327         LDKFundingCreated this_ptr_conv;
35328         this_ptr_conv.inner = untag_ptr(this_ptr);
35329         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35330         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35331         this_ptr_conv.is_owned = false;
35332         int16_t ret_conv = FundingCreated_get_funding_output_index(&this_ptr_conv);
35333         return ret_conv;
35334 }
35335
35336 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1set_1funding_1output_1index(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
35337         LDKFundingCreated this_ptr_conv;
35338         this_ptr_conv.inner = untag_ptr(this_ptr);
35339         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35340         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35341         this_ptr_conv.is_owned = false;
35342         FundingCreated_set_funding_output_index(&this_ptr_conv, val);
35343 }
35344
35345 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingCreated_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
35346         LDKFundingCreated this_ptr_conv;
35347         this_ptr_conv.inner = untag_ptr(this_ptr);
35348         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35349         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35350         this_ptr_conv.is_owned = false;
35351         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
35352         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, FundingCreated_get_signature(&this_ptr_conv).compact_form);
35353         return ret_arr;
35354 }
35355
35356 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
35357         LDKFundingCreated this_ptr_conv;
35358         this_ptr_conv.inner = untag_ptr(this_ptr);
35359         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35360         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35361         this_ptr_conv.is_owned = false;
35362         LDKSignature val_ref;
35363         CHECK((*env)->GetArrayLength(env, val) == 64);
35364         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
35365         FundingCreated_set_signature(&this_ptr_conv, val_ref);
35366 }
35367
35368 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) {
35369         LDKThirtyTwoBytes temporary_channel_id_arg_ref;
35370         CHECK((*env)->GetArrayLength(env, temporary_channel_id_arg) == 32);
35371         (*env)->GetByteArrayRegion(env, temporary_channel_id_arg, 0, 32, temporary_channel_id_arg_ref.data);
35372         LDKThirtyTwoBytes funding_txid_arg_ref;
35373         CHECK((*env)->GetArrayLength(env, funding_txid_arg) == 32);
35374         (*env)->GetByteArrayRegion(env, funding_txid_arg, 0, 32, funding_txid_arg_ref.data);
35375         LDKSignature signature_arg_ref;
35376         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
35377         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
35378         LDKFundingCreated ret_var = FundingCreated_new(temporary_channel_id_arg_ref, funding_txid_arg_ref, funding_output_index_arg, signature_arg_ref);
35379         int64_t ret_ref = 0;
35380         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35381         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
35382         return ret_ref;
35383 }
35384
35385 static inline uint64_t FundingCreated_clone_ptr(LDKFundingCreated *NONNULL_PTR arg) {
35386         LDKFundingCreated ret_var = FundingCreated_clone(arg);
35387         int64_t ret_ref = 0;
35388         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35389         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
35390         return ret_ref;
35391 }
35392 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingCreated_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
35393         LDKFundingCreated arg_conv;
35394         arg_conv.inner = untag_ptr(arg);
35395         arg_conv.is_owned = ptr_is_owned(arg);
35396         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
35397         arg_conv.is_owned = false;
35398         int64_t ret_conv = FundingCreated_clone_ptr(&arg_conv);
35399         return ret_conv;
35400 }
35401
35402 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingCreated_1clone(JNIEnv *env, jclass clz, int64_t orig) {
35403         LDKFundingCreated orig_conv;
35404         orig_conv.inner = untag_ptr(orig);
35405         orig_conv.is_owned = ptr_is_owned(orig);
35406         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
35407         orig_conv.is_owned = false;
35408         LDKFundingCreated ret_var = FundingCreated_clone(&orig_conv);
35409         int64_t ret_ref = 0;
35410         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35411         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
35412         return ret_ref;
35413 }
35414
35415 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_FundingCreated_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
35416         LDKFundingCreated a_conv;
35417         a_conv.inner = untag_ptr(a);
35418         a_conv.is_owned = ptr_is_owned(a);
35419         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
35420         a_conv.is_owned = false;
35421         LDKFundingCreated b_conv;
35422         b_conv.inner = untag_ptr(b);
35423         b_conv.is_owned = ptr_is_owned(b);
35424         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
35425         b_conv.is_owned = false;
35426         jboolean ret_conv = FundingCreated_eq(&a_conv, &b_conv);
35427         return ret_conv;
35428 }
35429
35430 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingSigned_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
35431         LDKFundingSigned this_obj_conv;
35432         this_obj_conv.inner = untag_ptr(this_obj);
35433         this_obj_conv.is_owned = ptr_is_owned(this_obj);
35434         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35435         FundingSigned_free(this_obj_conv);
35436 }
35437
35438 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingSigned_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
35439         LDKFundingSigned this_ptr_conv;
35440         this_ptr_conv.inner = untag_ptr(this_ptr);
35441         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35442         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35443         this_ptr_conv.is_owned = false;
35444         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
35445         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *FundingSigned_get_channel_id(&this_ptr_conv));
35446         return ret_arr;
35447 }
35448
35449 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingSigned_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
35450         LDKFundingSigned this_ptr_conv;
35451         this_ptr_conv.inner = untag_ptr(this_ptr);
35452         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35453         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35454         this_ptr_conv.is_owned = false;
35455         LDKThirtyTwoBytes val_ref;
35456         CHECK((*env)->GetArrayLength(env, val) == 32);
35457         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
35458         FundingSigned_set_channel_id(&this_ptr_conv, val_ref);
35459 }
35460
35461 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingSigned_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
35462         LDKFundingSigned this_ptr_conv;
35463         this_ptr_conv.inner = untag_ptr(this_ptr);
35464         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35465         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35466         this_ptr_conv.is_owned = false;
35467         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
35468         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, FundingSigned_get_signature(&this_ptr_conv).compact_form);
35469         return ret_arr;
35470 }
35471
35472 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingSigned_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
35473         LDKFundingSigned this_ptr_conv;
35474         this_ptr_conv.inner = untag_ptr(this_ptr);
35475         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35476         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35477         this_ptr_conv.is_owned = false;
35478         LDKSignature val_ref;
35479         CHECK((*env)->GetArrayLength(env, val) == 64);
35480         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
35481         FundingSigned_set_signature(&this_ptr_conv, val_ref);
35482 }
35483
35484 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingSigned_1new(JNIEnv *env, jclass clz, int8_tArray channel_id_arg, int8_tArray signature_arg) {
35485         LDKThirtyTwoBytes channel_id_arg_ref;
35486         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
35487         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
35488         LDKSignature signature_arg_ref;
35489         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
35490         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
35491         LDKFundingSigned ret_var = FundingSigned_new(channel_id_arg_ref, signature_arg_ref);
35492         int64_t ret_ref = 0;
35493         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35494         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
35495         return ret_ref;
35496 }
35497
35498 static inline uint64_t FundingSigned_clone_ptr(LDKFundingSigned *NONNULL_PTR arg) {
35499         LDKFundingSigned ret_var = FundingSigned_clone(arg);
35500         int64_t ret_ref = 0;
35501         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35502         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
35503         return ret_ref;
35504 }
35505 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingSigned_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
35506         LDKFundingSigned arg_conv;
35507         arg_conv.inner = untag_ptr(arg);
35508         arg_conv.is_owned = ptr_is_owned(arg);
35509         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
35510         arg_conv.is_owned = false;
35511         int64_t ret_conv = FundingSigned_clone_ptr(&arg_conv);
35512         return ret_conv;
35513 }
35514
35515 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingSigned_1clone(JNIEnv *env, jclass clz, int64_t orig) {
35516         LDKFundingSigned orig_conv;
35517         orig_conv.inner = untag_ptr(orig);
35518         orig_conv.is_owned = ptr_is_owned(orig);
35519         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
35520         orig_conv.is_owned = false;
35521         LDKFundingSigned ret_var = FundingSigned_clone(&orig_conv);
35522         int64_t ret_ref = 0;
35523         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35524         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
35525         return ret_ref;
35526 }
35527
35528 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_FundingSigned_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
35529         LDKFundingSigned a_conv;
35530         a_conv.inner = untag_ptr(a);
35531         a_conv.is_owned = ptr_is_owned(a);
35532         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
35533         a_conv.is_owned = false;
35534         LDKFundingSigned b_conv;
35535         b_conv.inner = untag_ptr(b);
35536         b_conv.is_owned = ptr_is_owned(b);
35537         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
35538         b_conv.is_owned = false;
35539         jboolean ret_conv = FundingSigned_eq(&a_conv, &b_conv);
35540         return ret_conv;
35541 }
35542
35543 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelReady_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
35544         LDKChannelReady this_obj_conv;
35545         this_obj_conv.inner = untag_ptr(this_obj);
35546         this_obj_conv.is_owned = ptr_is_owned(this_obj);
35547         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35548         ChannelReady_free(this_obj_conv);
35549 }
35550
35551 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelReady_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
35552         LDKChannelReady this_ptr_conv;
35553         this_ptr_conv.inner = untag_ptr(this_ptr);
35554         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35555         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35556         this_ptr_conv.is_owned = false;
35557         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
35558         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ChannelReady_get_channel_id(&this_ptr_conv));
35559         return ret_arr;
35560 }
35561
35562 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelReady_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
35563         LDKChannelReady this_ptr_conv;
35564         this_ptr_conv.inner = untag_ptr(this_ptr);
35565         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35566         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35567         this_ptr_conv.is_owned = false;
35568         LDKThirtyTwoBytes val_ref;
35569         CHECK((*env)->GetArrayLength(env, val) == 32);
35570         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
35571         ChannelReady_set_channel_id(&this_ptr_conv, val_ref);
35572 }
35573
35574 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelReady_1get_1next_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
35575         LDKChannelReady this_ptr_conv;
35576         this_ptr_conv.inner = untag_ptr(this_ptr);
35577         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35578         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35579         this_ptr_conv.is_owned = false;
35580         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
35581         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelReady_get_next_per_commitment_point(&this_ptr_conv).compressed_form);
35582         return ret_arr;
35583 }
35584
35585 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) {
35586         LDKChannelReady this_ptr_conv;
35587         this_ptr_conv.inner = untag_ptr(this_ptr);
35588         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35589         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35590         this_ptr_conv.is_owned = false;
35591         LDKPublicKey val_ref;
35592         CHECK((*env)->GetArrayLength(env, val) == 33);
35593         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
35594         ChannelReady_set_next_per_commitment_point(&this_ptr_conv, val_ref);
35595 }
35596
35597 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReady_1get_1short_1channel_1id_1alias(JNIEnv *env, jclass clz, int64_t this_ptr) {
35598         LDKChannelReady this_ptr_conv;
35599         this_ptr_conv.inner = untag_ptr(this_ptr);
35600         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35601         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35602         this_ptr_conv.is_owned = false;
35603         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
35604         *ret_copy = ChannelReady_get_short_channel_id_alias(&this_ptr_conv);
35605         int64_t ret_ref = tag_ptr(ret_copy, true);
35606         return ret_ref;
35607 }
35608
35609 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) {
35610         LDKChannelReady this_ptr_conv;
35611         this_ptr_conv.inner = untag_ptr(this_ptr);
35612         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35613         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35614         this_ptr_conv.is_owned = false;
35615         void* val_ptr = untag_ptr(val);
35616         CHECK_ACCESS(val_ptr);
35617         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
35618         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(val));
35619         ChannelReady_set_short_channel_id_alias(&this_ptr_conv, val_conv);
35620 }
35621
35622 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) {
35623         LDKThirtyTwoBytes channel_id_arg_ref;
35624         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
35625         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
35626         LDKPublicKey next_per_commitment_point_arg_ref;
35627         CHECK((*env)->GetArrayLength(env, next_per_commitment_point_arg) == 33);
35628         (*env)->GetByteArrayRegion(env, next_per_commitment_point_arg, 0, 33, next_per_commitment_point_arg_ref.compressed_form);
35629         void* short_channel_id_alias_arg_ptr = untag_ptr(short_channel_id_alias_arg);
35630         CHECK_ACCESS(short_channel_id_alias_arg_ptr);
35631         LDKCOption_u64Z short_channel_id_alias_arg_conv = *(LDKCOption_u64Z*)(short_channel_id_alias_arg_ptr);
35632         short_channel_id_alias_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(short_channel_id_alias_arg));
35633         LDKChannelReady ret_var = ChannelReady_new(channel_id_arg_ref, next_per_commitment_point_arg_ref, short_channel_id_alias_arg_conv);
35634         int64_t ret_ref = 0;
35635         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35636         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
35637         return ret_ref;
35638 }
35639
35640 static inline uint64_t ChannelReady_clone_ptr(LDKChannelReady *NONNULL_PTR arg) {
35641         LDKChannelReady ret_var = ChannelReady_clone(arg);
35642         int64_t ret_ref = 0;
35643         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35644         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
35645         return ret_ref;
35646 }
35647 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReady_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
35648         LDKChannelReady arg_conv;
35649         arg_conv.inner = untag_ptr(arg);
35650         arg_conv.is_owned = ptr_is_owned(arg);
35651         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
35652         arg_conv.is_owned = false;
35653         int64_t ret_conv = ChannelReady_clone_ptr(&arg_conv);
35654         return ret_conv;
35655 }
35656
35657 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReady_1clone(JNIEnv *env, jclass clz, int64_t orig) {
35658         LDKChannelReady orig_conv;
35659         orig_conv.inner = untag_ptr(orig);
35660         orig_conv.is_owned = ptr_is_owned(orig);
35661         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
35662         orig_conv.is_owned = false;
35663         LDKChannelReady ret_var = ChannelReady_clone(&orig_conv);
35664         int64_t ret_ref = 0;
35665         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35666         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
35667         return ret_ref;
35668 }
35669
35670 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelReady_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
35671         LDKChannelReady a_conv;
35672         a_conv.inner = untag_ptr(a);
35673         a_conv.is_owned = ptr_is_owned(a);
35674         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
35675         a_conv.is_owned = false;
35676         LDKChannelReady b_conv;
35677         b_conv.inner = untag_ptr(b);
35678         b_conv.is_owned = ptr_is_owned(b);
35679         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
35680         b_conv.is_owned = false;
35681         jboolean ret_conv = ChannelReady_eq(&a_conv, &b_conv);
35682         return ret_conv;
35683 }
35684
35685 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Shutdown_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
35686         LDKShutdown this_obj_conv;
35687         this_obj_conv.inner = untag_ptr(this_obj);
35688         this_obj_conv.is_owned = ptr_is_owned(this_obj);
35689         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35690         Shutdown_free(this_obj_conv);
35691 }
35692
35693 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Shutdown_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
35694         LDKShutdown this_ptr_conv;
35695         this_ptr_conv.inner = untag_ptr(this_ptr);
35696         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35697         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35698         this_ptr_conv.is_owned = false;
35699         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
35700         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *Shutdown_get_channel_id(&this_ptr_conv));
35701         return ret_arr;
35702 }
35703
35704 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Shutdown_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
35705         LDKShutdown this_ptr_conv;
35706         this_ptr_conv.inner = untag_ptr(this_ptr);
35707         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35708         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35709         this_ptr_conv.is_owned = false;
35710         LDKThirtyTwoBytes val_ref;
35711         CHECK((*env)->GetArrayLength(env, val) == 32);
35712         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
35713         Shutdown_set_channel_id(&this_ptr_conv, val_ref);
35714 }
35715
35716 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Shutdown_1get_1scriptpubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
35717         LDKShutdown this_ptr_conv;
35718         this_ptr_conv.inner = untag_ptr(this_ptr);
35719         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35720         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35721         this_ptr_conv.is_owned = false;
35722         LDKu8slice ret_var = Shutdown_get_scriptpubkey(&this_ptr_conv);
35723         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
35724         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
35725         return ret_arr;
35726 }
35727
35728 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Shutdown_1set_1scriptpubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
35729         LDKShutdown this_ptr_conv;
35730         this_ptr_conv.inner = untag_ptr(this_ptr);
35731         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35732         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35733         this_ptr_conv.is_owned = false;
35734         LDKCVec_u8Z val_ref;
35735         val_ref.datalen = (*env)->GetArrayLength(env, val);
35736         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
35737         (*env)->GetByteArrayRegion(env, val, 0, val_ref.datalen, val_ref.data);
35738         Shutdown_set_scriptpubkey(&this_ptr_conv, val_ref);
35739 }
35740
35741 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Shutdown_1new(JNIEnv *env, jclass clz, int8_tArray channel_id_arg, int8_tArray scriptpubkey_arg) {
35742         LDKThirtyTwoBytes channel_id_arg_ref;
35743         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
35744         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
35745         LDKCVec_u8Z scriptpubkey_arg_ref;
35746         scriptpubkey_arg_ref.datalen = (*env)->GetArrayLength(env, scriptpubkey_arg);
35747         scriptpubkey_arg_ref.data = MALLOC(scriptpubkey_arg_ref.datalen, "LDKCVec_u8Z Bytes");
35748         (*env)->GetByteArrayRegion(env, scriptpubkey_arg, 0, scriptpubkey_arg_ref.datalen, scriptpubkey_arg_ref.data);
35749         LDKShutdown ret_var = Shutdown_new(channel_id_arg_ref, scriptpubkey_arg_ref);
35750         int64_t ret_ref = 0;
35751         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35752         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
35753         return ret_ref;
35754 }
35755
35756 static inline uint64_t Shutdown_clone_ptr(LDKShutdown *NONNULL_PTR arg) {
35757         LDKShutdown ret_var = Shutdown_clone(arg);
35758         int64_t ret_ref = 0;
35759         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35760         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
35761         return ret_ref;
35762 }
35763 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Shutdown_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
35764         LDKShutdown arg_conv;
35765         arg_conv.inner = untag_ptr(arg);
35766         arg_conv.is_owned = ptr_is_owned(arg);
35767         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
35768         arg_conv.is_owned = false;
35769         int64_t ret_conv = Shutdown_clone_ptr(&arg_conv);
35770         return ret_conv;
35771 }
35772
35773 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Shutdown_1clone(JNIEnv *env, jclass clz, int64_t orig) {
35774         LDKShutdown orig_conv;
35775         orig_conv.inner = untag_ptr(orig);
35776         orig_conv.is_owned = ptr_is_owned(orig);
35777         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
35778         orig_conv.is_owned = false;
35779         LDKShutdown ret_var = Shutdown_clone(&orig_conv);
35780         int64_t ret_ref = 0;
35781         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35782         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
35783         return ret_ref;
35784 }
35785
35786 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Shutdown_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
35787         LDKShutdown a_conv;
35788         a_conv.inner = untag_ptr(a);
35789         a_conv.is_owned = ptr_is_owned(a);
35790         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
35791         a_conv.is_owned = false;
35792         LDKShutdown b_conv;
35793         b_conv.inner = untag_ptr(b);
35794         b_conv.is_owned = ptr_is_owned(b);
35795         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
35796         b_conv.is_owned = false;
35797         jboolean ret_conv = Shutdown_eq(&a_conv, &b_conv);
35798         return ret_conv;
35799 }
35800
35801 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
35802         LDKClosingSignedFeeRange this_obj_conv;
35803         this_obj_conv.inner = untag_ptr(this_obj);
35804         this_obj_conv.is_owned = ptr_is_owned(this_obj);
35805         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35806         ClosingSignedFeeRange_free(this_obj_conv);
35807 }
35808
35809 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1get_1min_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
35810         LDKClosingSignedFeeRange this_ptr_conv;
35811         this_ptr_conv.inner = untag_ptr(this_ptr);
35812         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35813         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35814         this_ptr_conv.is_owned = false;
35815         int64_t ret_conv = ClosingSignedFeeRange_get_min_fee_satoshis(&this_ptr_conv);
35816         return ret_conv;
35817 }
35818
35819 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1set_1min_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
35820         LDKClosingSignedFeeRange this_ptr_conv;
35821         this_ptr_conv.inner = untag_ptr(this_ptr);
35822         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35823         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35824         this_ptr_conv.is_owned = false;
35825         ClosingSignedFeeRange_set_min_fee_satoshis(&this_ptr_conv, val);
35826 }
35827
35828 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1get_1max_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
35829         LDKClosingSignedFeeRange this_ptr_conv;
35830         this_ptr_conv.inner = untag_ptr(this_ptr);
35831         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35832         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35833         this_ptr_conv.is_owned = false;
35834         int64_t ret_conv = ClosingSignedFeeRange_get_max_fee_satoshis(&this_ptr_conv);
35835         return ret_conv;
35836 }
35837
35838 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1set_1max_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
35839         LDKClosingSignedFeeRange this_ptr_conv;
35840         this_ptr_conv.inner = untag_ptr(this_ptr);
35841         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35842         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35843         this_ptr_conv.is_owned = false;
35844         ClosingSignedFeeRange_set_max_fee_satoshis(&this_ptr_conv, val);
35845 }
35846
35847 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) {
35848         LDKClosingSignedFeeRange ret_var = ClosingSignedFeeRange_new(min_fee_satoshis_arg, max_fee_satoshis_arg);
35849         int64_t ret_ref = 0;
35850         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35851         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
35852         return ret_ref;
35853 }
35854
35855 static inline uint64_t ClosingSignedFeeRange_clone_ptr(LDKClosingSignedFeeRange *NONNULL_PTR arg) {
35856         LDKClosingSignedFeeRange ret_var = ClosingSignedFeeRange_clone(arg);
35857         int64_t ret_ref = 0;
35858         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35859         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
35860         return ret_ref;
35861 }
35862 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
35863         LDKClosingSignedFeeRange arg_conv;
35864         arg_conv.inner = untag_ptr(arg);
35865         arg_conv.is_owned = ptr_is_owned(arg);
35866         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
35867         arg_conv.is_owned = false;
35868         int64_t ret_conv = ClosingSignedFeeRange_clone_ptr(&arg_conv);
35869         return ret_conv;
35870 }
35871
35872 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1clone(JNIEnv *env, jclass clz, int64_t orig) {
35873         LDKClosingSignedFeeRange orig_conv;
35874         orig_conv.inner = untag_ptr(orig);
35875         orig_conv.is_owned = ptr_is_owned(orig);
35876         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
35877         orig_conv.is_owned = false;
35878         LDKClosingSignedFeeRange ret_var = ClosingSignedFeeRange_clone(&orig_conv);
35879         int64_t ret_ref = 0;
35880         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35881         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
35882         return ret_ref;
35883 }
35884
35885 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
35886         LDKClosingSignedFeeRange a_conv;
35887         a_conv.inner = untag_ptr(a);
35888         a_conv.is_owned = ptr_is_owned(a);
35889         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
35890         a_conv.is_owned = false;
35891         LDKClosingSignedFeeRange b_conv;
35892         b_conv.inner = untag_ptr(b);
35893         b_conv.is_owned = ptr_is_owned(b);
35894         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
35895         b_conv.is_owned = false;
35896         jboolean ret_conv = ClosingSignedFeeRange_eq(&a_conv, &b_conv);
35897         return ret_conv;
35898 }
35899
35900 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
35901         LDKClosingSigned this_obj_conv;
35902         this_obj_conv.inner = untag_ptr(this_obj);
35903         this_obj_conv.is_owned = ptr_is_owned(this_obj);
35904         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35905         ClosingSigned_free(this_obj_conv);
35906 }
35907
35908 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
35909         LDKClosingSigned this_ptr_conv;
35910         this_ptr_conv.inner = untag_ptr(this_ptr);
35911         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35912         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35913         this_ptr_conv.is_owned = false;
35914         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
35915         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ClosingSigned_get_channel_id(&this_ptr_conv));
35916         return ret_arr;
35917 }
35918
35919 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
35920         LDKClosingSigned this_ptr_conv;
35921         this_ptr_conv.inner = untag_ptr(this_ptr);
35922         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35923         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35924         this_ptr_conv.is_owned = false;
35925         LDKThirtyTwoBytes val_ref;
35926         CHECK((*env)->GetArrayLength(env, val) == 32);
35927         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
35928         ClosingSigned_set_channel_id(&this_ptr_conv, val_ref);
35929 }
35930
35931 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1get_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
35932         LDKClosingSigned this_ptr_conv;
35933         this_ptr_conv.inner = untag_ptr(this_ptr);
35934         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35935         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35936         this_ptr_conv.is_owned = false;
35937         int64_t ret_conv = ClosingSigned_get_fee_satoshis(&this_ptr_conv);
35938         return ret_conv;
35939 }
35940
35941 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1set_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
35942         LDKClosingSigned this_ptr_conv;
35943         this_ptr_conv.inner = untag_ptr(this_ptr);
35944         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35945         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35946         this_ptr_conv.is_owned = false;
35947         ClosingSigned_set_fee_satoshis(&this_ptr_conv, val);
35948 }
35949
35950 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
35951         LDKClosingSigned this_ptr_conv;
35952         this_ptr_conv.inner = untag_ptr(this_ptr);
35953         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35954         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35955         this_ptr_conv.is_owned = false;
35956         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
35957         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ClosingSigned_get_signature(&this_ptr_conv).compact_form);
35958         return ret_arr;
35959 }
35960
35961 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
35962         LDKClosingSigned this_ptr_conv;
35963         this_ptr_conv.inner = untag_ptr(this_ptr);
35964         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35965         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35966         this_ptr_conv.is_owned = false;
35967         LDKSignature val_ref;
35968         CHECK((*env)->GetArrayLength(env, val) == 64);
35969         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
35970         ClosingSigned_set_signature(&this_ptr_conv, val_ref);
35971 }
35972
35973 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1get_1fee_1range(JNIEnv *env, jclass clz, int64_t this_ptr) {
35974         LDKClosingSigned this_ptr_conv;
35975         this_ptr_conv.inner = untag_ptr(this_ptr);
35976         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35977         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35978         this_ptr_conv.is_owned = false;
35979         LDKClosingSignedFeeRange ret_var = ClosingSigned_get_fee_range(&this_ptr_conv);
35980         int64_t ret_ref = 0;
35981         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35982         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
35983         return ret_ref;
35984 }
35985
35986 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1set_1fee_1range(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
35987         LDKClosingSigned this_ptr_conv;
35988         this_ptr_conv.inner = untag_ptr(this_ptr);
35989         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
35990         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35991         this_ptr_conv.is_owned = false;
35992         LDKClosingSignedFeeRange val_conv;
35993         val_conv.inner = untag_ptr(val);
35994         val_conv.is_owned = ptr_is_owned(val);
35995         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
35996         val_conv = ClosingSignedFeeRange_clone(&val_conv);
35997         ClosingSigned_set_fee_range(&this_ptr_conv, val_conv);
35998 }
35999
36000 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) {
36001         LDKThirtyTwoBytes channel_id_arg_ref;
36002         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
36003         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
36004         LDKSignature signature_arg_ref;
36005         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
36006         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
36007         LDKClosingSignedFeeRange fee_range_arg_conv;
36008         fee_range_arg_conv.inner = untag_ptr(fee_range_arg);
36009         fee_range_arg_conv.is_owned = ptr_is_owned(fee_range_arg);
36010         CHECK_INNER_FIELD_ACCESS_OR_NULL(fee_range_arg_conv);
36011         fee_range_arg_conv = ClosingSignedFeeRange_clone(&fee_range_arg_conv);
36012         LDKClosingSigned ret_var = ClosingSigned_new(channel_id_arg_ref, fee_satoshis_arg, signature_arg_ref, fee_range_arg_conv);
36013         int64_t ret_ref = 0;
36014         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36015         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36016         return ret_ref;
36017 }
36018
36019 static inline uint64_t ClosingSigned_clone_ptr(LDKClosingSigned *NONNULL_PTR arg) {
36020         LDKClosingSigned ret_var = ClosingSigned_clone(arg);
36021         int64_t ret_ref = 0;
36022         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36023         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36024         return ret_ref;
36025 }
36026 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
36027         LDKClosingSigned arg_conv;
36028         arg_conv.inner = untag_ptr(arg);
36029         arg_conv.is_owned = ptr_is_owned(arg);
36030         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
36031         arg_conv.is_owned = false;
36032         int64_t ret_conv = ClosingSigned_clone_ptr(&arg_conv);
36033         return ret_conv;
36034 }
36035
36036 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1clone(JNIEnv *env, jclass clz, int64_t orig) {
36037         LDKClosingSigned orig_conv;
36038         orig_conv.inner = untag_ptr(orig);
36039         orig_conv.is_owned = ptr_is_owned(orig);
36040         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
36041         orig_conv.is_owned = false;
36042         LDKClosingSigned ret_var = ClosingSigned_clone(&orig_conv);
36043         int64_t ret_ref = 0;
36044         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36045         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36046         return ret_ref;
36047 }
36048
36049 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
36050         LDKClosingSigned a_conv;
36051         a_conv.inner = untag_ptr(a);
36052         a_conv.is_owned = ptr_is_owned(a);
36053         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
36054         a_conv.is_owned = false;
36055         LDKClosingSigned b_conv;
36056         b_conv.inner = untag_ptr(b);
36057         b_conv.is_owned = ptr_is_owned(b);
36058         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
36059         b_conv.is_owned = false;
36060         jboolean ret_conv = ClosingSigned_eq(&a_conv, &b_conv);
36061         return ret_conv;
36062 }
36063
36064 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
36065         LDKUpdateAddHTLC this_obj_conv;
36066         this_obj_conv.inner = untag_ptr(this_obj);
36067         this_obj_conv.is_owned = ptr_is_owned(this_obj);
36068         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36069         UpdateAddHTLC_free(this_obj_conv);
36070 }
36071
36072 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
36073         LDKUpdateAddHTLC this_ptr_conv;
36074         this_ptr_conv.inner = untag_ptr(this_ptr);
36075         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36076         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36077         this_ptr_conv.is_owned = false;
36078         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
36079         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateAddHTLC_get_channel_id(&this_ptr_conv));
36080         return ret_arr;
36081 }
36082
36083 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
36084         LDKUpdateAddHTLC this_ptr_conv;
36085         this_ptr_conv.inner = untag_ptr(this_ptr);
36086         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36087         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36088         this_ptr_conv.is_owned = false;
36089         LDKThirtyTwoBytes val_ref;
36090         CHECK((*env)->GetArrayLength(env, val) == 32);
36091         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
36092         UpdateAddHTLC_set_channel_id(&this_ptr_conv, val_ref);
36093 }
36094
36095 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
36096         LDKUpdateAddHTLC this_ptr_conv;
36097         this_ptr_conv.inner = untag_ptr(this_ptr);
36098         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36099         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36100         this_ptr_conv.is_owned = false;
36101         int64_t ret_conv = UpdateAddHTLC_get_htlc_id(&this_ptr_conv);
36102         return ret_conv;
36103 }
36104
36105 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
36106         LDKUpdateAddHTLC this_ptr_conv;
36107         this_ptr_conv.inner = untag_ptr(this_ptr);
36108         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36109         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36110         this_ptr_conv.is_owned = false;
36111         UpdateAddHTLC_set_htlc_id(&this_ptr_conv, val);
36112 }
36113
36114 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
36115         LDKUpdateAddHTLC this_ptr_conv;
36116         this_ptr_conv.inner = untag_ptr(this_ptr);
36117         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36118         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36119         this_ptr_conv.is_owned = false;
36120         int64_t ret_conv = UpdateAddHTLC_get_amount_msat(&this_ptr_conv);
36121         return ret_conv;
36122 }
36123
36124 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
36125         LDKUpdateAddHTLC this_ptr_conv;
36126         this_ptr_conv.inner = untag_ptr(this_ptr);
36127         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36128         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36129         this_ptr_conv.is_owned = false;
36130         UpdateAddHTLC_set_amount_msat(&this_ptr_conv, val);
36131 }
36132
36133 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
36134         LDKUpdateAddHTLC this_ptr_conv;
36135         this_ptr_conv.inner = untag_ptr(this_ptr);
36136         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36137         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36138         this_ptr_conv.is_owned = false;
36139         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
36140         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateAddHTLC_get_payment_hash(&this_ptr_conv));
36141         return ret_arr;
36142 }
36143
36144 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
36145         LDKUpdateAddHTLC this_ptr_conv;
36146         this_ptr_conv.inner = untag_ptr(this_ptr);
36147         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36148         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36149         this_ptr_conv.is_owned = false;
36150         LDKThirtyTwoBytes val_ref;
36151         CHECK((*env)->GetArrayLength(env, val) == 32);
36152         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
36153         UpdateAddHTLC_set_payment_hash(&this_ptr_conv, val_ref);
36154 }
36155
36156 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_ptr) {
36157         LDKUpdateAddHTLC this_ptr_conv;
36158         this_ptr_conv.inner = untag_ptr(this_ptr);
36159         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36160         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36161         this_ptr_conv.is_owned = false;
36162         int32_t ret_conv = UpdateAddHTLC_get_cltv_expiry(&this_ptr_conv);
36163         return ret_conv;
36164 }
36165
36166 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
36167         LDKUpdateAddHTLC this_ptr_conv;
36168         this_ptr_conv.inner = untag_ptr(this_ptr);
36169         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36170         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36171         this_ptr_conv.is_owned = false;
36172         UpdateAddHTLC_set_cltv_expiry(&this_ptr_conv, val);
36173 }
36174
36175 static inline uint64_t UpdateAddHTLC_clone_ptr(LDKUpdateAddHTLC *NONNULL_PTR arg) {
36176         LDKUpdateAddHTLC ret_var = UpdateAddHTLC_clone(arg);
36177         int64_t ret_ref = 0;
36178         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36179         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36180         return ret_ref;
36181 }
36182 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
36183         LDKUpdateAddHTLC arg_conv;
36184         arg_conv.inner = untag_ptr(arg);
36185         arg_conv.is_owned = ptr_is_owned(arg);
36186         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
36187         arg_conv.is_owned = false;
36188         int64_t ret_conv = UpdateAddHTLC_clone_ptr(&arg_conv);
36189         return ret_conv;
36190 }
36191
36192 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1clone(JNIEnv *env, jclass clz, int64_t orig) {
36193         LDKUpdateAddHTLC orig_conv;
36194         orig_conv.inner = untag_ptr(orig);
36195         orig_conv.is_owned = ptr_is_owned(orig);
36196         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
36197         orig_conv.is_owned = false;
36198         LDKUpdateAddHTLC ret_var = UpdateAddHTLC_clone(&orig_conv);
36199         int64_t ret_ref = 0;
36200         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36201         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36202         return ret_ref;
36203 }
36204
36205 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
36206         LDKUpdateAddHTLC a_conv;
36207         a_conv.inner = untag_ptr(a);
36208         a_conv.is_owned = ptr_is_owned(a);
36209         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
36210         a_conv.is_owned = false;
36211         LDKUpdateAddHTLC b_conv;
36212         b_conv.inner = untag_ptr(b);
36213         b_conv.is_owned = ptr_is_owned(b);
36214         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
36215         b_conv.is_owned = false;
36216         jboolean ret_conv = UpdateAddHTLC_eq(&a_conv, &b_conv);
36217         return ret_conv;
36218 }
36219
36220 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OnionMessage_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
36221         LDKOnionMessage this_obj_conv;
36222         this_obj_conv.inner = untag_ptr(this_obj);
36223         this_obj_conv.is_owned = ptr_is_owned(this_obj);
36224         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36225         OnionMessage_free(this_obj_conv);
36226 }
36227
36228 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OnionMessage_1get_1blinding_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
36229         LDKOnionMessage this_ptr_conv;
36230         this_ptr_conv.inner = untag_ptr(this_ptr);
36231         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36232         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36233         this_ptr_conv.is_owned = false;
36234         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
36235         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OnionMessage_get_blinding_point(&this_ptr_conv).compressed_form);
36236         return ret_arr;
36237 }
36238
36239 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OnionMessage_1set_1blinding_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
36240         LDKOnionMessage this_ptr_conv;
36241         this_ptr_conv.inner = untag_ptr(this_ptr);
36242         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36243         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36244         this_ptr_conv.is_owned = false;
36245         LDKPublicKey val_ref;
36246         CHECK((*env)->GetArrayLength(env, val) == 33);
36247         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
36248         OnionMessage_set_blinding_point(&this_ptr_conv, val_ref);
36249 }
36250
36251 static inline uint64_t OnionMessage_clone_ptr(LDKOnionMessage *NONNULL_PTR arg) {
36252         LDKOnionMessage ret_var = OnionMessage_clone(arg);
36253         int64_t ret_ref = 0;
36254         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36255         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36256         return ret_ref;
36257 }
36258 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OnionMessage_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
36259         LDKOnionMessage arg_conv;
36260         arg_conv.inner = untag_ptr(arg);
36261         arg_conv.is_owned = ptr_is_owned(arg);
36262         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
36263         arg_conv.is_owned = false;
36264         int64_t ret_conv = OnionMessage_clone_ptr(&arg_conv);
36265         return ret_conv;
36266 }
36267
36268 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OnionMessage_1clone(JNIEnv *env, jclass clz, int64_t orig) {
36269         LDKOnionMessage orig_conv;
36270         orig_conv.inner = untag_ptr(orig);
36271         orig_conv.is_owned = ptr_is_owned(orig);
36272         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
36273         orig_conv.is_owned = false;
36274         LDKOnionMessage ret_var = OnionMessage_clone(&orig_conv);
36275         int64_t ret_ref = 0;
36276         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36277         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36278         return ret_ref;
36279 }
36280
36281 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_OnionMessage_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
36282         LDKOnionMessage a_conv;
36283         a_conv.inner = untag_ptr(a);
36284         a_conv.is_owned = ptr_is_owned(a);
36285         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
36286         a_conv.is_owned = false;
36287         LDKOnionMessage b_conv;
36288         b_conv.inner = untag_ptr(b);
36289         b_conv.is_owned = ptr_is_owned(b);
36290         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
36291         b_conv.is_owned = false;
36292         jboolean ret_conv = OnionMessage_eq(&a_conv, &b_conv);
36293         return ret_conv;
36294 }
36295
36296 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
36297         LDKUpdateFulfillHTLC this_obj_conv;
36298         this_obj_conv.inner = untag_ptr(this_obj);
36299         this_obj_conv.is_owned = ptr_is_owned(this_obj);
36300         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36301         UpdateFulfillHTLC_free(this_obj_conv);
36302 }
36303
36304 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
36305         LDKUpdateFulfillHTLC this_ptr_conv;
36306         this_ptr_conv.inner = untag_ptr(this_ptr);
36307         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36308         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36309         this_ptr_conv.is_owned = false;
36310         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
36311         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFulfillHTLC_get_channel_id(&this_ptr_conv));
36312         return ret_arr;
36313 }
36314
36315 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
36316         LDKUpdateFulfillHTLC this_ptr_conv;
36317         this_ptr_conv.inner = untag_ptr(this_ptr);
36318         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36319         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36320         this_ptr_conv.is_owned = false;
36321         LDKThirtyTwoBytes val_ref;
36322         CHECK((*env)->GetArrayLength(env, val) == 32);
36323         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
36324         UpdateFulfillHTLC_set_channel_id(&this_ptr_conv, val_ref);
36325 }
36326
36327 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1get_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
36328         LDKUpdateFulfillHTLC this_ptr_conv;
36329         this_ptr_conv.inner = untag_ptr(this_ptr);
36330         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36331         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36332         this_ptr_conv.is_owned = false;
36333         int64_t ret_conv = UpdateFulfillHTLC_get_htlc_id(&this_ptr_conv);
36334         return ret_conv;
36335 }
36336
36337 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1set_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
36338         LDKUpdateFulfillHTLC this_ptr_conv;
36339         this_ptr_conv.inner = untag_ptr(this_ptr);
36340         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36341         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36342         this_ptr_conv.is_owned = false;
36343         UpdateFulfillHTLC_set_htlc_id(&this_ptr_conv, val);
36344 }
36345
36346 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1get_1payment_1preimage(JNIEnv *env, jclass clz, int64_t this_ptr) {
36347         LDKUpdateFulfillHTLC this_ptr_conv;
36348         this_ptr_conv.inner = untag_ptr(this_ptr);
36349         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36350         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36351         this_ptr_conv.is_owned = false;
36352         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
36353         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFulfillHTLC_get_payment_preimage(&this_ptr_conv));
36354         return ret_arr;
36355 }
36356
36357 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1set_1payment_1preimage(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
36358         LDKUpdateFulfillHTLC this_ptr_conv;
36359         this_ptr_conv.inner = untag_ptr(this_ptr);
36360         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36361         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36362         this_ptr_conv.is_owned = false;
36363         LDKThirtyTwoBytes val_ref;
36364         CHECK((*env)->GetArrayLength(env, val) == 32);
36365         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
36366         UpdateFulfillHTLC_set_payment_preimage(&this_ptr_conv, val_ref);
36367 }
36368
36369 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) {
36370         LDKThirtyTwoBytes channel_id_arg_ref;
36371         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
36372         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
36373         LDKThirtyTwoBytes payment_preimage_arg_ref;
36374         CHECK((*env)->GetArrayLength(env, payment_preimage_arg) == 32);
36375         (*env)->GetByteArrayRegion(env, payment_preimage_arg, 0, 32, payment_preimage_arg_ref.data);
36376         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_new(channel_id_arg_ref, htlc_id_arg, payment_preimage_arg_ref);
36377         int64_t ret_ref = 0;
36378         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36379         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36380         return ret_ref;
36381 }
36382
36383 static inline uint64_t UpdateFulfillHTLC_clone_ptr(LDKUpdateFulfillHTLC *NONNULL_PTR arg) {
36384         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_clone(arg);
36385         int64_t ret_ref = 0;
36386         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36387         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36388         return ret_ref;
36389 }
36390 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
36391         LDKUpdateFulfillHTLC arg_conv;
36392         arg_conv.inner = untag_ptr(arg);
36393         arg_conv.is_owned = ptr_is_owned(arg);
36394         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
36395         arg_conv.is_owned = false;
36396         int64_t ret_conv = UpdateFulfillHTLC_clone_ptr(&arg_conv);
36397         return ret_conv;
36398 }
36399
36400 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1clone(JNIEnv *env, jclass clz, int64_t orig) {
36401         LDKUpdateFulfillHTLC orig_conv;
36402         orig_conv.inner = untag_ptr(orig);
36403         orig_conv.is_owned = ptr_is_owned(orig);
36404         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
36405         orig_conv.is_owned = false;
36406         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_clone(&orig_conv);
36407         int64_t ret_ref = 0;
36408         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36409         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36410         return ret_ref;
36411 }
36412
36413 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
36414         LDKUpdateFulfillHTLC a_conv;
36415         a_conv.inner = untag_ptr(a);
36416         a_conv.is_owned = ptr_is_owned(a);
36417         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
36418         a_conv.is_owned = false;
36419         LDKUpdateFulfillHTLC b_conv;
36420         b_conv.inner = untag_ptr(b);
36421         b_conv.is_owned = ptr_is_owned(b);
36422         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
36423         b_conv.is_owned = false;
36424         jboolean ret_conv = UpdateFulfillHTLC_eq(&a_conv, &b_conv);
36425         return ret_conv;
36426 }
36427
36428 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
36429         LDKUpdateFailHTLC this_obj_conv;
36430         this_obj_conv.inner = untag_ptr(this_obj);
36431         this_obj_conv.is_owned = ptr_is_owned(this_obj);
36432         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36433         UpdateFailHTLC_free(this_obj_conv);
36434 }
36435
36436 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
36437         LDKUpdateFailHTLC this_ptr_conv;
36438         this_ptr_conv.inner = untag_ptr(this_ptr);
36439         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36440         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36441         this_ptr_conv.is_owned = false;
36442         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
36443         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFailHTLC_get_channel_id(&this_ptr_conv));
36444         return ret_arr;
36445 }
36446
36447 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
36448         LDKUpdateFailHTLC this_ptr_conv;
36449         this_ptr_conv.inner = untag_ptr(this_ptr);
36450         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36451         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36452         this_ptr_conv.is_owned = false;
36453         LDKThirtyTwoBytes val_ref;
36454         CHECK((*env)->GetArrayLength(env, val) == 32);
36455         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
36456         UpdateFailHTLC_set_channel_id(&this_ptr_conv, val_ref);
36457 }
36458
36459 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1get_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
36460         LDKUpdateFailHTLC this_ptr_conv;
36461         this_ptr_conv.inner = untag_ptr(this_ptr);
36462         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36463         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36464         this_ptr_conv.is_owned = false;
36465         int64_t ret_conv = UpdateFailHTLC_get_htlc_id(&this_ptr_conv);
36466         return ret_conv;
36467 }
36468
36469 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1set_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
36470         LDKUpdateFailHTLC this_ptr_conv;
36471         this_ptr_conv.inner = untag_ptr(this_ptr);
36472         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36473         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36474         this_ptr_conv.is_owned = false;
36475         UpdateFailHTLC_set_htlc_id(&this_ptr_conv, val);
36476 }
36477
36478 static inline uint64_t UpdateFailHTLC_clone_ptr(LDKUpdateFailHTLC *NONNULL_PTR arg) {
36479         LDKUpdateFailHTLC ret_var = UpdateFailHTLC_clone(arg);
36480         int64_t ret_ref = 0;
36481         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36482         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36483         return ret_ref;
36484 }
36485 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
36486         LDKUpdateFailHTLC arg_conv;
36487         arg_conv.inner = untag_ptr(arg);
36488         arg_conv.is_owned = ptr_is_owned(arg);
36489         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
36490         arg_conv.is_owned = false;
36491         int64_t ret_conv = UpdateFailHTLC_clone_ptr(&arg_conv);
36492         return ret_conv;
36493 }
36494
36495 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1clone(JNIEnv *env, jclass clz, int64_t orig) {
36496         LDKUpdateFailHTLC orig_conv;
36497         orig_conv.inner = untag_ptr(orig);
36498         orig_conv.is_owned = ptr_is_owned(orig);
36499         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
36500         orig_conv.is_owned = false;
36501         LDKUpdateFailHTLC ret_var = UpdateFailHTLC_clone(&orig_conv);
36502         int64_t ret_ref = 0;
36503         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36504         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36505         return ret_ref;
36506 }
36507
36508 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
36509         LDKUpdateFailHTLC a_conv;
36510         a_conv.inner = untag_ptr(a);
36511         a_conv.is_owned = ptr_is_owned(a);
36512         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
36513         a_conv.is_owned = false;
36514         LDKUpdateFailHTLC b_conv;
36515         b_conv.inner = untag_ptr(b);
36516         b_conv.is_owned = ptr_is_owned(b);
36517         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
36518         b_conv.is_owned = false;
36519         jboolean ret_conv = UpdateFailHTLC_eq(&a_conv, &b_conv);
36520         return ret_conv;
36521 }
36522
36523 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
36524         LDKUpdateFailMalformedHTLC this_obj_conv;
36525         this_obj_conv.inner = untag_ptr(this_obj);
36526         this_obj_conv.is_owned = ptr_is_owned(this_obj);
36527         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36528         UpdateFailMalformedHTLC_free(this_obj_conv);
36529 }
36530
36531 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
36532         LDKUpdateFailMalformedHTLC 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, 32);
36538         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFailMalformedHTLC_get_channel_id(&this_ptr_conv));
36539         return ret_arr;
36540 }
36541
36542 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
36543         LDKUpdateFailMalformedHTLC 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         LDKThirtyTwoBytes val_ref;
36549         CHECK((*env)->GetArrayLength(env, val) == 32);
36550         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
36551         UpdateFailMalformedHTLC_set_channel_id(&this_ptr_conv, val_ref);
36552 }
36553
36554 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1get_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
36555         LDKUpdateFailMalformedHTLC 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         int64_t ret_conv = UpdateFailMalformedHTLC_get_htlc_id(&this_ptr_conv);
36561         return ret_conv;
36562 }
36563
36564 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1set_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
36565         LDKUpdateFailMalformedHTLC this_ptr_conv;
36566         this_ptr_conv.inner = untag_ptr(this_ptr);
36567         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36568         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36569         this_ptr_conv.is_owned = false;
36570         UpdateFailMalformedHTLC_set_htlc_id(&this_ptr_conv, val);
36571 }
36572
36573 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1get_1failure_1code(JNIEnv *env, jclass clz, int64_t this_ptr) {
36574         LDKUpdateFailMalformedHTLC this_ptr_conv;
36575         this_ptr_conv.inner = untag_ptr(this_ptr);
36576         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36577         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36578         this_ptr_conv.is_owned = false;
36579         int16_t ret_conv = UpdateFailMalformedHTLC_get_failure_code(&this_ptr_conv);
36580         return ret_conv;
36581 }
36582
36583 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1set_1failure_1code(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
36584         LDKUpdateFailMalformedHTLC this_ptr_conv;
36585         this_ptr_conv.inner = untag_ptr(this_ptr);
36586         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36587         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36588         this_ptr_conv.is_owned = false;
36589         UpdateFailMalformedHTLC_set_failure_code(&this_ptr_conv, val);
36590 }
36591
36592 static inline uint64_t UpdateFailMalformedHTLC_clone_ptr(LDKUpdateFailMalformedHTLC *NONNULL_PTR arg) {
36593         LDKUpdateFailMalformedHTLC ret_var = UpdateFailMalformedHTLC_clone(arg);
36594         int64_t ret_ref = 0;
36595         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36596         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36597         return ret_ref;
36598 }
36599 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
36600         LDKUpdateFailMalformedHTLC arg_conv;
36601         arg_conv.inner = untag_ptr(arg);
36602         arg_conv.is_owned = ptr_is_owned(arg);
36603         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
36604         arg_conv.is_owned = false;
36605         int64_t ret_conv = UpdateFailMalformedHTLC_clone_ptr(&arg_conv);
36606         return ret_conv;
36607 }
36608
36609 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1clone(JNIEnv *env, jclass clz, int64_t orig) {
36610         LDKUpdateFailMalformedHTLC orig_conv;
36611         orig_conv.inner = untag_ptr(orig);
36612         orig_conv.is_owned = ptr_is_owned(orig);
36613         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
36614         orig_conv.is_owned = false;
36615         LDKUpdateFailMalformedHTLC ret_var = UpdateFailMalformedHTLC_clone(&orig_conv);
36616         int64_t ret_ref = 0;
36617         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36618         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36619         return ret_ref;
36620 }
36621
36622 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
36623         LDKUpdateFailMalformedHTLC a_conv;
36624         a_conv.inner = untag_ptr(a);
36625         a_conv.is_owned = ptr_is_owned(a);
36626         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
36627         a_conv.is_owned = false;
36628         LDKUpdateFailMalformedHTLC b_conv;
36629         b_conv.inner = untag_ptr(b);
36630         b_conv.is_owned = ptr_is_owned(b);
36631         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
36632         b_conv.is_owned = false;
36633         jboolean ret_conv = UpdateFailMalformedHTLC_eq(&a_conv, &b_conv);
36634         return ret_conv;
36635 }
36636
36637 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
36638         LDKCommitmentSigned this_obj_conv;
36639         this_obj_conv.inner = untag_ptr(this_obj);
36640         this_obj_conv.is_owned = ptr_is_owned(this_obj);
36641         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36642         CommitmentSigned_free(this_obj_conv);
36643 }
36644
36645 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
36646         LDKCommitmentSigned this_ptr_conv;
36647         this_ptr_conv.inner = untag_ptr(this_ptr);
36648         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36649         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36650         this_ptr_conv.is_owned = false;
36651         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
36652         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *CommitmentSigned_get_channel_id(&this_ptr_conv));
36653         return ret_arr;
36654 }
36655
36656 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
36657         LDKCommitmentSigned this_ptr_conv;
36658         this_ptr_conv.inner = untag_ptr(this_ptr);
36659         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36660         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36661         this_ptr_conv.is_owned = false;
36662         LDKThirtyTwoBytes val_ref;
36663         CHECK((*env)->GetArrayLength(env, val) == 32);
36664         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
36665         CommitmentSigned_set_channel_id(&this_ptr_conv, val_ref);
36666 }
36667
36668 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
36669         LDKCommitmentSigned this_ptr_conv;
36670         this_ptr_conv.inner = untag_ptr(this_ptr);
36671         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36672         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36673         this_ptr_conv.is_owned = false;
36674         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
36675         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, CommitmentSigned_get_signature(&this_ptr_conv).compact_form);
36676         return ret_arr;
36677 }
36678
36679 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
36680         LDKCommitmentSigned this_ptr_conv;
36681         this_ptr_conv.inner = untag_ptr(this_ptr);
36682         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36683         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36684         this_ptr_conv.is_owned = false;
36685         LDKSignature val_ref;
36686         CHECK((*env)->GetArrayLength(env, val) == 64);
36687         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
36688         CommitmentSigned_set_signature(&this_ptr_conv, val_ref);
36689 }
36690
36691 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1get_1htlc_1signatures(JNIEnv *env, jclass clz, int64_t this_ptr) {
36692         LDKCommitmentSigned this_ptr_conv;
36693         this_ptr_conv.inner = untag_ptr(this_ptr);
36694         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36695         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36696         this_ptr_conv.is_owned = false;
36697         LDKCVec_SignatureZ ret_var = CommitmentSigned_get_htlc_signatures(&this_ptr_conv);
36698         jobjectArray ret_arr = NULL;
36699         ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
36700         ;
36701         for (size_t i = 0; i < ret_var.datalen; i++) {
36702                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, 64);
36703                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, 64, ret_var.data[i].compact_form);
36704                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
36705         }
36706         
36707         FREE(ret_var.data);
36708         return ret_arr;
36709 }
36710
36711 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1set_1htlc_1signatures(JNIEnv *env, jclass clz, int64_t this_ptr, jobjectArray val) {
36712         LDKCommitmentSigned this_ptr_conv;
36713         this_ptr_conv.inner = untag_ptr(this_ptr);
36714         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36715         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36716         this_ptr_conv.is_owned = false;
36717         LDKCVec_SignatureZ val_constr;
36718         val_constr.datalen = (*env)->GetArrayLength(env, val);
36719         if (val_constr.datalen > 0)
36720                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
36721         else
36722                 val_constr.data = NULL;
36723         for (size_t i = 0; i < val_constr.datalen; i++) {
36724                 int8_tArray val_conv_8 = (*env)->GetObjectArrayElement(env, val, i);
36725                 LDKSignature val_conv_8_ref;
36726                 CHECK((*env)->GetArrayLength(env, val_conv_8) == 64);
36727                 (*env)->GetByteArrayRegion(env, val_conv_8, 0, 64, val_conv_8_ref.compact_form);
36728                 val_constr.data[i] = val_conv_8_ref;
36729         }
36730         CommitmentSigned_set_htlc_signatures(&this_ptr_conv, val_constr);
36731 }
36732
36733 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) {
36734         LDKThirtyTwoBytes channel_id_arg_ref;
36735         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
36736         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
36737         LDKSignature signature_arg_ref;
36738         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
36739         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
36740         LDKCVec_SignatureZ htlc_signatures_arg_constr;
36741         htlc_signatures_arg_constr.datalen = (*env)->GetArrayLength(env, htlc_signatures_arg);
36742         if (htlc_signatures_arg_constr.datalen > 0)
36743                 htlc_signatures_arg_constr.data = MALLOC(htlc_signatures_arg_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
36744         else
36745                 htlc_signatures_arg_constr.data = NULL;
36746         for (size_t i = 0; i < htlc_signatures_arg_constr.datalen; i++) {
36747                 int8_tArray htlc_signatures_arg_conv_8 = (*env)->GetObjectArrayElement(env, htlc_signatures_arg, i);
36748                 LDKSignature htlc_signatures_arg_conv_8_ref;
36749                 CHECK((*env)->GetArrayLength(env, htlc_signatures_arg_conv_8) == 64);
36750                 (*env)->GetByteArrayRegion(env, htlc_signatures_arg_conv_8, 0, 64, htlc_signatures_arg_conv_8_ref.compact_form);
36751                 htlc_signatures_arg_constr.data[i] = htlc_signatures_arg_conv_8_ref;
36752         }
36753         LDKCommitmentSigned ret_var = CommitmentSigned_new(channel_id_arg_ref, signature_arg_ref, htlc_signatures_arg_constr);
36754         int64_t ret_ref = 0;
36755         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36756         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36757         return ret_ref;
36758 }
36759
36760 static inline uint64_t CommitmentSigned_clone_ptr(LDKCommitmentSigned *NONNULL_PTR arg) {
36761         LDKCommitmentSigned ret_var = CommitmentSigned_clone(arg);
36762         int64_t ret_ref = 0;
36763         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36764         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36765         return ret_ref;
36766 }
36767 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
36768         LDKCommitmentSigned arg_conv;
36769         arg_conv.inner = untag_ptr(arg);
36770         arg_conv.is_owned = ptr_is_owned(arg);
36771         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
36772         arg_conv.is_owned = false;
36773         int64_t ret_conv = CommitmentSigned_clone_ptr(&arg_conv);
36774         return ret_conv;
36775 }
36776
36777 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1clone(JNIEnv *env, jclass clz, int64_t orig) {
36778         LDKCommitmentSigned orig_conv;
36779         orig_conv.inner = untag_ptr(orig);
36780         orig_conv.is_owned = ptr_is_owned(orig);
36781         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
36782         orig_conv.is_owned = false;
36783         LDKCommitmentSigned ret_var = CommitmentSigned_clone(&orig_conv);
36784         int64_t ret_ref = 0;
36785         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36786         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36787         return ret_ref;
36788 }
36789
36790 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
36791         LDKCommitmentSigned a_conv;
36792         a_conv.inner = untag_ptr(a);
36793         a_conv.is_owned = ptr_is_owned(a);
36794         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
36795         a_conv.is_owned = false;
36796         LDKCommitmentSigned b_conv;
36797         b_conv.inner = untag_ptr(b);
36798         b_conv.is_owned = ptr_is_owned(b);
36799         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
36800         b_conv.is_owned = false;
36801         jboolean ret_conv = CommitmentSigned_eq(&a_conv, &b_conv);
36802         return ret_conv;
36803 }
36804
36805 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
36806         LDKRevokeAndACK this_obj_conv;
36807         this_obj_conv.inner = untag_ptr(this_obj);
36808         this_obj_conv.is_owned = ptr_is_owned(this_obj);
36809         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36810         RevokeAndACK_free(this_obj_conv);
36811 }
36812
36813 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
36814         LDKRevokeAndACK this_ptr_conv;
36815         this_ptr_conv.inner = untag_ptr(this_ptr);
36816         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36817         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36818         this_ptr_conv.is_owned = false;
36819         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
36820         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *RevokeAndACK_get_channel_id(&this_ptr_conv));
36821         return ret_arr;
36822 }
36823
36824 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
36825         LDKRevokeAndACK this_ptr_conv;
36826         this_ptr_conv.inner = untag_ptr(this_ptr);
36827         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36828         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36829         this_ptr_conv.is_owned = false;
36830         LDKThirtyTwoBytes val_ref;
36831         CHECK((*env)->GetArrayLength(env, val) == 32);
36832         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
36833         RevokeAndACK_set_channel_id(&this_ptr_conv, val_ref);
36834 }
36835
36836 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1get_1per_1commitment_1secret(JNIEnv *env, jclass clz, int64_t this_ptr) {
36837         LDKRevokeAndACK this_ptr_conv;
36838         this_ptr_conv.inner = untag_ptr(this_ptr);
36839         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36840         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36841         this_ptr_conv.is_owned = false;
36842         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
36843         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *RevokeAndACK_get_per_commitment_secret(&this_ptr_conv));
36844         return ret_arr;
36845 }
36846
36847 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1set_1per_1commitment_1secret(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
36848         LDKRevokeAndACK this_ptr_conv;
36849         this_ptr_conv.inner = untag_ptr(this_ptr);
36850         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36851         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36852         this_ptr_conv.is_owned = false;
36853         LDKThirtyTwoBytes val_ref;
36854         CHECK((*env)->GetArrayLength(env, val) == 32);
36855         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
36856         RevokeAndACK_set_per_commitment_secret(&this_ptr_conv, val_ref);
36857 }
36858
36859 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1get_1next_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
36860         LDKRevokeAndACK this_ptr_conv;
36861         this_ptr_conv.inner = untag_ptr(this_ptr);
36862         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36863         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36864         this_ptr_conv.is_owned = false;
36865         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
36866         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, RevokeAndACK_get_next_per_commitment_point(&this_ptr_conv).compressed_form);
36867         return ret_arr;
36868 }
36869
36870 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) {
36871         LDKRevokeAndACK this_ptr_conv;
36872         this_ptr_conv.inner = untag_ptr(this_ptr);
36873         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36874         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36875         this_ptr_conv.is_owned = false;
36876         LDKPublicKey val_ref;
36877         CHECK((*env)->GetArrayLength(env, val) == 33);
36878         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
36879         RevokeAndACK_set_next_per_commitment_point(&this_ptr_conv, val_ref);
36880 }
36881
36882 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) {
36883         LDKThirtyTwoBytes channel_id_arg_ref;
36884         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
36885         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
36886         LDKThirtyTwoBytes per_commitment_secret_arg_ref;
36887         CHECK((*env)->GetArrayLength(env, per_commitment_secret_arg) == 32);
36888         (*env)->GetByteArrayRegion(env, per_commitment_secret_arg, 0, 32, per_commitment_secret_arg_ref.data);
36889         LDKPublicKey next_per_commitment_point_arg_ref;
36890         CHECK((*env)->GetArrayLength(env, next_per_commitment_point_arg) == 33);
36891         (*env)->GetByteArrayRegion(env, next_per_commitment_point_arg, 0, 33, next_per_commitment_point_arg_ref.compressed_form);
36892         LDKRevokeAndACK ret_var = RevokeAndACK_new(channel_id_arg_ref, per_commitment_secret_arg_ref, next_per_commitment_point_arg_ref);
36893         int64_t ret_ref = 0;
36894         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36895         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36896         return ret_ref;
36897 }
36898
36899 static inline uint64_t RevokeAndACK_clone_ptr(LDKRevokeAndACK *NONNULL_PTR arg) {
36900         LDKRevokeAndACK ret_var = RevokeAndACK_clone(arg);
36901         int64_t ret_ref = 0;
36902         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36903         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36904         return ret_ref;
36905 }
36906 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
36907         LDKRevokeAndACK arg_conv;
36908         arg_conv.inner = untag_ptr(arg);
36909         arg_conv.is_owned = ptr_is_owned(arg);
36910         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
36911         arg_conv.is_owned = false;
36912         int64_t ret_conv = RevokeAndACK_clone_ptr(&arg_conv);
36913         return ret_conv;
36914 }
36915
36916 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1clone(JNIEnv *env, jclass clz, int64_t orig) {
36917         LDKRevokeAndACK orig_conv;
36918         orig_conv.inner = untag_ptr(orig);
36919         orig_conv.is_owned = ptr_is_owned(orig);
36920         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
36921         orig_conv.is_owned = false;
36922         LDKRevokeAndACK ret_var = RevokeAndACK_clone(&orig_conv);
36923         int64_t ret_ref = 0;
36924         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36925         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
36926         return ret_ref;
36927 }
36928
36929 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
36930         LDKRevokeAndACK a_conv;
36931         a_conv.inner = untag_ptr(a);
36932         a_conv.is_owned = ptr_is_owned(a);
36933         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
36934         a_conv.is_owned = false;
36935         LDKRevokeAndACK b_conv;
36936         b_conv.inner = untag_ptr(b);
36937         b_conv.is_owned = ptr_is_owned(b);
36938         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
36939         b_conv.is_owned = false;
36940         jboolean ret_conv = RevokeAndACK_eq(&a_conv, &b_conv);
36941         return ret_conv;
36942 }
36943
36944 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFee_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
36945         LDKUpdateFee this_obj_conv;
36946         this_obj_conv.inner = untag_ptr(this_obj);
36947         this_obj_conv.is_owned = ptr_is_owned(this_obj);
36948         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36949         UpdateFee_free(this_obj_conv);
36950 }
36951
36952 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFee_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
36953         LDKUpdateFee this_ptr_conv;
36954         this_ptr_conv.inner = untag_ptr(this_ptr);
36955         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36956         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36957         this_ptr_conv.is_owned = false;
36958         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
36959         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFee_get_channel_id(&this_ptr_conv));
36960         return ret_arr;
36961 }
36962
36963 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFee_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
36964         LDKUpdateFee this_ptr_conv;
36965         this_ptr_conv.inner = untag_ptr(this_ptr);
36966         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36967         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36968         this_ptr_conv.is_owned = false;
36969         LDKThirtyTwoBytes val_ref;
36970         CHECK((*env)->GetArrayLength(env, val) == 32);
36971         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
36972         UpdateFee_set_channel_id(&this_ptr_conv, val_ref);
36973 }
36974
36975 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UpdateFee_1get_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_ptr) {
36976         LDKUpdateFee this_ptr_conv;
36977         this_ptr_conv.inner = untag_ptr(this_ptr);
36978         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36979         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36980         this_ptr_conv.is_owned = false;
36981         int32_t ret_conv = UpdateFee_get_feerate_per_kw(&this_ptr_conv);
36982         return ret_conv;
36983 }
36984
36985 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFee_1set_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
36986         LDKUpdateFee this_ptr_conv;
36987         this_ptr_conv.inner = untag_ptr(this_ptr);
36988         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
36989         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36990         this_ptr_conv.is_owned = false;
36991         UpdateFee_set_feerate_per_kw(&this_ptr_conv, val);
36992 }
36993
36994 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) {
36995         LDKThirtyTwoBytes channel_id_arg_ref;
36996         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
36997         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
36998         LDKUpdateFee ret_var = UpdateFee_new(channel_id_arg_ref, feerate_per_kw_arg);
36999         int64_t ret_ref = 0;
37000         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37001         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37002         return ret_ref;
37003 }
37004
37005 static inline uint64_t UpdateFee_clone_ptr(LDKUpdateFee *NONNULL_PTR arg) {
37006         LDKUpdateFee ret_var = UpdateFee_clone(arg);
37007         int64_t ret_ref = 0;
37008         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37009         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37010         return ret_ref;
37011 }
37012 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFee_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
37013         LDKUpdateFee arg_conv;
37014         arg_conv.inner = untag_ptr(arg);
37015         arg_conv.is_owned = ptr_is_owned(arg);
37016         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
37017         arg_conv.is_owned = false;
37018         int64_t ret_conv = UpdateFee_clone_ptr(&arg_conv);
37019         return ret_conv;
37020 }
37021
37022 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFee_1clone(JNIEnv *env, jclass clz, int64_t orig) {
37023         LDKUpdateFee orig_conv;
37024         orig_conv.inner = untag_ptr(orig);
37025         orig_conv.is_owned = ptr_is_owned(orig);
37026         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
37027         orig_conv.is_owned = false;
37028         LDKUpdateFee ret_var = UpdateFee_clone(&orig_conv);
37029         int64_t ret_ref = 0;
37030         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37031         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37032         return ret_ref;
37033 }
37034
37035 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_UpdateFee_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
37036         LDKUpdateFee a_conv;
37037         a_conv.inner = untag_ptr(a);
37038         a_conv.is_owned = ptr_is_owned(a);
37039         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
37040         a_conv.is_owned = false;
37041         LDKUpdateFee b_conv;
37042         b_conv.inner = untag_ptr(b);
37043         b_conv.is_owned = ptr_is_owned(b);
37044         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
37045         b_conv.is_owned = false;
37046         jboolean ret_conv = UpdateFee_eq(&a_conv, &b_conv);
37047         return ret_conv;
37048 }
37049
37050 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
37051         LDKDataLossProtect this_obj_conv;
37052         this_obj_conv.inner = untag_ptr(this_obj);
37053         this_obj_conv.is_owned = ptr_is_owned(this_obj);
37054         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
37055         DataLossProtect_free(this_obj_conv);
37056 }
37057
37058 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1get_1your_1last_1per_1commitment_1secret(JNIEnv *env, jclass clz, int64_t this_ptr) {
37059         LDKDataLossProtect this_ptr_conv;
37060         this_ptr_conv.inner = untag_ptr(this_ptr);
37061         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37062         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37063         this_ptr_conv.is_owned = false;
37064         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
37065         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *DataLossProtect_get_your_last_per_commitment_secret(&this_ptr_conv));
37066         return ret_arr;
37067 }
37068
37069 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) {
37070         LDKDataLossProtect this_ptr_conv;
37071         this_ptr_conv.inner = untag_ptr(this_ptr);
37072         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37073         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37074         this_ptr_conv.is_owned = false;
37075         LDKThirtyTwoBytes val_ref;
37076         CHECK((*env)->GetArrayLength(env, val) == 32);
37077         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
37078         DataLossProtect_set_your_last_per_commitment_secret(&this_ptr_conv, val_ref);
37079 }
37080
37081 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1get_1my_1current_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
37082         LDKDataLossProtect this_ptr_conv;
37083         this_ptr_conv.inner = untag_ptr(this_ptr);
37084         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37085         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37086         this_ptr_conv.is_owned = false;
37087         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
37088         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, DataLossProtect_get_my_current_per_commitment_point(&this_ptr_conv).compressed_form);
37089         return ret_arr;
37090 }
37091
37092 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) {
37093         LDKDataLossProtect this_ptr_conv;
37094         this_ptr_conv.inner = untag_ptr(this_ptr);
37095         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37096         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37097         this_ptr_conv.is_owned = false;
37098         LDKPublicKey val_ref;
37099         CHECK((*env)->GetArrayLength(env, val) == 33);
37100         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
37101         DataLossProtect_set_my_current_per_commitment_point(&this_ptr_conv, val_ref);
37102 }
37103
37104 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) {
37105         LDKThirtyTwoBytes your_last_per_commitment_secret_arg_ref;
37106         CHECK((*env)->GetArrayLength(env, your_last_per_commitment_secret_arg) == 32);
37107         (*env)->GetByteArrayRegion(env, your_last_per_commitment_secret_arg, 0, 32, your_last_per_commitment_secret_arg_ref.data);
37108         LDKPublicKey my_current_per_commitment_point_arg_ref;
37109         CHECK((*env)->GetArrayLength(env, my_current_per_commitment_point_arg) == 33);
37110         (*env)->GetByteArrayRegion(env, my_current_per_commitment_point_arg, 0, 33, my_current_per_commitment_point_arg_ref.compressed_form);
37111         LDKDataLossProtect ret_var = DataLossProtect_new(your_last_per_commitment_secret_arg_ref, my_current_per_commitment_point_arg_ref);
37112         int64_t ret_ref = 0;
37113         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37114         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37115         return ret_ref;
37116 }
37117
37118 static inline uint64_t DataLossProtect_clone_ptr(LDKDataLossProtect *NONNULL_PTR arg) {
37119         LDKDataLossProtect ret_var = DataLossProtect_clone(arg);
37120         int64_t ret_ref = 0;
37121         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37122         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37123         return ret_ref;
37124 }
37125 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
37126         LDKDataLossProtect arg_conv;
37127         arg_conv.inner = untag_ptr(arg);
37128         arg_conv.is_owned = ptr_is_owned(arg);
37129         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
37130         arg_conv.is_owned = false;
37131         int64_t ret_conv = DataLossProtect_clone_ptr(&arg_conv);
37132         return ret_conv;
37133 }
37134
37135 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1clone(JNIEnv *env, jclass clz, int64_t orig) {
37136         LDKDataLossProtect orig_conv;
37137         orig_conv.inner = untag_ptr(orig);
37138         orig_conv.is_owned = ptr_is_owned(orig);
37139         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
37140         orig_conv.is_owned = false;
37141         LDKDataLossProtect ret_var = DataLossProtect_clone(&orig_conv);
37142         int64_t ret_ref = 0;
37143         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37144         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37145         return ret_ref;
37146 }
37147
37148 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
37149         LDKDataLossProtect a_conv;
37150         a_conv.inner = untag_ptr(a);
37151         a_conv.is_owned = ptr_is_owned(a);
37152         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
37153         a_conv.is_owned = false;
37154         LDKDataLossProtect b_conv;
37155         b_conv.inner = untag_ptr(b);
37156         b_conv.is_owned = ptr_is_owned(b);
37157         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
37158         b_conv.is_owned = false;
37159         jboolean ret_conv = DataLossProtect_eq(&a_conv, &b_conv);
37160         return ret_conv;
37161 }
37162
37163 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
37164         LDKChannelReestablish this_obj_conv;
37165         this_obj_conv.inner = untag_ptr(this_obj);
37166         this_obj_conv.is_owned = ptr_is_owned(this_obj);
37167         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
37168         ChannelReestablish_free(this_obj_conv);
37169 }
37170
37171 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
37172         LDKChannelReestablish this_ptr_conv;
37173         this_ptr_conv.inner = untag_ptr(this_ptr);
37174         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37175         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37176         this_ptr_conv.is_owned = false;
37177         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
37178         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ChannelReestablish_get_channel_id(&this_ptr_conv));
37179         return ret_arr;
37180 }
37181
37182 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
37183         LDKChannelReestablish this_ptr_conv;
37184         this_ptr_conv.inner = untag_ptr(this_ptr);
37185         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37186         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37187         this_ptr_conv.is_owned = false;
37188         LDKThirtyTwoBytes val_ref;
37189         CHECK((*env)->GetArrayLength(env, val) == 32);
37190         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
37191         ChannelReestablish_set_channel_id(&this_ptr_conv, val_ref);
37192 }
37193
37194 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1get_1next_1local_1commitment_1number(JNIEnv *env, jclass clz, int64_t this_ptr) {
37195         LDKChannelReestablish this_ptr_conv;
37196         this_ptr_conv.inner = untag_ptr(this_ptr);
37197         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37198         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37199         this_ptr_conv.is_owned = false;
37200         int64_t ret_conv = ChannelReestablish_get_next_local_commitment_number(&this_ptr_conv);
37201         return ret_conv;
37202 }
37203
37204 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) {
37205         LDKChannelReestablish this_ptr_conv;
37206         this_ptr_conv.inner = untag_ptr(this_ptr);
37207         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37208         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37209         this_ptr_conv.is_owned = false;
37210         ChannelReestablish_set_next_local_commitment_number(&this_ptr_conv, val);
37211 }
37212
37213 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1get_1next_1remote_1commitment_1number(JNIEnv *env, jclass clz, int64_t this_ptr) {
37214         LDKChannelReestablish this_ptr_conv;
37215         this_ptr_conv.inner = untag_ptr(this_ptr);
37216         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37217         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37218         this_ptr_conv.is_owned = false;
37219         int64_t ret_conv = ChannelReestablish_get_next_remote_commitment_number(&this_ptr_conv);
37220         return ret_conv;
37221 }
37222
37223 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) {
37224         LDKChannelReestablish this_ptr_conv;
37225         this_ptr_conv.inner = untag_ptr(this_ptr);
37226         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37227         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37228         this_ptr_conv.is_owned = false;
37229         ChannelReestablish_set_next_remote_commitment_number(&this_ptr_conv, val);
37230 }
37231
37232 static inline uint64_t ChannelReestablish_clone_ptr(LDKChannelReestablish *NONNULL_PTR arg) {
37233         LDKChannelReestablish ret_var = ChannelReestablish_clone(arg);
37234         int64_t ret_ref = 0;
37235         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37236         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37237         return ret_ref;
37238 }
37239 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
37240         LDKChannelReestablish arg_conv;
37241         arg_conv.inner = untag_ptr(arg);
37242         arg_conv.is_owned = ptr_is_owned(arg);
37243         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
37244         arg_conv.is_owned = false;
37245         int64_t ret_conv = ChannelReestablish_clone_ptr(&arg_conv);
37246         return ret_conv;
37247 }
37248
37249 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1clone(JNIEnv *env, jclass clz, int64_t orig) {
37250         LDKChannelReestablish orig_conv;
37251         orig_conv.inner = untag_ptr(orig);
37252         orig_conv.is_owned = ptr_is_owned(orig);
37253         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
37254         orig_conv.is_owned = false;
37255         LDKChannelReestablish ret_var = ChannelReestablish_clone(&orig_conv);
37256         int64_t ret_ref = 0;
37257         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37258         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37259         return ret_ref;
37260 }
37261
37262 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
37263         LDKChannelReestablish a_conv;
37264         a_conv.inner = untag_ptr(a);
37265         a_conv.is_owned = ptr_is_owned(a);
37266         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
37267         a_conv.is_owned = false;
37268         LDKChannelReestablish b_conv;
37269         b_conv.inner = untag_ptr(b);
37270         b_conv.is_owned = ptr_is_owned(b);
37271         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
37272         b_conv.is_owned = false;
37273         jboolean ret_conv = ChannelReestablish_eq(&a_conv, &b_conv);
37274         return ret_conv;
37275 }
37276
37277 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
37278         LDKAnnouncementSignatures this_obj_conv;
37279         this_obj_conv.inner = untag_ptr(this_obj);
37280         this_obj_conv.is_owned = ptr_is_owned(this_obj);
37281         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
37282         AnnouncementSignatures_free(this_obj_conv);
37283 }
37284
37285 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
37286         LDKAnnouncementSignatures this_ptr_conv;
37287         this_ptr_conv.inner = untag_ptr(this_ptr);
37288         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37289         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37290         this_ptr_conv.is_owned = false;
37291         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
37292         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *AnnouncementSignatures_get_channel_id(&this_ptr_conv));
37293         return ret_arr;
37294 }
37295
37296 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
37297         LDKAnnouncementSignatures this_ptr_conv;
37298         this_ptr_conv.inner = untag_ptr(this_ptr);
37299         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37300         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37301         this_ptr_conv.is_owned = false;
37302         LDKThirtyTwoBytes val_ref;
37303         CHECK((*env)->GetArrayLength(env, val) == 32);
37304         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
37305         AnnouncementSignatures_set_channel_id(&this_ptr_conv, val_ref);
37306 }
37307
37308 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
37309         LDKAnnouncementSignatures this_ptr_conv;
37310         this_ptr_conv.inner = untag_ptr(this_ptr);
37311         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37312         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37313         this_ptr_conv.is_owned = false;
37314         int64_t ret_conv = AnnouncementSignatures_get_short_channel_id(&this_ptr_conv);
37315         return ret_conv;
37316 }
37317
37318 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
37319         LDKAnnouncementSignatures this_ptr_conv;
37320         this_ptr_conv.inner = untag_ptr(this_ptr);
37321         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37322         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37323         this_ptr_conv.is_owned = false;
37324         AnnouncementSignatures_set_short_channel_id(&this_ptr_conv, val);
37325 }
37326
37327 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1get_1node_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
37328         LDKAnnouncementSignatures this_ptr_conv;
37329         this_ptr_conv.inner = untag_ptr(this_ptr);
37330         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37331         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37332         this_ptr_conv.is_owned = false;
37333         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
37334         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, AnnouncementSignatures_get_node_signature(&this_ptr_conv).compact_form);
37335         return ret_arr;
37336 }
37337
37338 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1set_1node_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
37339         LDKAnnouncementSignatures 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         LDKSignature val_ref;
37345         CHECK((*env)->GetArrayLength(env, val) == 64);
37346         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
37347         AnnouncementSignatures_set_node_signature(&this_ptr_conv, val_ref);
37348 }
37349
37350 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1get_1bitcoin_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
37351         LDKAnnouncementSignatures this_ptr_conv;
37352         this_ptr_conv.inner = untag_ptr(this_ptr);
37353         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37354         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37355         this_ptr_conv.is_owned = false;
37356         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
37357         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, AnnouncementSignatures_get_bitcoin_signature(&this_ptr_conv).compact_form);
37358         return ret_arr;
37359 }
37360
37361 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1set_1bitcoin_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
37362         LDKAnnouncementSignatures this_ptr_conv;
37363         this_ptr_conv.inner = untag_ptr(this_ptr);
37364         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37365         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37366         this_ptr_conv.is_owned = false;
37367         LDKSignature val_ref;
37368         CHECK((*env)->GetArrayLength(env, val) == 64);
37369         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
37370         AnnouncementSignatures_set_bitcoin_signature(&this_ptr_conv, val_ref);
37371 }
37372
37373 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) {
37374         LDKThirtyTwoBytes channel_id_arg_ref;
37375         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
37376         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
37377         LDKSignature node_signature_arg_ref;
37378         CHECK((*env)->GetArrayLength(env, node_signature_arg) == 64);
37379         (*env)->GetByteArrayRegion(env, node_signature_arg, 0, 64, node_signature_arg_ref.compact_form);
37380         LDKSignature bitcoin_signature_arg_ref;
37381         CHECK((*env)->GetArrayLength(env, bitcoin_signature_arg) == 64);
37382         (*env)->GetByteArrayRegion(env, bitcoin_signature_arg, 0, 64, bitcoin_signature_arg_ref.compact_form);
37383         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_new(channel_id_arg_ref, short_channel_id_arg, node_signature_arg_ref, bitcoin_signature_arg_ref);
37384         int64_t ret_ref = 0;
37385         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37386         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37387         return ret_ref;
37388 }
37389
37390 static inline uint64_t AnnouncementSignatures_clone_ptr(LDKAnnouncementSignatures *NONNULL_PTR arg) {
37391         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_clone(arg);
37392         int64_t ret_ref = 0;
37393         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37394         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37395         return ret_ref;
37396 }
37397 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
37398         LDKAnnouncementSignatures arg_conv;
37399         arg_conv.inner = untag_ptr(arg);
37400         arg_conv.is_owned = ptr_is_owned(arg);
37401         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
37402         arg_conv.is_owned = false;
37403         int64_t ret_conv = AnnouncementSignatures_clone_ptr(&arg_conv);
37404         return ret_conv;
37405 }
37406
37407 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
37408         LDKAnnouncementSignatures orig_conv;
37409         orig_conv.inner = untag_ptr(orig);
37410         orig_conv.is_owned = ptr_is_owned(orig);
37411         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
37412         orig_conv.is_owned = false;
37413         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_clone(&orig_conv);
37414         int64_t ret_ref = 0;
37415         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37416         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37417         return ret_ref;
37418 }
37419
37420 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
37421         LDKAnnouncementSignatures a_conv;
37422         a_conv.inner = untag_ptr(a);
37423         a_conv.is_owned = ptr_is_owned(a);
37424         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
37425         a_conv.is_owned = false;
37426         LDKAnnouncementSignatures b_conv;
37427         b_conv.inner = untag_ptr(b);
37428         b_conv.is_owned = ptr_is_owned(b);
37429         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
37430         b_conv.is_owned = false;
37431         jboolean ret_conv = AnnouncementSignatures_eq(&a_conv, &b_conv);
37432         return ret_conv;
37433 }
37434
37435 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetAddress_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
37436         if (!ptr_is_owned(this_ptr)) return;
37437         void* this_ptr_ptr = untag_ptr(this_ptr);
37438         CHECK_ACCESS(this_ptr_ptr);
37439         LDKNetAddress this_ptr_conv = *(LDKNetAddress*)(this_ptr_ptr);
37440         FREE(untag_ptr(this_ptr));
37441         NetAddress_free(this_ptr_conv);
37442 }
37443
37444 static inline uint64_t NetAddress_clone_ptr(LDKNetAddress *NONNULL_PTR arg) {
37445         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
37446         *ret_copy = NetAddress_clone(arg);
37447         int64_t ret_ref = tag_ptr(ret_copy, true);
37448         return ret_ref;
37449 }
37450 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
37451         LDKNetAddress* arg_conv = (LDKNetAddress*)untag_ptr(arg);
37452         int64_t ret_conv = NetAddress_clone_ptr(arg_conv);
37453         return ret_conv;
37454 }
37455
37456 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1clone(JNIEnv *env, jclass clz, int64_t orig) {
37457         LDKNetAddress* orig_conv = (LDKNetAddress*)untag_ptr(orig);
37458         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
37459         *ret_copy = NetAddress_clone(orig_conv);
37460         int64_t ret_ref = tag_ptr(ret_copy, true);
37461         return ret_ref;
37462 }
37463
37464 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1ipv4(JNIEnv *env, jclass clz, int8_tArray addr, int16_t port) {
37465         LDKFourBytes addr_ref;
37466         CHECK((*env)->GetArrayLength(env, addr) == 4);
37467         (*env)->GetByteArrayRegion(env, addr, 0, 4, addr_ref.data);
37468         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
37469         *ret_copy = NetAddress_ipv4(addr_ref, port);
37470         int64_t ret_ref = tag_ptr(ret_copy, true);
37471         return ret_ref;
37472 }
37473
37474 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1ipv6(JNIEnv *env, jclass clz, int8_tArray addr, int16_t port) {
37475         LDKSixteenBytes addr_ref;
37476         CHECK((*env)->GetArrayLength(env, addr) == 16);
37477         (*env)->GetByteArrayRegion(env, addr, 0, 16, addr_ref.data);
37478         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
37479         *ret_copy = NetAddress_ipv6(addr_ref, port);
37480         int64_t ret_ref = tag_ptr(ret_copy, true);
37481         return ret_ref;
37482 }
37483
37484 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1onion_1v2(JNIEnv *env, jclass clz, int8_tArray a) {
37485         LDKTwelveBytes a_ref;
37486         CHECK((*env)->GetArrayLength(env, a) == 12);
37487         (*env)->GetByteArrayRegion(env, a, 0, 12, a_ref.data);
37488         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
37489         *ret_copy = NetAddress_onion_v2(a_ref);
37490         int64_t ret_ref = tag_ptr(ret_copy, true);
37491         return ret_ref;
37492 }
37493
37494 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) {
37495         LDKThirtyTwoBytes ed25519_pubkey_ref;
37496         CHECK((*env)->GetArrayLength(env, ed25519_pubkey) == 32);
37497         (*env)->GetByteArrayRegion(env, ed25519_pubkey, 0, 32, ed25519_pubkey_ref.data);
37498         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
37499         *ret_copy = NetAddress_onion_v3(ed25519_pubkey_ref, checksum, version, port);
37500         int64_t ret_ref = tag_ptr(ret_copy, true);
37501         return ret_ref;
37502 }
37503
37504 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1hostname(JNIEnv *env, jclass clz, int64_t hostname, int16_t port) {
37505         LDKHostname hostname_conv;
37506         hostname_conv.inner = untag_ptr(hostname);
37507         hostname_conv.is_owned = ptr_is_owned(hostname);
37508         CHECK_INNER_FIELD_ACCESS_OR_NULL(hostname_conv);
37509         hostname_conv = Hostname_clone(&hostname_conv);
37510         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
37511         *ret_copy = NetAddress_hostname(hostname_conv, port);
37512         int64_t ret_ref = tag_ptr(ret_copy, true);
37513         return ret_ref;
37514 }
37515
37516 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NetAddress_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
37517         LDKNetAddress* a_conv = (LDKNetAddress*)untag_ptr(a);
37518         LDKNetAddress* b_conv = (LDKNetAddress*)untag_ptr(b);
37519         jboolean ret_conv = NetAddress_eq(a_conv, b_conv);
37520         return ret_conv;
37521 }
37522
37523 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NetAddress_1write(JNIEnv *env, jclass clz, int64_t obj) {
37524         LDKNetAddress* obj_conv = (LDKNetAddress*)untag_ptr(obj);
37525         LDKCVec_u8Z ret_var = NetAddress_write(obj_conv);
37526         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37527         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37528         CVec_u8Z_free(ret_var);
37529         return ret_arr;
37530 }
37531
37532 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
37533         LDKu8slice ser_ref;
37534         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
37535         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
37536         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
37537         *ret_conv = NetAddress_read(ser_ref);
37538         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
37539         return tag_ptr(ret_conv, true);
37540 }
37541
37542 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
37543         LDKUnsignedNodeAnnouncement this_obj_conv;
37544         this_obj_conv.inner = untag_ptr(this_obj);
37545         this_obj_conv.is_owned = ptr_is_owned(this_obj);
37546         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
37547         UnsignedNodeAnnouncement_free(this_obj_conv);
37548 }
37549
37550 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
37551         LDKUnsignedNodeAnnouncement this_ptr_conv;
37552         this_ptr_conv.inner = untag_ptr(this_ptr);
37553         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37554         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37555         this_ptr_conv.is_owned = false;
37556         LDKNodeFeatures ret_var = UnsignedNodeAnnouncement_get_features(&this_ptr_conv);
37557         int64_t ret_ref = 0;
37558         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37559         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37560         return ret_ref;
37561 }
37562
37563 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
37564         LDKUnsignedNodeAnnouncement this_ptr_conv;
37565         this_ptr_conv.inner = untag_ptr(this_ptr);
37566         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37567         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37568         this_ptr_conv.is_owned = false;
37569         LDKNodeFeatures val_conv;
37570         val_conv.inner = untag_ptr(val);
37571         val_conv.is_owned = ptr_is_owned(val);
37572         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
37573         val_conv = NodeFeatures_clone(&val_conv);
37574         UnsignedNodeAnnouncement_set_features(&this_ptr_conv, val_conv);
37575 }
37576
37577 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr) {
37578         LDKUnsignedNodeAnnouncement this_ptr_conv;
37579         this_ptr_conv.inner = untag_ptr(this_ptr);
37580         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37581         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37582         this_ptr_conv.is_owned = false;
37583         int32_t ret_conv = UnsignedNodeAnnouncement_get_timestamp(&this_ptr_conv);
37584         return ret_conv;
37585 }
37586
37587 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
37588         LDKUnsignedNodeAnnouncement this_ptr_conv;
37589         this_ptr_conv.inner = untag_ptr(this_ptr);
37590         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37591         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37592         this_ptr_conv.is_owned = false;
37593         UnsignedNodeAnnouncement_set_timestamp(&this_ptr_conv, val);
37594 }
37595
37596 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
37597         LDKUnsignedNodeAnnouncement this_ptr_conv;
37598         this_ptr_conv.inner = untag_ptr(this_ptr);
37599         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37600         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37601         this_ptr_conv.is_owned = false;
37602         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
37603         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, UnsignedNodeAnnouncement_get_node_id(&this_ptr_conv).compressed_form);
37604         return ret_arr;
37605 }
37606
37607 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
37608         LDKUnsignedNodeAnnouncement this_ptr_conv;
37609         this_ptr_conv.inner = untag_ptr(this_ptr);
37610         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37611         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37612         this_ptr_conv.is_owned = false;
37613         LDKPublicKey val_ref;
37614         CHECK((*env)->GetArrayLength(env, val) == 33);
37615         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
37616         UnsignedNodeAnnouncement_set_node_id(&this_ptr_conv, val_ref);
37617 }
37618
37619 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1rgb(JNIEnv *env, jclass clz, int64_t this_ptr) {
37620         LDKUnsignedNodeAnnouncement this_ptr_conv;
37621         this_ptr_conv.inner = untag_ptr(this_ptr);
37622         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37623         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37624         this_ptr_conv.is_owned = false;
37625         int8_tArray ret_arr = (*env)->NewByteArray(env, 3);
37626         (*env)->SetByteArrayRegion(env, ret_arr, 0, 3, *UnsignedNodeAnnouncement_get_rgb(&this_ptr_conv));
37627         return ret_arr;
37628 }
37629
37630 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1rgb(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
37631         LDKUnsignedNodeAnnouncement this_ptr_conv;
37632         this_ptr_conv.inner = untag_ptr(this_ptr);
37633         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37634         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37635         this_ptr_conv.is_owned = false;
37636         LDKThreeBytes val_ref;
37637         CHECK((*env)->GetArrayLength(env, val) == 3);
37638         (*env)->GetByteArrayRegion(env, val, 0, 3, val_ref.data);
37639         UnsignedNodeAnnouncement_set_rgb(&this_ptr_conv, val_ref);
37640 }
37641
37642 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1alias(JNIEnv *env, jclass clz, int64_t this_ptr) {
37643         LDKUnsignedNodeAnnouncement this_ptr_conv;
37644         this_ptr_conv.inner = untag_ptr(this_ptr);
37645         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37646         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37647         this_ptr_conv.is_owned = false;
37648         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
37649         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UnsignedNodeAnnouncement_get_alias(&this_ptr_conv));
37650         return ret_arr;
37651 }
37652
37653 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1alias(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
37654         LDKUnsignedNodeAnnouncement this_ptr_conv;
37655         this_ptr_conv.inner = untag_ptr(this_ptr);
37656         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37657         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37658         this_ptr_conv.is_owned = false;
37659         LDKThirtyTwoBytes val_ref;
37660         CHECK((*env)->GetArrayLength(env, val) == 32);
37661         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
37662         UnsignedNodeAnnouncement_set_alias(&this_ptr_conv, val_ref);
37663 }
37664
37665 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1addresses(JNIEnv *env, jclass clz, int64_t this_ptr) {
37666         LDKUnsignedNodeAnnouncement this_ptr_conv;
37667         this_ptr_conv.inner = untag_ptr(this_ptr);
37668         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37669         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37670         this_ptr_conv.is_owned = false;
37671         LDKCVec_NetAddressZ ret_var = UnsignedNodeAnnouncement_get_addresses(&this_ptr_conv);
37672         int64_tArray ret_arr = NULL;
37673         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
37674         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
37675         for (size_t m = 0; m < ret_var.datalen; m++) {
37676                 LDKNetAddress *ret_conv_12_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
37677                 *ret_conv_12_copy = ret_var.data[m];
37678                 int64_t ret_conv_12_ref = tag_ptr(ret_conv_12_copy, true);
37679                 ret_arr_ptr[m] = ret_conv_12_ref;
37680         }
37681         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
37682         FREE(ret_var.data);
37683         return ret_arr;
37684 }
37685
37686 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1addresses(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
37687         LDKUnsignedNodeAnnouncement this_ptr_conv;
37688         this_ptr_conv.inner = untag_ptr(this_ptr);
37689         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37690         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37691         this_ptr_conv.is_owned = false;
37692         LDKCVec_NetAddressZ val_constr;
37693         val_constr.datalen = (*env)->GetArrayLength(env, val);
37694         if (val_constr.datalen > 0)
37695                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
37696         else
37697                 val_constr.data = NULL;
37698         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
37699         for (size_t m = 0; m < val_constr.datalen; m++) {
37700                 int64_t val_conv_12 = val_vals[m];
37701                 void* val_conv_12_ptr = untag_ptr(val_conv_12);
37702                 CHECK_ACCESS(val_conv_12_ptr);
37703                 LDKNetAddress val_conv_12_conv = *(LDKNetAddress*)(val_conv_12_ptr);
37704                 val_conv_12_conv = NetAddress_clone((LDKNetAddress*)untag_ptr(val_conv_12));
37705                 val_constr.data[m] = val_conv_12_conv;
37706         }
37707         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
37708         UnsignedNodeAnnouncement_set_addresses(&this_ptr_conv, val_constr);
37709 }
37710
37711 static inline uint64_t UnsignedNodeAnnouncement_clone_ptr(LDKUnsignedNodeAnnouncement *NONNULL_PTR arg) {
37712         LDKUnsignedNodeAnnouncement ret_var = UnsignedNodeAnnouncement_clone(arg);
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 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
37719         LDKUnsignedNodeAnnouncement arg_conv;
37720         arg_conv.inner = untag_ptr(arg);
37721         arg_conv.is_owned = ptr_is_owned(arg);
37722         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
37723         arg_conv.is_owned = false;
37724         int64_t ret_conv = UnsignedNodeAnnouncement_clone_ptr(&arg_conv);
37725         return ret_conv;
37726 }
37727
37728 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1clone(JNIEnv *env, jclass clz, int64_t orig) {
37729         LDKUnsignedNodeAnnouncement orig_conv;
37730         orig_conv.inner = untag_ptr(orig);
37731         orig_conv.is_owned = ptr_is_owned(orig);
37732         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
37733         orig_conv.is_owned = false;
37734         LDKUnsignedNodeAnnouncement ret_var = UnsignedNodeAnnouncement_clone(&orig_conv);
37735         int64_t ret_ref = 0;
37736         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37737         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37738         return ret_ref;
37739 }
37740
37741 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
37742         LDKUnsignedNodeAnnouncement a_conv;
37743         a_conv.inner = untag_ptr(a);
37744         a_conv.is_owned = ptr_is_owned(a);
37745         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
37746         a_conv.is_owned = false;
37747         LDKUnsignedNodeAnnouncement b_conv;
37748         b_conv.inner = untag_ptr(b);
37749         b_conv.is_owned = ptr_is_owned(b);
37750         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
37751         b_conv.is_owned = false;
37752         jboolean ret_conv = UnsignedNodeAnnouncement_eq(&a_conv, &b_conv);
37753         return ret_conv;
37754 }
37755
37756 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
37757         LDKNodeAnnouncement this_obj_conv;
37758         this_obj_conv.inner = untag_ptr(this_obj);
37759         this_obj_conv.is_owned = ptr_is_owned(this_obj);
37760         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
37761         NodeAnnouncement_free(this_obj_conv);
37762 }
37763
37764 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
37765         LDKNodeAnnouncement this_ptr_conv;
37766         this_ptr_conv.inner = untag_ptr(this_ptr);
37767         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37768         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37769         this_ptr_conv.is_owned = false;
37770         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
37771         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, NodeAnnouncement_get_signature(&this_ptr_conv).compact_form);
37772         return ret_arr;
37773 }
37774
37775 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
37776         LDKNodeAnnouncement 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         LDKSignature val_ref;
37782         CHECK((*env)->GetArrayLength(env, val) == 64);
37783         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
37784         NodeAnnouncement_set_signature(&this_ptr_conv, val_ref);
37785 }
37786
37787 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1get_1contents(JNIEnv *env, jclass clz, int64_t this_ptr) {
37788         LDKNodeAnnouncement this_ptr_conv;
37789         this_ptr_conv.inner = untag_ptr(this_ptr);
37790         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37791         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37792         this_ptr_conv.is_owned = false;
37793         LDKUnsignedNodeAnnouncement ret_var = NodeAnnouncement_get_contents(&this_ptr_conv);
37794         int64_t ret_ref = 0;
37795         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37796         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37797         return ret_ref;
37798 }
37799
37800 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1set_1contents(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
37801         LDKNodeAnnouncement this_ptr_conv;
37802         this_ptr_conv.inner = untag_ptr(this_ptr);
37803         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37804         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37805         this_ptr_conv.is_owned = false;
37806         LDKUnsignedNodeAnnouncement val_conv;
37807         val_conv.inner = untag_ptr(val);
37808         val_conv.is_owned = ptr_is_owned(val);
37809         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
37810         val_conv = UnsignedNodeAnnouncement_clone(&val_conv);
37811         NodeAnnouncement_set_contents(&this_ptr_conv, val_conv);
37812 }
37813
37814 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1new(JNIEnv *env, jclass clz, int8_tArray signature_arg, int64_t contents_arg) {
37815         LDKSignature signature_arg_ref;
37816         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
37817         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
37818         LDKUnsignedNodeAnnouncement contents_arg_conv;
37819         contents_arg_conv.inner = untag_ptr(contents_arg);
37820         contents_arg_conv.is_owned = ptr_is_owned(contents_arg);
37821         CHECK_INNER_FIELD_ACCESS_OR_NULL(contents_arg_conv);
37822         contents_arg_conv = UnsignedNodeAnnouncement_clone(&contents_arg_conv);
37823         LDKNodeAnnouncement ret_var = NodeAnnouncement_new(signature_arg_ref, contents_arg_conv);
37824         int64_t ret_ref = 0;
37825         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37826         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37827         return ret_ref;
37828 }
37829
37830 static inline uint64_t NodeAnnouncement_clone_ptr(LDKNodeAnnouncement *NONNULL_PTR arg) {
37831         LDKNodeAnnouncement ret_var = NodeAnnouncement_clone(arg);
37832         int64_t ret_ref = 0;
37833         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37834         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37835         return ret_ref;
37836 }
37837 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
37838         LDKNodeAnnouncement arg_conv;
37839         arg_conv.inner = untag_ptr(arg);
37840         arg_conv.is_owned = ptr_is_owned(arg);
37841         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
37842         arg_conv.is_owned = false;
37843         int64_t ret_conv = NodeAnnouncement_clone_ptr(&arg_conv);
37844         return ret_conv;
37845 }
37846
37847 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1clone(JNIEnv *env, jclass clz, int64_t orig) {
37848         LDKNodeAnnouncement orig_conv;
37849         orig_conv.inner = untag_ptr(orig);
37850         orig_conv.is_owned = ptr_is_owned(orig);
37851         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
37852         orig_conv.is_owned = false;
37853         LDKNodeAnnouncement ret_var = NodeAnnouncement_clone(&orig_conv);
37854         int64_t ret_ref = 0;
37855         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37856         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37857         return ret_ref;
37858 }
37859
37860 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
37861         LDKNodeAnnouncement a_conv;
37862         a_conv.inner = untag_ptr(a);
37863         a_conv.is_owned = ptr_is_owned(a);
37864         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
37865         a_conv.is_owned = false;
37866         LDKNodeAnnouncement b_conv;
37867         b_conv.inner = untag_ptr(b);
37868         b_conv.is_owned = ptr_is_owned(b);
37869         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
37870         b_conv.is_owned = false;
37871         jboolean ret_conv = NodeAnnouncement_eq(&a_conv, &b_conv);
37872         return ret_conv;
37873 }
37874
37875 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
37876         LDKUnsignedChannelAnnouncement this_obj_conv;
37877         this_obj_conv.inner = untag_ptr(this_obj);
37878         this_obj_conv.is_owned = ptr_is_owned(this_obj);
37879         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
37880         UnsignedChannelAnnouncement_free(this_obj_conv);
37881 }
37882
37883 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
37884         LDKUnsignedChannelAnnouncement this_ptr_conv;
37885         this_ptr_conv.inner = untag_ptr(this_ptr);
37886         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37887         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37888         this_ptr_conv.is_owned = false;
37889         LDKChannelFeatures ret_var = UnsignedChannelAnnouncement_get_features(&this_ptr_conv);
37890         int64_t ret_ref = 0;
37891         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37892         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
37893         return ret_ref;
37894 }
37895
37896 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
37897         LDKUnsignedChannelAnnouncement this_ptr_conv;
37898         this_ptr_conv.inner = untag_ptr(this_ptr);
37899         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37900         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37901         this_ptr_conv.is_owned = false;
37902         LDKChannelFeatures val_conv;
37903         val_conv.inner = untag_ptr(val);
37904         val_conv.is_owned = ptr_is_owned(val);
37905         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
37906         val_conv = ChannelFeatures_clone(&val_conv);
37907         UnsignedChannelAnnouncement_set_features(&this_ptr_conv, val_conv);
37908 }
37909
37910 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
37911         LDKUnsignedChannelAnnouncement this_ptr_conv;
37912         this_ptr_conv.inner = untag_ptr(this_ptr);
37913         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37914         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37915         this_ptr_conv.is_owned = false;
37916         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
37917         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UnsignedChannelAnnouncement_get_chain_hash(&this_ptr_conv));
37918         return ret_arr;
37919 }
37920
37921 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
37922         LDKUnsignedChannelAnnouncement this_ptr_conv;
37923         this_ptr_conv.inner = untag_ptr(this_ptr);
37924         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37925         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37926         this_ptr_conv.is_owned = false;
37927         LDKThirtyTwoBytes val_ref;
37928         CHECK((*env)->GetArrayLength(env, val) == 32);
37929         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
37930         UnsignedChannelAnnouncement_set_chain_hash(&this_ptr_conv, val_ref);
37931 }
37932
37933 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
37934         LDKUnsignedChannelAnnouncement this_ptr_conv;
37935         this_ptr_conv.inner = untag_ptr(this_ptr);
37936         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37937         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37938         this_ptr_conv.is_owned = false;
37939         int64_t ret_conv = UnsignedChannelAnnouncement_get_short_channel_id(&this_ptr_conv);
37940         return ret_conv;
37941 }
37942
37943 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
37944         LDKUnsignedChannelAnnouncement this_ptr_conv;
37945         this_ptr_conv.inner = untag_ptr(this_ptr);
37946         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37947         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37948         this_ptr_conv.is_owned = false;
37949         UnsignedChannelAnnouncement_set_short_channel_id(&this_ptr_conv, val);
37950 }
37951
37952 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1node_1id_11(JNIEnv *env, jclass clz, int64_t this_ptr) {
37953         LDKUnsignedChannelAnnouncement this_ptr_conv;
37954         this_ptr_conv.inner = untag_ptr(this_ptr);
37955         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37956         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37957         this_ptr_conv.is_owned = false;
37958         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
37959         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, UnsignedChannelAnnouncement_get_node_id_1(&this_ptr_conv).compressed_form);
37960         return ret_arr;
37961 }
37962
37963 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1node_1id_11(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
37964         LDKUnsignedChannelAnnouncement this_ptr_conv;
37965         this_ptr_conv.inner = untag_ptr(this_ptr);
37966         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37967         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37968         this_ptr_conv.is_owned = false;
37969         LDKPublicKey val_ref;
37970         CHECK((*env)->GetArrayLength(env, val) == 33);
37971         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
37972         UnsignedChannelAnnouncement_set_node_id_1(&this_ptr_conv, val_ref);
37973 }
37974
37975 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1node_1id_12(JNIEnv *env, jclass clz, int64_t this_ptr) {
37976         LDKUnsignedChannelAnnouncement this_ptr_conv;
37977         this_ptr_conv.inner = untag_ptr(this_ptr);
37978         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37979         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37980         this_ptr_conv.is_owned = false;
37981         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
37982         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, UnsignedChannelAnnouncement_get_node_id_2(&this_ptr_conv).compressed_form);
37983         return ret_arr;
37984 }
37985
37986 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1node_1id_12(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
37987         LDKUnsignedChannelAnnouncement this_ptr_conv;
37988         this_ptr_conv.inner = untag_ptr(this_ptr);
37989         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
37990         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37991         this_ptr_conv.is_owned = false;
37992         LDKPublicKey val_ref;
37993         CHECK((*env)->GetArrayLength(env, val) == 33);
37994         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
37995         UnsignedChannelAnnouncement_set_node_id_2(&this_ptr_conv, val_ref);
37996 }
37997
37998 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1bitcoin_1key_11(JNIEnv *env, jclass clz, int64_t this_ptr) {
37999         LDKUnsignedChannelAnnouncement this_ptr_conv;
38000         this_ptr_conv.inner = untag_ptr(this_ptr);
38001         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38002         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38003         this_ptr_conv.is_owned = false;
38004         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
38005         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, UnsignedChannelAnnouncement_get_bitcoin_key_1(&this_ptr_conv).compressed_form);
38006         return ret_arr;
38007 }
38008
38009 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1bitcoin_1key_11(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
38010         LDKUnsignedChannelAnnouncement this_ptr_conv;
38011         this_ptr_conv.inner = untag_ptr(this_ptr);
38012         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38013         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38014         this_ptr_conv.is_owned = false;
38015         LDKPublicKey val_ref;
38016         CHECK((*env)->GetArrayLength(env, val) == 33);
38017         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
38018         UnsignedChannelAnnouncement_set_bitcoin_key_1(&this_ptr_conv, val_ref);
38019 }
38020
38021 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1bitcoin_1key_12(JNIEnv *env, jclass clz, int64_t this_ptr) {
38022         LDKUnsignedChannelAnnouncement this_ptr_conv;
38023         this_ptr_conv.inner = untag_ptr(this_ptr);
38024         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38025         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38026         this_ptr_conv.is_owned = false;
38027         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
38028         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, UnsignedChannelAnnouncement_get_bitcoin_key_2(&this_ptr_conv).compressed_form);
38029         return ret_arr;
38030 }
38031
38032 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1bitcoin_1key_12(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
38033         LDKUnsignedChannelAnnouncement this_ptr_conv;
38034         this_ptr_conv.inner = untag_ptr(this_ptr);
38035         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38036         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38037         this_ptr_conv.is_owned = false;
38038         LDKPublicKey val_ref;
38039         CHECK((*env)->GetArrayLength(env, val) == 33);
38040         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
38041         UnsignedChannelAnnouncement_set_bitcoin_key_2(&this_ptr_conv, val_ref);
38042 }
38043
38044 static inline uint64_t UnsignedChannelAnnouncement_clone_ptr(LDKUnsignedChannelAnnouncement *NONNULL_PTR arg) {
38045         LDKUnsignedChannelAnnouncement ret_var = UnsignedChannelAnnouncement_clone(arg);
38046         int64_t ret_ref = 0;
38047         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38048         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
38049         return ret_ref;
38050 }
38051 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
38052         LDKUnsignedChannelAnnouncement arg_conv;
38053         arg_conv.inner = untag_ptr(arg);
38054         arg_conv.is_owned = ptr_is_owned(arg);
38055         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
38056         arg_conv.is_owned = false;
38057         int64_t ret_conv = UnsignedChannelAnnouncement_clone_ptr(&arg_conv);
38058         return ret_conv;
38059 }
38060
38061 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1clone(JNIEnv *env, jclass clz, int64_t orig) {
38062         LDKUnsignedChannelAnnouncement orig_conv;
38063         orig_conv.inner = untag_ptr(orig);
38064         orig_conv.is_owned = ptr_is_owned(orig);
38065         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
38066         orig_conv.is_owned = false;
38067         LDKUnsignedChannelAnnouncement ret_var = UnsignedChannelAnnouncement_clone(&orig_conv);
38068         int64_t ret_ref = 0;
38069         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38070         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
38071         return ret_ref;
38072 }
38073
38074 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
38075         LDKUnsignedChannelAnnouncement a_conv;
38076         a_conv.inner = untag_ptr(a);
38077         a_conv.is_owned = ptr_is_owned(a);
38078         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
38079         a_conv.is_owned = false;
38080         LDKUnsignedChannelAnnouncement b_conv;
38081         b_conv.inner = untag_ptr(b);
38082         b_conv.is_owned = ptr_is_owned(b);
38083         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
38084         b_conv.is_owned = false;
38085         jboolean ret_conv = UnsignedChannelAnnouncement_eq(&a_conv, &b_conv);
38086         return ret_conv;
38087 }
38088
38089 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
38090         LDKChannelAnnouncement this_obj_conv;
38091         this_obj_conv.inner = untag_ptr(this_obj);
38092         this_obj_conv.is_owned = ptr_is_owned(this_obj);
38093         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38094         ChannelAnnouncement_free(this_obj_conv);
38095 }
38096
38097 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1node_1signature_11(JNIEnv *env, jclass clz, int64_t this_ptr) {
38098         LDKChannelAnnouncement this_ptr_conv;
38099         this_ptr_conv.inner = untag_ptr(this_ptr);
38100         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38101         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38102         this_ptr_conv.is_owned = false;
38103         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
38104         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelAnnouncement_get_node_signature_1(&this_ptr_conv).compact_form);
38105         return ret_arr;
38106 }
38107
38108 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1node_1signature_11(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
38109         LDKChannelAnnouncement this_ptr_conv;
38110         this_ptr_conv.inner = untag_ptr(this_ptr);
38111         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38112         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38113         this_ptr_conv.is_owned = false;
38114         LDKSignature val_ref;
38115         CHECK((*env)->GetArrayLength(env, val) == 64);
38116         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
38117         ChannelAnnouncement_set_node_signature_1(&this_ptr_conv, val_ref);
38118 }
38119
38120 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1node_1signature_12(JNIEnv *env, jclass clz, int64_t this_ptr) {
38121         LDKChannelAnnouncement this_ptr_conv;
38122         this_ptr_conv.inner = untag_ptr(this_ptr);
38123         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38124         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38125         this_ptr_conv.is_owned = false;
38126         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
38127         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelAnnouncement_get_node_signature_2(&this_ptr_conv).compact_form);
38128         return ret_arr;
38129 }
38130
38131 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1node_1signature_12(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
38132         LDKChannelAnnouncement this_ptr_conv;
38133         this_ptr_conv.inner = untag_ptr(this_ptr);
38134         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38135         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38136         this_ptr_conv.is_owned = false;
38137         LDKSignature val_ref;
38138         CHECK((*env)->GetArrayLength(env, val) == 64);
38139         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
38140         ChannelAnnouncement_set_node_signature_2(&this_ptr_conv, val_ref);
38141 }
38142
38143 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1bitcoin_1signature_11(JNIEnv *env, jclass clz, int64_t this_ptr) {
38144         LDKChannelAnnouncement this_ptr_conv;
38145         this_ptr_conv.inner = untag_ptr(this_ptr);
38146         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38147         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38148         this_ptr_conv.is_owned = false;
38149         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
38150         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelAnnouncement_get_bitcoin_signature_1(&this_ptr_conv).compact_form);
38151         return ret_arr;
38152 }
38153
38154 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1bitcoin_1signature_11(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
38155         LDKChannelAnnouncement this_ptr_conv;
38156         this_ptr_conv.inner = untag_ptr(this_ptr);
38157         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38158         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38159         this_ptr_conv.is_owned = false;
38160         LDKSignature val_ref;
38161         CHECK((*env)->GetArrayLength(env, val) == 64);
38162         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
38163         ChannelAnnouncement_set_bitcoin_signature_1(&this_ptr_conv, val_ref);
38164 }
38165
38166 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1bitcoin_1signature_12(JNIEnv *env, jclass clz, int64_t this_ptr) {
38167         LDKChannelAnnouncement this_ptr_conv;
38168         this_ptr_conv.inner = untag_ptr(this_ptr);
38169         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38170         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38171         this_ptr_conv.is_owned = false;
38172         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
38173         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelAnnouncement_get_bitcoin_signature_2(&this_ptr_conv).compact_form);
38174         return ret_arr;
38175 }
38176
38177 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1bitcoin_1signature_12(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
38178         LDKChannelAnnouncement this_ptr_conv;
38179         this_ptr_conv.inner = untag_ptr(this_ptr);
38180         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38181         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38182         this_ptr_conv.is_owned = false;
38183         LDKSignature val_ref;
38184         CHECK((*env)->GetArrayLength(env, val) == 64);
38185         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
38186         ChannelAnnouncement_set_bitcoin_signature_2(&this_ptr_conv, val_ref);
38187 }
38188
38189 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1contents(JNIEnv *env, jclass clz, int64_t this_ptr) {
38190         LDKChannelAnnouncement this_ptr_conv;
38191         this_ptr_conv.inner = untag_ptr(this_ptr);
38192         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38193         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38194         this_ptr_conv.is_owned = false;
38195         LDKUnsignedChannelAnnouncement ret_var = ChannelAnnouncement_get_contents(&this_ptr_conv);
38196         int64_t ret_ref = 0;
38197         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38198         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
38199         return ret_ref;
38200 }
38201
38202 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1contents(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
38203         LDKChannelAnnouncement this_ptr_conv;
38204         this_ptr_conv.inner = untag_ptr(this_ptr);
38205         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38206         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38207         this_ptr_conv.is_owned = false;
38208         LDKUnsignedChannelAnnouncement val_conv;
38209         val_conv.inner = untag_ptr(val);
38210         val_conv.is_owned = ptr_is_owned(val);
38211         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
38212         val_conv = UnsignedChannelAnnouncement_clone(&val_conv);
38213         ChannelAnnouncement_set_contents(&this_ptr_conv, val_conv);
38214 }
38215
38216 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) {
38217         LDKSignature node_signature_1_arg_ref;
38218         CHECK((*env)->GetArrayLength(env, node_signature_1_arg) == 64);
38219         (*env)->GetByteArrayRegion(env, node_signature_1_arg, 0, 64, node_signature_1_arg_ref.compact_form);
38220         LDKSignature node_signature_2_arg_ref;
38221         CHECK((*env)->GetArrayLength(env, node_signature_2_arg) == 64);
38222         (*env)->GetByteArrayRegion(env, node_signature_2_arg, 0, 64, node_signature_2_arg_ref.compact_form);
38223         LDKSignature bitcoin_signature_1_arg_ref;
38224         CHECK((*env)->GetArrayLength(env, bitcoin_signature_1_arg) == 64);
38225         (*env)->GetByteArrayRegion(env, bitcoin_signature_1_arg, 0, 64, bitcoin_signature_1_arg_ref.compact_form);
38226         LDKSignature bitcoin_signature_2_arg_ref;
38227         CHECK((*env)->GetArrayLength(env, bitcoin_signature_2_arg) == 64);
38228         (*env)->GetByteArrayRegion(env, bitcoin_signature_2_arg, 0, 64, bitcoin_signature_2_arg_ref.compact_form);
38229         LDKUnsignedChannelAnnouncement contents_arg_conv;
38230         contents_arg_conv.inner = untag_ptr(contents_arg);
38231         contents_arg_conv.is_owned = ptr_is_owned(contents_arg);
38232         CHECK_INNER_FIELD_ACCESS_OR_NULL(contents_arg_conv);
38233         contents_arg_conv = UnsignedChannelAnnouncement_clone(&contents_arg_conv);
38234         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);
38235         int64_t ret_ref = 0;
38236         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38237         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
38238         return ret_ref;
38239 }
38240
38241 static inline uint64_t ChannelAnnouncement_clone_ptr(LDKChannelAnnouncement *NONNULL_PTR arg) {
38242         LDKChannelAnnouncement ret_var = ChannelAnnouncement_clone(arg);
38243         int64_t ret_ref = 0;
38244         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38245         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
38246         return ret_ref;
38247 }
38248 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
38249         LDKChannelAnnouncement arg_conv;
38250         arg_conv.inner = untag_ptr(arg);
38251         arg_conv.is_owned = ptr_is_owned(arg);
38252         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
38253         arg_conv.is_owned = false;
38254         int64_t ret_conv = ChannelAnnouncement_clone_ptr(&arg_conv);
38255         return ret_conv;
38256 }
38257
38258 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1clone(JNIEnv *env, jclass clz, int64_t orig) {
38259         LDKChannelAnnouncement orig_conv;
38260         orig_conv.inner = untag_ptr(orig);
38261         orig_conv.is_owned = ptr_is_owned(orig);
38262         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
38263         orig_conv.is_owned = false;
38264         LDKChannelAnnouncement ret_var = ChannelAnnouncement_clone(&orig_conv);
38265         int64_t ret_ref = 0;
38266         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38267         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
38268         return ret_ref;
38269 }
38270
38271 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
38272         LDKChannelAnnouncement a_conv;
38273         a_conv.inner = untag_ptr(a);
38274         a_conv.is_owned = ptr_is_owned(a);
38275         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
38276         a_conv.is_owned = false;
38277         LDKChannelAnnouncement b_conv;
38278         b_conv.inner = untag_ptr(b);
38279         b_conv.is_owned = ptr_is_owned(b);
38280         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
38281         b_conv.is_owned = false;
38282         jboolean ret_conv = ChannelAnnouncement_eq(&a_conv, &b_conv);
38283         return ret_conv;
38284 }
38285
38286 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
38287         LDKUnsignedChannelUpdate this_obj_conv;
38288         this_obj_conv.inner = untag_ptr(this_obj);
38289         this_obj_conv.is_owned = ptr_is_owned(this_obj);
38290         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38291         UnsignedChannelUpdate_free(this_obj_conv);
38292 }
38293
38294 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
38295         LDKUnsignedChannelUpdate this_ptr_conv;
38296         this_ptr_conv.inner = untag_ptr(this_ptr);
38297         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38298         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38299         this_ptr_conv.is_owned = false;
38300         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
38301         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UnsignedChannelUpdate_get_chain_hash(&this_ptr_conv));
38302         return ret_arr;
38303 }
38304
38305 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
38306         LDKUnsignedChannelUpdate this_ptr_conv;
38307         this_ptr_conv.inner = untag_ptr(this_ptr);
38308         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38309         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38310         this_ptr_conv.is_owned = false;
38311         LDKThirtyTwoBytes val_ref;
38312         CHECK((*env)->GetArrayLength(env, val) == 32);
38313         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
38314         UnsignedChannelUpdate_set_chain_hash(&this_ptr_conv, val_ref);
38315 }
38316
38317 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
38318         LDKUnsignedChannelUpdate this_ptr_conv;
38319         this_ptr_conv.inner = untag_ptr(this_ptr);
38320         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38321         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38322         this_ptr_conv.is_owned = false;
38323         int64_t ret_conv = UnsignedChannelUpdate_get_short_channel_id(&this_ptr_conv);
38324         return ret_conv;
38325 }
38326
38327 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
38328         LDKUnsignedChannelUpdate this_ptr_conv;
38329         this_ptr_conv.inner = untag_ptr(this_ptr);
38330         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38331         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38332         this_ptr_conv.is_owned = false;
38333         UnsignedChannelUpdate_set_short_channel_id(&this_ptr_conv, val);
38334 }
38335
38336 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr) {
38337         LDKUnsignedChannelUpdate this_ptr_conv;
38338         this_ptr_conv.inner = untag_ptr(this_ptr);
38339         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38340         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38341         this_ptr_conv.is_owned = false;
38342         int32_t ret_conv = UnsignedChannelUpdate_get_timestamp(&this_ptr_conv);
38343         return ret_conv;
38344 }
38345
38346 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
38347         LDKUnsignedChannelUpdate this_ptr_conv;
38348         this_ptr_conv.inner = untag_ptr(this_ptr);
38349         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38350         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38351         this_ptr_conv.is_owned = false;
38352         UnsignedChannelUpdate_set_timestamp(&this_ptr_conv, val);
38353 }
38354
38355 JNIEXPORT int8_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1flags(JNIEnv *env, jclass clz, int64_t this_ptr) {
38356         LDKUnsignedChannelUpdate this_ptr_conv;
38357         this_ptr_conv.inner = untag_ptr(this_ptr);
38358         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38359         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38360         this_ptr_conv.is_owned = false;
38361         int8_t ret_conv = UnsignedChannelUpdate_get_flags(&this_ptr_conv);
38362         return ret_conv;
38363 }
38364
38365 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1flags(JNIEnv *env, jclass clz, int64_t this_ptr, int8_t val) {
38366         LDKUnsignedChannelUpdate this_ptr_conv;
38367         this_ptr_conv.inner = untag_ptr(this_ptr);
38368         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38369         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38370         this_ptr_conv.is_owned = false;
38371         UnsignedChannelUpdate_set_flags(&this_ptr_conv, val);
38372 }
38373
38374 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
38375         LDKUnsignedChannelUpdate this_ptr_conv;
38376         this_ptr_conv.inner = untag_ptr(this_ptr);
38377         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38378         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38379         this_ptr_conv.is_owned = false;
38380         int16_t ret_conv = UnsignedChannelUpdate_get_cltv_expiry_delta(&this_ptr_conv);
38381         return ret_conv;
38382 }
38383
38384 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
38385         LDKUnsignedChannelUpdate this_ptr_conv;
38386         this_ptr_conv.inner = untag_ptr(this_ptr);
38387         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38388         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38389         this_ptr_conv.is_owned = false;
38390         UnsignedChannelUpdate_set_cltv_expiry_delta(&this_ptr_conv, val);
38391 }
38392
38393 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
38394         LDKUnsignedChannelUpdate this_ptr_conv;
38395         this_ptr_conv.inner = untag_ptr(this_ptr);
38396         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38397         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38398         this_ptr_conv.is_owned = false;
38399         int64_t ret_conv = UnsignedChannelUpdate_get_htlc_minimum_msat(&this_ptr_conv);
38400         return ret_conv;
38401 }
38402
38403 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
38404         LDKUnsignedChannelUpdate this_ptr_conv;
38405         this_ptr_conv.inner = untag_ptr(this_ptr);
38406         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38407         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38408         this_ptr_conv.is_owned = false;
38409         UnsignedChannelUpdate_set_htlc_minimum_msat(&this_ptr_conv, val);
38410 }
38411
38412 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
38413         LDKUnsignedChannelUpdate this_ptr_conv;
38414         this_ptr_conv.inner = untag_ptr(this_ptr);
38415         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38416         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38417         this_ptr_conv.is_owned = false;
38418         int64_t ret_conv = UnsignedChannelUpdate_get_htlc_maximum_msat(&this_ptr_conv);
38419         return ret_conv;
38420 }
38421
38422 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
38423         LDKUnsignedChannelUpdate this_ptr_conv;
38424         this_ptr_conv.inner = untag_ptr(this_ptr);
38425         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38426         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38427         this_ptr_conv.is_owned = false;
38428         UnsignedChannelUpdate_set_htlc_maximum_msat(&this_ptr_conv, val);
38429 }
38430
38431 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1fee_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
38432         LDKUnsignedChannelUpdate this_ptr_conv;
38433         this_ptr_conv.inner = untag_ptr(this_ptr);
38434         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38435         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38436         this_ptr_conv.is_owned = false;
38437         int32_t ret_conv = UnsignedChannelUpdate_get_fee_base_msat(&this_ptr_conv);
38438         return ret_conv;
38439 }
38440
38441 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1fee_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
38442         LDKUnsignedChannelUpdate this_ptr_conv;
38443         this_ptr_conv.inner = untag_ptr(this_ptr);
38444         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38445         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38446         this_ptr_conv.is_owned = false;
38447         UnsignedChannelUpdate_set_fee_base_msat(&this_ptr_conv, val);
38448 }
38449
38450 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr) {
38451         LDKUnsignedChannelUpdate this_ptr_conv;
38452         this_ptr_conv.inner = untag_ptr(this_ptr);
38453         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38454         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38455         this_ptr_conv.is_owned = false;
38456         int32_t ret_conv = UnsignedChannelUpdate_get_fee_proportional_millionths(&this_ptr_conv);
38457         return ret_conv;
38458 }
38459
38460 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
38461         LDKUnsignedChannelUpdate this_ptr_conv;
38462         this_ptr_conv.inner = untag_ptr(this_ptr);
38463         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38464         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38465         this_ptr_conv.is_owned = false;
38466         UnsignedChannelUpdate_set_fee_proportional_millionths(&this_ptr_conv, val);
38467 }
38468
38469 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1excess_1data(JNIEnv *env, jclass clz, int64_t this_ptr) {
38470         LDKUnsignedChannelUpdate this_ptr_conv;
38471         this_ptr_conv.inner = untag_ptr(this_ptr);
38472         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38473         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38474         this_ptr_conv.is_owned = false;
38475         LDKCVec_u8Z ret_var = UnsignedChannelUpdate_get_excess_data(&this_ptr_conv);
38476         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
38477         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
38478         CVec_u8Z_free(ret_var);
38479         return ret_arr;
38480 }
38481
38482 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1excess_1data(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
38483         LDKUnsignedChannelUpdate this_ptr_conv;
38484         this_ptr_conv.inner = untag_ptr(this_ptr);
38485         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38486         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38487         this_ptr_conv.is_owned = false;
38488         LDKCVec_u8Z val_ref;
38489         val_ref.datalen = (*env)->GetArrayLength(env, val);
38490         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
38491         (*env)->GetByteArrayRegion(env, val, 0, val_ref.datalen, val_ref.data);
38492         UnsignedChannelUpdate_set_excess_data(&this_ptr_conv, val_ref);
38493 }
38494
38495 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) {
38496         LDKThirtyTwoBytes chain_hash_arg_ref;
38497         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
38498         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
38499         LDKCVec_u8Z excess_data_arg_ref;
38500         excess_data_arg_ref.datalen = (*env)->GetArrayLength(env, excess_data_arg);
38501         excess_data_arg_ref.data = MALLOC(excess_data_arg_ref.datalen, "LDKCVec_u8Z Bytes");
38502         (*env)->GetByteArrayRegion(env, excess_data_arg, 0, excess_data_arg_ref.datalen, excess_data_arg_ref.data);
38503         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);
38504         int64_t ret_ref = 0;
38505         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38506         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
38507         return ret_ref;
38508 }
38509
38510 static inline uint64_t UnsignedChannelUpdate_clone_ptr(LDKUnsignedChannelUpdate *NONNULL_PTR arg) {
38511         LDKUnsignedChannelUpdate ret_var = UnsignedChannelUpdate_clone(arg);
38512         int64_t ret_ref = 0;
38513         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38514         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
38515         return ret_ref;
38516 }
38517 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
38518         LDKUnsignedChannelUpdate arg_conv;
38519         arg_conv.inner = untag_ptr(arg);
38520         arg_conv.is_owned = ptr_is_owned(arg);
38521         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
38522         arg_conv.is_owned = false;
38523         int64_t ret_conv = UnsignedChannelUpdate_clone_ptr(&arg_conv);
38524         return ret_conv;
38525 }
38526
38527 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
38528         LDKUnsignedChannelUpdate orig_conv;
38529         orig_conv.inner = untag_ptr(orig);
38530         orig_conv.is_owned = ptr_is_owned(orig);
38531         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
38532         orig_conv.is_owned = false;
38533         LDKUnsignedChannelUpdate ret_var = UnsignedChannelUpdate_clone(&orig_conv);
38534         int64_t ret_ref = 0;
38535         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38536         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
38537         return ret_ref;
38538 }
38539
38540 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
38541         LDKUnsignedChannelUpdate a_conv;
38542         a_conv.inner = untag_ptr(a);
38543         a_conv.is_owned = ptr_is_owned(a);
38544         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
38545         a_conv.is_owned = false;
38546         LDKUnsignedChannelUpdate b_conv;
38547         b_conv.inner = untag_ptr(b);
38548         b_conv.is_owned = ptr_is_owned(b);
38549         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
38550         b_conv.is_owned = false;
38551         jboolean ret_conv = UnsignedChannelUpdate_eq(&a_conv, &b_conv);
38552         return ret_conv;
38553 }
38554
38555 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
38556         LDKChannelUpdate this_obj_conv;
38557         this_obj_conv.inner = untag_ptr(this_obj);
38558         this_obj_conv.is_owned = ptr_is_owned(this_obj);
38559         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38560         ChannelUpdate_free(this_obj_conv);
38561 }
38562
38563 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
38564         LDKChannelUpdate this_ptr_conv;
38565         this_ptr_conv.inner = untag_ptr(this_ptr);
38566         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38567         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38568         this_ptr_conv.is_owned = false;
38569         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
38570         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelUpdate_get_signature(&this_ptr_conv).compact_form);
38571         return ret_arr;
38572 }
38573
38574 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
38575         LDKChannelUpdate this_ptr_conv;
38576         this_ptr_conv.inner = untag_ptr(this_ptr);
38577         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38578         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38579         this_ptr_conv.is_owned = false;
38580         LDKSignature val_ref;
38581         CHECK((*env)->GetArrayLength(env, val) == 64);
38582         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
38583         ChannelUpdate_set_signature(&this_ptr_conv, val_ref);
38584 }
38585
38586 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1get_1contents(JNIEnv *env, jclass clz, int64_t this_ptr) {
38587         LDKChannelUpdate this_ptr_conv;
38588         this_ptr_conv.inner = untag_ptr(this_ptr);
38589         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38590         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38591         this_ptr_conv.is_owned = false;
38592         LDKUnsignedChannelUpdate ret_var = ChannelUpdate_get_contents(&this_ptr_conv);
38593         int64_t ret_ref = 0;
38594         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38595         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
38596         return ret_ref;
38597 }
38598
38599 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1set_1contents(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
38600         LDKChannelUpdate this_ptr_conv;
38601         this_ptr_conv.inner = untag_ptr(this_ptr);
38602         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38603         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38604         this_ptr_conv.is_owned = false;
38605         LDKUnsignedChannelUpdate val_conv;
38606         val_conv.inner = untag_ptr(val);
38607         val_conv.is_owned = ptr_is_owned(val);
38608         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
38609         val_conv = UnsignedChannelUpdate_clone(&val_conv);
38610         ChannelUpdate_set_contents(&this_ptr_conv, val_conv);
38611 }
38612
38613 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1new(JNIEnv *env, jclass clz, int8_tArray signature_arg, int64_t contents_arg) {
38614         LDKSignature signature_arg_ref;
38615         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
38616         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
38617         LDKUnsignedChannelUpdate contents_arg_conv;
38618         contents_arg_conv.inner = untag_ptr(contents_arg);
38619         contents_arg_conv.is_owned = ptr_is_owned(contents_arg);
38620         CHECK_INNER_FIELD_ACCESS_OR_NULL(contents_arg_conv);
38621         contents_arg_conv = UnsignedChannelUpdate_clone(&contents_arg_conv);
38622         LDKChannelUpdate ret_var = ChannelUpdate_new(signature_arg_ref, contents_arg_conv);
38623         int64_t ret_ref = 0;
38624         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38625         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
38626         return ret_ref;
38627 }
38628
38629 static inline uint64_t ChannelUpdate_clone_ptr(LDKChannelUpdate *NONNULL_PTR arg) {
38630         LDKChannelUpdate ret_var = ChannelUpdate_clone(arg);
38631         int64_t ret_ref = 0;
38632         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38633         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
38634         return ret_ref;
38635 }
38636 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
38637         LDKChannelUpdate arg_conv;
38638         arg_conv.inner = untag_ptr(arg);
38639         arg_conv.is_owned = ptr_is_owned(arg);
38640         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
38641         arg_conv.is_owned = false;
38642         int64_t ret_conv = ChannelUpdate_clone_ptr(&arg_conv);
38643         return ret_conv;
38644 }
38645
38646 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
38647         LDKChannelUpdate orig_conv;
38648         orig_conv.inner = untag_ptr(orig);
38649         orig_conv.is_owned = ptr_is_owned(orig);
38650         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
38651         orig_conv.is_owned = false;
38652         LDKChannelUpdate ret_var = ChannelUpdate_clone(&orig_conv);
38653         int64_t ret_ref = 0;
38654         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38655         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
38656         return ret_ref;
38657 }
38658
38659 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
38660         LDKChannelUpdate a_conv;
38661         a_conv.inner = untag_ptr(a);
38662         a_conv.is_owned = ptr_is_owned(a);
38663         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
38664         a_conv.is_owned = false;
38665         LDKChannelUpdate b_conv;
38666         b_conv.inner = untag_ptr(b);
38667         b_conv.is_owned = ptr_is_owned(b);
38668         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
38669         b_conv.is_owned = false;
38670         jboolean ret_conv = ChannelUpdate_eq(&a_conv, &b_conv);
38671         return ret_conv;
38672 }
38673
38674 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
38675         LDKQueryChannelRange this_obj_conv;
38676         this_obj_conv.inner = untag_ptr(this_obj);
38677         this_obj_conv.is_owned = ptr_is_owned(this_obj);
38678         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38679         QueryChannelRange_free(this_obj_conv);
38680 }
38681
38682 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
38683         LDKQueryChannelRange this_ptr_conv;
38684         this_ptr_conv.inner = untag_ptr(this_ptr);
38685         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38686         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38687         this_ptr_conv.is_owned = false;
38688         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
38689         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *QueryChannelRange_get_chain_hash(&this_ptr_conv));
38690         return ret_arr;
38691 }
38692
38693 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
38694         LDKQueryChannelRange this_ptr_conv;
38695         this_ptr_conv.inner = untag_ptr(this_ptr);
38696         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38697         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38698         this_ptr_conv.is_owned = false;
38699         LDKThirtyTwoBytes val_ref;
38700         CHECK((*env)->GetArrayLength(env, val) == 32);
38701         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
38702         QueryChannelRange_set_chain_hash(&this_ptr_conv, val_ref);
38703 }
38704
38705 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1get_1first_1blocknum(JNIEnv *env, jclass clz, int64_t this_ptr) {
38706         LDKQueryChannelRange this_ptr_conv;
38707         this_ptr_conv.inner = untag_ptr(this_ptr);
38708         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38709         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38710         this_ptr_conv.is_owned = false;
38711         int32_t ret_conv = QueryChannelRange_get_first_blocknum(&this_ptr_conv);
38712         return ret_conv;
38713 }
38714
38715 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1set_1first_1blocknum(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
38716         LDKQueryChannelRange this_ptr_conv;
38717         this_ptr_conv.inner = untag_ptr(this_ptr);
38718         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38719         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38720         this_ptr_conv.is_owned = false;
38721         QueryChannelRange_set_first_blocknum(&this_ptr_conv, val);
38722 }
38723
38724 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1get_1number_1of_1blocks(JNIEnv *env, jclass clz, int64_t this_ptr) {
38725         LDKQueryChannelRange this_ptr_conv;
38726         this_ptr_conv.inner = untag_ptr(this_ptr);
38727         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38728         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38729         this_ptr_conv.is_owned = false;
38730         int32_t ret_conv = QueryChannelRange_get_number_of_blocks(&this_ptr_conv);
38731         return ret_conv;
38732 }
38733
38734 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1set_1number_1of_1blocks(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
38735         LDKQueryChannelRange this_ptr_conv;
38736         this_ptr_conv.inner = untag_ptr(this_ptr);
38737         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38738         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38739         this_ptr_conv.is_owned = false;
38740         QueryChannelRange_set_number_of_blocks(&this_ptr_conv, val);
38741 }
38742
38743 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) {
38744         LDKThirtyTwoBytes chain_hash_arg_ref;
38745         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
38746         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
38747         LDKQueryChannelRange ret_var = QueryChannelRange_new(chain_hash_arg_ref, first_blocknum_arg, number_of_blocks_arg);
38748         int64_t ret_ref = 0;
38749         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38750         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
38751         return ret_ref;
38752 }
38753
38754 static inline uint64_t QueryChannelRange_clone_ptr(LDKQueryChannelRange *NONNULL_PTR arg) {
38755         LDKQueryChannelRange ret_var = QueryChannelRange_clone(arg);
38756         int64_t ret_ref = 0;
38757         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38758         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
38759         return ret_ref;
38760 }
38761 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
38762         LDKQueryChannelRange arg_conv;
38763         arg_conv.inner = untag_ptr(arg);
38764         arg_conv.is_owned = ptr_is_owned(arg);
38765         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
38766         arg_conv.is_owned = false;
38767         int64_t ret_conv = QueryChannelRange_clone_ptr(&arg_conv);
38768         return ret_conv;
38769 }
38770
38771 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1clone(JNIEnv *env, jclass clz, int64_t orig) {
38772         LDKQueryChannelRange orig_conv;
38773         orig_conv.inner = untag_ptr(orig);
38774         orig_conv.is_owned = ptr_is_owned(orig);
38775         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
38776         orig_conv.is_owned = false;
38777         LDKQueryChannelRange ret_var = QueryChannelRange_clone(&orig_conv);
38778         int64_t ret_ref = 0;
38779         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38780         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
38781         return ret_ref;
38782 }
38783
38784 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
38785         LDKQueryChannelRange a_conv;
38786         a_conv.inner = untag_ptr(a);
38787         a_conv.is_owned = ptr_is_owned(a);
38788         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
38789         a_conv.is_owned = false;
38790         LDKQueryChannelRange b_conv;
38791         b_conv.inner = untag_ptr(b);
38792         b_conv.is_owned = ptr_is_owned(b);
38793         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
38794         b_conv.is_owned = false;
38795         jboolean ret_conv = QueryChannelRange_eq(&a_conv, &b_conv);
38796         return ret_conv;
38797 }
38798
38799 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
38800         LDKReplyChannelRange this_obj_conv;
38801         this_obj_conv.inner = untag_ptr(this_obj);
38802         this_obj_conv.is_owned = ptr_is_owned(this_obj);
38803         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38804         ReplyChannelRange_free(this_obj_conv);
38805 }
38806
38807 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
38808         LDKReplyChannelRange this_ptr_conv;
38809         this_ptr_conv.inner = untag_ptr(this_ptr);
38810         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38811         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38812         this_ptr_conv.is_owned = false;
38813         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
38814         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ReplyChannelRange_get_chain_hash(&this_ptr_conv));
38815         return ret_arr;
38816 }
38817
38818 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
38819         LDKReplyChannelRange this_ptr_conv;
38820         this_ptr_conv.inner = untag_ptr(this_ptr);
38821         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38822         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38823         this_ptr_conv.is_owned = false;
38824         LDKThirtyTwoBytes val_ref;
38825         CHECK((*env)->GetArrayLength(env, val) == 32);
38826         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
38827         ReplyChannelRange_set_chain_hash(&this_ptr_conv, val_ref);
38828 }
38829
38830 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1first_1blocknum(JNIEnv *env, jclass clz, int64_t this_ptr) {
38831         LDKReplyChannelRange this_ptr_conv;
38832         this_ptr_conv.inner = untag_ptr(this_ptr);
38833         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38834         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38835         this_ptr_conv.is_owned = false;
38836         int32_t ret_conv = ReplyChannelRange_get_first_blocknum(&this_ptr_conv);
38837         return ret_conv;
38838 }
38839
38840 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1first_1blocknum(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
38841         LDKReplyChannelRange this_ptr_conv;
38842         this_ptr_conv.inner = untag_ptr(this_ptr);
38843         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38844         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38845         this_ptr_conv.is_owned = false;
38846         ReplyChannelRange_set_first_blocknum(&this_ptr_conv, val);
38847 }
38848
38849 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1number_1of_1blocks(JNIEnv *env, jclass clz, int64_t this_ptr) {
38850         LDKReplyChannelRange this_ptr_conv;
38851         this_ptr_conv.inner = untag_ptr(this_ptr);
38852         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38853         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38854         this_ptr_conv.is_owned = false;
38855         int32_t ret_conv = ReplyChannelRange_get_number_of_blocks(&this_ptr_conv);
38856         return ret_conv;
38857 }
38858
38859 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1number_1of_1blocks(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
38860         LDKReplyChannelRange this_ptr_conv;
38861         this_ptr_conv.inner = untag_ptr(this_ptr);
38862         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38863         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38864         this_ptr_conv.is_owned = false;
38865         ReplyChannelRange_set_number_of_blocks(&this_ptr_conv, val);
38866 }
38867
38868 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1sync_1complete(JNIEnv *env, jclass clz, int64_t this_ptr) {
38869         LDKReplyChannelRange this_ptr_conv;
38870         this_ptr_conv.inner = untag_ptr(this_ptr);
38871         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38872         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38873         this_ptr_conv.is_owned = false;
38874         jboolean ret_conv = ReplyChannelRange_get_sync_complete(&this_ptr_conv);
38875         return ret_conv;
38876 }
38877
38878 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1sync_1complete(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
38879         LDKReplyChannelRange this_ptr_conv;
38880         this_ptr_conv.inner = untag_ptr(this_ptr);
38881         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38882         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38883         this_ptr_conv.is_owned = false;
38884         ReplyChannelRange_set_sync_complete(&this_ptr_conv, val);
38885 }
38886
38887 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1short_1channel_1ids(JNIEnv *env, jclass clz, int64_t this_ptr) {
38888         LDKReplyChannelRange this_ptr_conv;
38889         this_ptr_conv.inner = untag_ptr(this_ptr);
38890         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38891         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38892         this_ptr_conv.is_owned = false;
38893         LDKCVec_u64Z ret_var = ReplyChannelRange_get_short_channel_ids(&this_ptr_conv);
38894         int64_tArray ret_arr = NULL;
38895         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
38896         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
38897         for (size_t g = 0; g < ret_var.datalen; g++) {
38898                 int64_t ret_conv_6_conv = ret_var.data[g];
38899                 ret_arr_ptr[g] = ret_conv_6_conv;
38900         }
38901         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
38902         FREE(ret_var.data);
38903         return ret_arr;
38904 }
38905
38906 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1short_1channel_1ids(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
38907         LDKReplyChannelRange this_ptr_conv;
38908         this_ptr_conv.inner = untag_ptr(this_ptr);
38909         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
38910         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38911         this_ptr_conv.is_owned = false;
38912         LDKCVec_u64Z val_constr;
38913         val_constr.datalen = (*env)->GetArrayLength(env, val);
38914         if (val_constr.datalen > 0)
38915                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
38916         else
38917                 val_constr.data = NULL;
38918         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
38919         for (size_t g = 0; g < val_constr.datalen; g++) {
38920                 int64_t val_conv_6 = val_vals[g];
38921                 val_constr.data[g] = val_conv_6;
38922         }
38923         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
38924         ReplyChannelRange_set_short_channel_ids(&this_ptr_conv, val_constr);
38925 }
38926
38927 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) {
38928         LDKThirtyTwoBytes chain_hash_arg_ref;
38929         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
38930         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
38931         LDKCVec_u64Z short_channel_ids_arg_constr;
38932         short_channel_ids_arg_constr.datalen = (*env)->GetArrayLength(env, short_channel_ids_arg);
38933         if (short_channel_ids_arg_constr.datalen > 0)
38934                 short_channel_ids_arg_constr.data = MALLOC(short_channel_ids_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
38935         else
38936                 short_channel_ids_arg_constr.data = NULL;
38937         int64_t* short_channel_ids_arg_vals = (*env)->GetLongArrayElements (env, short_channel_ids_arg, NULL);
38938         for (size_t g = 0; g < short_channel_ids_arg_constr.datalen; g++) {
38939                 int64_t short_channel_ids_arg_conv_6 = short_channel_ids_arg_vals[g];
38940                 short_channel_ids_arg_constr.data[g] = short_channel_ids_arg_conv_6;
38941         }
38942         (*env)->ReleaseLongArrayElements(env, short_channel_ids_arg, short_channel_ids_arg_vals, 0);
38943         LDKReplyChannelRange ret_var = ReplyChannelRange_new(chain_hash_arg_ref, first_blocknum_arg, number_of_blocks_arg, sync_complete_arg, short_channel_ids_arg_constr);
38944         int64_t ret_ref = 0;
38945         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38946         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
38947         return ret_ref;
38948 }
38949
38950 static inline uint64_t ReplyChannelRange_clone_ptr(LDKReplyChannelRange *NONNULL_PTR arg) {
38951         LDKReplyChannelRange ret_var = ReplyChannelRange_clone(arg);
38952         int64_t ret_ref = 0;
38953         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38954         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
38955         return ret_ref;
38956 }
38957 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
38958         LDKReplyChannelRange arg_conv;
38959         arg_conv.inner = untag_ptr(arg);
38960         arg_conv.is_owned = ptr_is_owned(arg);
38961         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
38962         arg_conv.is_owned = false;
38963         int64_t ret_conv = ReplyChannelRange_clone_ptr(&arg_conv);
38964         return ret_conv;
38965 }
38966
38967 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1clone(JNIEnv *env, jclass clz, int64_t orig) {
38968         LDKReplyChannelRange orig_conv;
38969         orig_conv.inner = untag_ptr(orig);
38970         orig_conv.is_owned = ptr_is_owned(orig);
38971         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
38972         orig_conv.is_owned = false;
38973         LDKReplyChannelRange ret_var = ReplyChannelRange_clone(&orig_conv);
38974         int64_t ret_ref = 0;
38975         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38976         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
38977         return ret_ref;
38978 }
38979
38980 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
38981         LDKReplyChannelRange a_conv;
38982         a_conv.inner = untag_ptr(a);
38983         a_conv.is_owned = ptr_is_owned(a);
38984         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
38985         a_conv.is_owned = false;
38986         LDKReplyChannelRange b_conv;
38987         b_conv.inner = untag_ptr(b);
38988         b_conv.is_owned = ptr_is_owned(b);
38989         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
38990         b_conv.is_owned = false;
38991         jboolean ret_conv = ReplyChannelRange_eq(&a_conv, &b_conv);
38992         return ret_conv;
38993 }
38994
38995 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
38996         LDKQueryShortChannelIds this_obj_conv;
38997         this_obj_conv.inner = untag_ptr(this_obj);
38998         this_obj_conv.is_owned = ptr_is_owned(this_obj);
38999         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39000         QueryShortChannelIds_free(this_obj_conv);
39001 }
39002
39003 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
39004         LDKQueryShortChannelIds this_ptr_conv;
39005         this_ptr_conv.inner = untag_ptr(this_ptr);
39006         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39007         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39008         this_ptr_conv.is_owned = false;
39009         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
39010         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *QueryShortChannelIds_get_chain_hash(&this_ptr_conv));
39011         return ret_arr;
39012 }
39013
39014 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
39015         LDKQueryShortChannelIds this_ptr_conv;
39016         this_ptr_conv.inner = untag_ptr(this_ptr);
39017         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39018         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39019         this_ptr_conv.is_owned = false;
39020         LDKThirtyTwoBytes val_ref;
39021         CHECK((*env)->GetArrayLength(env, val) == 32);
39022         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
39023         QueryShortChannelIds_set_chain_hash(&this_ptr_conv, val_ref);
39024 }
39025
39026 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1get_1short_1channel_1ids(JNIEnv *env, jclass clz, int64_t this_ptr) {
39027         LDKQueryShortChannelIds this_ptr_conv;
39028         this_ptr_conv.inner = untag_ptr(this_ptr);
39029         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39030         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39031         this_ptr_conv.is_owned = false;
39032         LDKCVec_u64Z ret_var = QueryShortChannelIds_get_short_channel_ids(&this_ptr_conv);
39033         int64_tArray ret_arr = NULL;
39034         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
39035         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
39036         for (size_t g = 0; g < ret_var.datalen; g++) {
39037                 int64_t ret_conv_6_conv = ret_var.data[g];
39038                 ret_arr_ptr[g] = ret_conv_6_conv;
39039         }
39040         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
39041         FREE(ret_var.data);
39042         return ret_arr;
39043 }
39044
39045 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1set_1short_1channel_1ids(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
39046         LDKQueryShortChannelIds this_ptr_conv;
39047         this_ptr_conv.inner = untag_ptr(this_ptr);
39048         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39049         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39050         this_ptr_conv.is_owned = false;
39051         LDKCVec_u64Z val_constr;
39052         val_constr.datalen = (*env)->GetArrayLength(env, val);
39053         if (val_constr.datalen > 0)
39054                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
39055         else
39056                 val_constr.data = NULL;
39057         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
39058         for (size_t g = 0; g < val_constr.datalen; g++) {
39059                 int64_t val_conv_6 = val_vals[g];
39060                 val_constr.data[g] = val_conv_6;
39061         }
39062         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
39063         QueryShortChannelIds_set_short_channel_ids(&this_ptr_conv, val_constr);
39064 }
39065
39066 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) {
39067         LDKThirtyTwoBytes chain_hash_arg_ref;
39068         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
39069         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
39070         LDKCVec_u64Z short_channel_ids_arg_constr;
39071         short_channel_ids_arg_constr.datalen = (*env)->GetArrayLength(env, short_channel_ids_arg);
39072         if (short_channel_ids_arg_constr.datalen > 0)
39073                 short_channel_ids_arg_constr.data = MALLOC(short_channel_ids_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
39074         else
39075                 short_channel_ids_arg_constr.data = NULL;
39076         int64_t* short_channel_ids_arg_vals = (*env)->GetLongArrayElements (env, short_channel_ids_arg, NULL);
39077         for (size_t g = 0; g < short_channel_ids_arg_constr.datalen; g++) {
39078                 int64_t short_channel_ids_arg_conv_6 = short_channel_ids_arg_vals[g];
39079                 short_channel_ids_arg_constr.data[g] = short_channel_ids_arg_conv_6;
39080         }
39081         (*env)->ReleaseLongArrayElements(env, short_channel_ids_arg, short_channel_ids_arg_vals, 0);
39082         LDKQueryShortChannelIds ret_var = QueryShortChannelIds_new(chain_hash_arg_ref, short_channel_ids_arg_constr);
39083         int64_t ret_ref = 0;
39084         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39085         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39086         return ret_ref;
39087 }
39088
39089 static inline uint64_t QueryShortChannelIds_clone_ptr(LDKQueryShortChannelIds *NONNULL_PTR arg) {
39090         LDKQueryShortChannelIds ret_var = QueryShortChannelIds_clone(arg);
39091         int64_t ret_ref = 0;
39092         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39093         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39094         return ret_ref;
39095 }
39096 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
39097         LDKQueryShortChannelIds arg_conv;
39098         arg_conv.inner = untag_ptr(arg);
39099         arg_conv.is_owned = ptr_is_owned(arg);
39100         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
39101         arg_conv.is_owned = false;
39102         int64_t ret_conv = QueryShortChannelIds_clone_ptr(&arg_conv);
39103         return ret_conv;
39104 }
39105
39106 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1clone(JNIEnv *env, jclass clz, int64_t orig) {
39107         LDKQueryShortChannelIds orig_conv;
39108         orig_conv.inner = untag_ptr(orig);
39109         orig_conv.is_owned = ptr_is_owned(orig);
39110         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
39111         orig_conv.is_owned = false;
39112         LDKQueryShortChannelIds ret_var = QueryShortChannelIds_clone(&orig_conv);
39113         int64_t ret_ref = 0;
39114         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39115         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39116         return ret_ref;
39117 }
39118
39119 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
39120         LDKQueryShortChannelIds a_conv;
39121         a_conv.inner = untag_ptr(a);
39122         a_conv.is_owned = ptr_is_owned(a);
39123         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
39124         a_conv.is_owned = false;
39125         LDKQueryShortChannelIds b_conv;
39126         b_conv.inner = untag_ptr(b);
39127         b_conv.is_owned = ptr_is_owned(b);
39128         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
39129         b_conv.is_owned = false;
39130         jboolean ret_conv = QueryShortChannelIds_eq(&a_conv, &b_conv);
39131         return ret_conv;
39132 }
39133
39134 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
39135         LDKReplyShortChannelIdsEnd this_obj_conv;
39136         this_obj_conv.inner = untag_ptr(this_obj);
39137         this_obj_conv.is_owned = ptr_is_owned(this_obj);
39138         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39139         ReplyShortChannelIdsEnd_free(this_obj_conv);
39140 }
39141
39142 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
39143         LDKReplyShortChannelIdsEnd this_ptr_conv;
39144         this_ptr_conv.inner = untag_ptr(this_ptr);
39145         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39146         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39147         this_ptr_conv.is_owned = false;
39148         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
39149         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ReplyShortChannelIdsEnd_get_chain_hash(&this_ptr_conv));
39150         return ret_arr;
39151 }
39152
39153 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
39154         LDKReplyShortChannelIdsEnd this_ptr_conv;
39155         this_ptr_conv.inner = untag_ptr(this_ptr);
39156         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39157         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39158         this_ptr_conv.is_owned = false;
39159         LDKThirtyTwoBytes val_ref;
39160         CHECK((*env)->GetArrayLength(env, val) == 32);
39161         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
39162         ReplyShortChannelIdsEnd_set_chain_hash(&this_ptr_conv, val_ref);
39163 }
39164
39165 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1get_1full_1information(JNIEnv *env, jclass clz, int64_t this_ptr) {
39166         LDKReplyShortChannelIdsEnd this_ptr_conv;
39167         this_ptr_conv.inner = untag_ptr(this_ptr);
39168         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39169         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39170         this_ptr_conv.is_owned = false;
39171         jboolean ret_conv = ReplyShortChannelIdsEnd_get_full_information(&this_ptr_conv);
39172         return ret_conv;
39173 }
39174
39175 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1set_1full_1information(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
39176         LDKReplyShortChannelIdsEnd this_ptr_conv;
39177         this_ptr_conv.inner = untag_ptr(this_ptr);
39178         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39179         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39180         this_ptr_conv.is_owned = false;
39181         ReplyShortChannelIdsEnd_set_full_information(&this_ptr_conv, val);
39182 }
39183
39184 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1new(JNIEnv *env, jclass clz, int8_tArray chain_hash_arg, jboolean full_information_arg) {
39185         LDKThirtyTwoBytes chain_hash_arg_ref;
39186         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
39187         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
39188         LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_new(chain_hash_arg_ref, full_information_arg);
39189         int64_t ret_ref = 0;
39190         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39191         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39192         return ret_ref;
39193 }
39194
39195 static inline uint64_t ReplyShortChannelIdsEnd_clone_ptr(LDKReplyShortChannelIdsEnd *NONNULL_PTR arg) {
39196         LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_clone(arg);
39197         int64_t ret_ref = 0;
39198         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39199         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39200         return ret_ref;
39201 }
39202 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
39203         LDKReplyShortChannelIdsEnd arg_conv;
39204         arg_conv.inner = untag_ptr(arg);
39205         arg_conv.is_owned = ptr_is_owned(arg);
39206         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
39207         arg_conv.is_owned = false;
39208         int64_t ret_conv = ReplyShortChannelIdsEnd_clone_ptr(&arg_conv);
39209         return ret_conv;
39210 }
39211
39212 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1clone(JNIEnv *env, jclass clz, int64_t orig) {
39213         LDKReplyShortChannelIdsEnd orig_conv;
39214         orig_conv.inner = untag_ptr(orig);
39215         orig_conv.is_owned = ptr_is_owned(orig);
39216         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
39217         orig_conv.is_owned = false;
39218         LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_clone(&orig_conv);
39219         int64_t ret_ref = 0;
39220         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39221         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39222         return ret_ref;
39223 }
39224
39225 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
39226         LDKReplyShortChannelIdsEnd a_conv;
39227         a_conv.inner = untag_ptr(a);
39228         a_conv.is_owned = ptr_is_owned(a);
39229         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
39230         a_conv.is_owned = false;
39231         LDKReplyShortChannelIdsEnd b_conv;
39232         b_conv.inner = untag_ptr(b);
39233         b_conv.is_owned = ptr_is_owned(b);
39234         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
39235         b_conv.is_owned = false;
39236         jboolean ret_conv = ReplyShortChannelIdsEnd_eq(&a_conv, &b_conv);
39237         return ret_conv;
39238 }
39239
39240 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
39241         LDKGossipTimestampFilter this_obj_conv;
39242         this_obj_conv.inner = untag_ptr(this_obj);
39243         this_obj_conv.is_owned = ptr_is_owned(this_obj);
39244         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39245         GossipTimestampFilter_free(this_obj_conv);
39246 }
39247
39248 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
39249         LDKGossipTimestampFilter this_ptr_conv;
39250         this_ptr_conv.inner = untag_ptr(this_ptr);
39251         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39252         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39253         this_ptr_conv.is_owned = false;
39254         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
39255         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *GossipTimestampFilter_get_chain_hash(&this_ptr_conv));
39256         return ret_arr;
39257 }
39258
39259 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
39260         LDKGossipTimestampFilter this_ptr_conv;
39261         this_ptr_conv.inner = untag_ptr(this_ptr);
39262         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39263         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39264         this_ptr_conv.is_owned = false;
39265         LDKThirtyTwoBytes val_ref;
39266         CHECK((*env)->GetArrayLength(env, val) == 32);
39267         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
39268         GossipTimestampFilter_set_chain_hash(&this_ptr_conv, val_ref);
39269 }
39270
39271 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1get_1first_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr) {
39272         LDKGossipTimestampFilter this_ptr_conv;
39273         this_ptr_conv.inner = untag_ptr(this_ptr);
39274         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39275         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39276         this_ptr_conv.is_owned = false;
39277         int32_t ret_conv = GossipTimestampFilter_get_first_timestamp(&this_ptr_conv);
39278         return ret_conv;
39279 }
39280
39281 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1set_1first_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
39282         LDKGossipTimestampFilter this_ptr_conv;
39283         this_ptr_conv.inner = untag_ptr(this_ptr);
39284         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39285         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39286         this_ptr_conv.is_owned = false;
39287         GossipTimestampFilter_set_first_timestamp(&this_ptr_conv, val);
39288 }
39289
39290 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1get_1timestamp_1range(JNIEnv *env, jclass clz, int64_t this_ptr) {
39291         LDKGossipTimestampFilter this_ptr_conv;
39292         this_ptr_conv.inner = untag_ptr(this_ptr);
39293         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39294         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39295         this_ptr_conv.is_owned = false;
39296         int32_t ret_conv = GossipTimestampFilter_get_timestamp_range(&this_ptr_conv);
39297         return ret_conv;
39298 }
39299
39300 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1set_1timestamp_1range(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
39301         LDKGossipTimestampFilter this_ptr_conv;
39302         this_ptr_conv.inner = untag_ptr(this_ptr);
39303         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39304         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39305         this_ptr_conv.is_owned = false;
39306         GossipTimestampFilter_set_timestamp_range(&this_ptr_conv, val);
39307 }
39308
39309 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) {
39310         LDKThirtyTwoBytes chain_hash_arg_ref;
39311         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
39312         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
39313         LDKGossipTimestampFilter ret_var = GossipTimestampFilter_new(chain_hash_arg_ref, first_timestamp_arg, timestamp_range_arg);
39314         int64_t ret_ref = 0;
39315         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39316         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39317         return ret_ref;
39318 }
39319
39320 static inline uint64_t GossipTimestampFilter_clone_ptr(LDKGossipTimestampFilter *NONNULL_PTR arg) {
39321         LDKGossipTimestampFilter ret_var = GossipTimestampFilter_clone(arg);
39322         int64_t ret_ref = 0;
39323         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39324         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39325         return ret_ref;
39326 }
39327 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
39328         LDKGossipTimestampFilter arg_conv;
39329         arg_conv.inner = untag_ptr(arg);
39330         arg_conv.is_owned = ptr_is_owned(arg);
39331         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
39332         arg_conv.is_owned = false;
39333         int64_t ret_conv = GossipTimestampFilter_clone_ptr(&arg_conv);
39334         return ret_conv;
39335 }
39336
39337 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1clone(JNIEnv *env, jclass clz, int64_t orig) {
39338         LDKGossipTimestampFilter orig_conv;
39339         orig_conv.inner = untag_ptr(orig);
39340         orig_conv.is_owned = ptr_is_owned(orig);
39341         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
39342         orig_conv.is_owned = false;
39343         LDKGossipTimestampFilter ret_var = GossipTimestampFilter_clone(&orig_conv);
39344         int64_t ret_ref = 0;
39345         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39346         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39347         return ret_ref;
39348 }
39349
39350 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
39351         LDKGossipTimestampFilter a_conv;
39352         a_conv.inner = untag_ptr(a);
39353         a_conv.is_owned = ptr_is_owned(a);
39354         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
39355         a_conv.is_owned = false;
39356         LDKGossipTimestampFilter b_conv;
39357         b_conv.inner = untag_ptr(b);
39358         b_conv.is_owned = ptr_is_owned(b);
39359         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
39360         b_conv.is_owned = false;
39361         jboolean ret_conv = GossipTimestampFilter_eq(&a_conv, &b_conv);
39362         return ret_conv;
39363 }
39364
39365 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorAction_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
39366         if (!ptr_is_owned(this_ptr)) return;
39367         void* this_ptr_ptr = untag_ptr(this_ptr);
39368         CHECK_ACCESS(this_ptr_ptr);
39369         LDKErrorAction this_ptr_conv = *(LDKErrorAction*)(this_ptr_ptr);
39370         FREE(untag_ptr(this_ptr));
39371         ErrorAction_free(this_ptr_conv);
39372 }
39373
39374 static inline uint64_t ErrorAction_clone_ptr(LDKErrorAction *NONNULL_PTR arg) {
39375         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
39376         *ret_copy = ErrorAction_clone(arg);
39377         int64_t ret_ref = tag_ptr(ret_copy, true);
39378         return ret_ref;
39379 }
39380 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
39381         LDKErrorAction* arg_conv = (LDKErrorAction*)untag_ptr(arg);
39382         int64_t ret_conv = ErrorAction_clone_ptr(arg_conv);
39383         return ret_conv;
39384 }
39385
39386 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
39387         LDKErrorAction* orig_conv = (LDKErrorAction*)untag_ptr(orig);
39388         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
39389         *ret_copy = ErrorAction_clone(orig_conv);
39390         int64_t ret_ref = tag_ptr(ret_copy, true);
39391         return ret_ref;
39392 }
39393
39394 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1disconnect_1peer(JNIEnv *env, jclass clz, int64_t msg) {
39395         LDKErrorMessage msg_conv;
39396         msg_conv.inner = untag_ptr(msg);
39397         msg_conv.is_owned = ptr_is_owned(msg);
39398         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
39399         msg_conv = ErrorMessage_clone(&msg_conv);
39400         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
39401         *ret_copy = ErrorAction_disconnect_peer(msg_conv);
39402         int64_t ret_ref = tag_ptr(ret_copy, true);
39403         return ret_ref;
39404 }
39405
39406 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1ignore_1error(JNIEnv *env, jclass clz) {
39407         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
39408         *ret_copy = ErrorAction_ignore_error();
39409         int64_t ret_ref = tag_ptr(ret_copy, true);
39410         return ret_ref;
39411 }
39412
39413 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1ignore_1and_1log(JNIEnv *env, jclass clz, jclass a) {
39414         LDKLevel a_conv = LDKLevel_from_java(env, a);
39415         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
39416         *ret_copy = ErrorAction_ignore_and_log(a_conv);
39417         int64_t ret_ref = tag_ptr(ret_copy, true);
39418         return ret_ref;
39419 }
39420
39421 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1ignore_1duplicate_1gossip(JNIEnv *env, jclass clz) {
39422         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
39423         *ret_copy = ErrorAction_ignore_duplicate_gossip();
39424         int64_t ret_ref = tag_ptr(ret_copy, true);
39425         return ret_ref;
39426 }
39427
39428 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1send_1error_1message(JNIEnv *env, jclass clz, int64_t msg) {
39429         LDKErrorMessage msg_conv;
39430         msg_conv.inner = untag_ptr(msg);
39431         msg_conv.is_owned = ptr_is_owned(msg);
39432         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
39433         msg_conv = ErrorMessage_clone(&msg_conv);
39434         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
39435         *ret_copy = ErrorAction_send_error_message(msg_conv);
39436         int64_t ret_ref = tag_ptr(ret_copy, true);
39437         return ret_ref;
39438 }
39439
39440 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1send_1warning_1message(JNIEnv *env, jclass clz, int64_t msg, jclass log_level) {
39441         LDKWarningMessage msg_conv;
39442         msg_conv.inner = untag_ptr(msg);
39443         msg_conv.is_owned = ptr_is_owned(msg);
39444         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
39445         msg_conv = WarningMessage_clone(&msg_conv);
39446         LDKLevel log_level_conv = LDKLevel_from_java(env, log_level);
39447         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
39448         *ret_copy = ErrorAction_send_warning_message(msg_conv, log_level_conv);
39449         int64_t ret_ref = tag_ptr(ret_copy, true);
39450         return ret_ref;
39451 }
39452
39453 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LightningError_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
39454         LDKLightningError this_obj_conv;
39455         this_obj_conv.inner = untag_ptr(this_obj);
39456         this_obj_conv.is_owned = ptr_is_owned(this_obj);
39457         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39458         LightningError_free(this_obj_conv);
39459 }
39460
39461 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_LightningError_1get_1err(JNIEnv *env, jclass clz, int64_t this_ptr) {
39462         LDKLightningError this_ptr_conv;
39463         this_ptr_conv.inner = untag_ptr(this_ptr);
39464         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39465         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39466         this_ptr_conv.is_owned = false;
39467         LDKStr ret_str = LightningError_get_err(&this_ptr_conv);
39468         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
39469         Str_free(ret_str);
39470         return ret_conv;
39471 }
39472
39473 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LightningError_1set_1err(JNIEnv *env, jclass clz, int64_t this_ptr, jstring val) {
39474         LDKLightningError this_ptr_conv;
39475         this_ptr_conv.inner = untag_ptr(this_ptr);
39476         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39477         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39478         this_ptr_conv.is_owned = false;
39479         LDKStr val_conv = java_to_owned_str(env, val);
39480         LightningError_set_err(&this_ptr_conv, val_conv);
39481 }
39482
39483 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LightningError_1get_1action(JNIEnv *env, jclass clz, int64_t this_ptr) {
39484         LDKLightningError this_ptr_conv;
39485         this_ptr_conv.inner = untag_ptr(this_ptr);
39486         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39487         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39488         this_ptr_conv.is_owned = false;
39489         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
39490         *ret_copy = LightningError_get_action(&this_ptr_conv);
39491         int64_t ret_ref = tag_ptr(ret_copy, true);
39492         return ret_ref;
39493 }
39494
39495 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LightningError_1set_1action(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
39496         LDKLightningError this_ptr_conv;
39497         this_ptr_conv.inner = untag_ptr(this_ptr);
39498         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39499         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39500         this_ptr_conv.is_owned = false;
39501         void* val_ptr = untag_ptr(val);
39502         CHECK_ACCESS(val_ptr);
39503         LDKErrorAction val_conv = *(LDKErrorAction*)(val_ptr);
39504         val_conv = ErrorAction_clone((LDKErrorAction*)untag_ptr(val));
39505         LightningError_set_action(&this_ptr_conv, val_conv);
39506 }
39507
39508 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LightningError_1new(JNIEnv *env, jclass clz, jstring err_arg, int64_t action_arg) {
39509         LDKStr err_arg_conv = java_to_owned_str(env, err_arg);
39510         void* action_arg_ptr = untag_ptr(action_arg);
39511         CHECK_ACCESS(action_arg_ptr);
39512         LDKErrorAction action_arg_conv = *(LDKErrorAction*)(action_arg_ptr);
39513         action_arg_conv = ErrorAction_clone((LDKErrorAction*)untag_ptr(action_arg));
39514         LDKLightningError ret_var = LightningError_new(err_arg_conv, action_arg_conv);
39515         int64_t ret_ref = 0;
39516         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39517         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39518         return ret_ref;
39519 }
39520
39521 static inline uint64_t LightningError_clone_ptr(LDKLightningError *NONNULL_PTR arg) {
39522         LDKLightningError ret_var = LightningError_clone(arg);
39523         int64_t ret_ref = 0;
39524         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39525         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39526         return ret_ref;
39527 }
39528 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LightningError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
39529         LDKLightningError arg_conv;
39530         arg_conv.inner = untag_ptr(arg);
39531         arg_conv.is_owned = ptr_is_owned(arg);
39532         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
39533         arg_conv.is_owned = false;
39534         int64_t ret_conv = LightningError_clone_ptr(&arg_conv);
39535         return ret_conv;
39536 }
39537
39538 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LightningError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
39539         LDKLightningError orig_conv;
39540         orig_conv.inner = untag_ptr(orig);
39541         orig_conv.is_owned = ptr_is_owned(orig);
39542         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
39543         orig_conv.is_owned = false;
39544         LDKLightningError ret_var = LightningError_clone(&orig_conv);
39545         int64_t ret_ref = 0;
39546         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39547         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39548         return ret_ref;
39549 }
39550
39551 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
39552         LDKCommitmentUpdate this_obj_conv;
39553         this_obj_conv.inner = untag_ptr(this_obj);
39554         this_obj_conv.is_owned = ptr_is_owned(this_obj);
39555         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39556         CommitmentUpdate_free(this_obj_conv);
39557 }
39558
39559 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1update_1add_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
39560         LDKCommitmentUpdate this_ptr_conv;
39561         this_ptr_conv.inner = untag_ptr(this_ptr);
39562         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39563         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39564         this_ptr_conv.is_owned = false;
39565         LDKCVec_UpdateAddHTLCZ ret_var = CommitmentUpdate_get_update_add_htlcs(&this_ptr_conv);
39566         int64_tArray ret_arr = NULL;
39567         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
39568         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
39569         for (size_t p = 0; p < ret_var.datalen; p++) {
39570                 LDKUpdateAddHTLC ret_conv_15_var = ret_var.data[p];
39571                 int64_t ret_conv_15_ref = 0;
39572                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_15_var);
39573                 ret_conv_15_ref = tag_ptr(ret_conv_15_var.inner, ret_conv_15_var.is_owned);
39574                 ret_arr_ptr[p] = ret_conv_15_ref;
39575         }
39576         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
39577         FREE(ret_var.data);
39578         return ret_arr;
39579 }
39580
39581 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1add_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
39582         LDKCommitmentUpdate this_ptr_conv;
39583         this_ptr_conv.inner = untag_ptr(this_ptr);
39584         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39585         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39586         this_ptr_conv.is_owned = false;
39587         LDKCVec_UpdateAddHTLCZ val_constr;
39588         val_constr.datalen = (*env)->GetArrayLength(env, val);
39589         if (val_constr.datalen > 0)
39590                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
39591         else
39592                 val_constr.data = NULL;
39593         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
39594         for (size_t p = 0; p < val_constr.datalen; p++) {
39595                 int64_t val_conv_15 = val_vals[p];
39596                 LDKUpdateAddHTLC val_conv_15_conv;
39597                 val_conv_15_conv.inner = untag_ptr(val_conv_15);
39598                 val_conv_15_conv.is_owned = ptr_is_owned(val_conv_15);
39599                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_15_conv);
39600                 val_conv_15_conv = UpdateAddHTLC_clone(&val_conv_15_conv);
39601                 val_constr.data[p] = val_conv_15_conv;
39602         }
39603         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
39604         CommitmentUpdate_set_update_add_htlcs(&this_ptr_conv, val_constr);
39605 }
39606
39607 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1update_1fulfill_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
39608         LDKCommitmentUpdate this_ptr_conv;
39609         this_ptr_conv.inner = untag_ptr(this_ptr);
39610         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39611         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39612         this_ptr_conv.is_owned = false;
39613         LDKCVec_UpdateFulfillHTLCZ ret_var = CommitmentUpdate_get_update_fulfill_htlcs(&this_ptr_conv);
39614         int64_tArray ret_arr = NULL;
39615         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
39616         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
39617         for (size_t t = 0; t < ret_var.datalen; t++) {
39618                 LDKUpdateFulfillHTLC ret_conv_19_var = ret_var.data[t];
39619                 int64_t ret_conv_19_ref = 0;
39620                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_19_var);
39621                 ret_conv_19_ref = tag_ptr(ret_conv_19_var.inner, ret_conv_19_var.is_owned);
39622                 ret_arr_ptr[t] = ret_conv_19_ref;
39623         }
39624         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
39625         FREE(ret_var.data);
39626         return ret_arr;
39627 }
39628
39629 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1fulfill_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
39630         LDKCommitmentUpdate this_ptr_conv;
39631         this_ptr_conv.inner = untag_ptr(this_ptr);
39632         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39633         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39634         this_ptr_conv.is_owned = false;
39635         LDKCVec_UpdateFulfillHTLCZ val_constr;
39636         val_constr.datalen = (*env)->GetArrayLength(env, val);
39637         if (val_constr.datalen > 0)
39638                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
39639         else
39640                 val_constr.data = NULL;
39641         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
39642         for (size_t t = 0; t < val_constr.datalen; t++) {
39643                 int64_t val_conv_19 = val_vals[t];
39644                 LDKUpdateFulfillHTLC val_conv_19_conv;
39645                 val_conv_19_conv.inner = untag_ptr(val_conv_19);
39646                 val_conv_19_conv.is_owned = ptr_is_owned(val_conv_19);
39647                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_19_conv);
39648                 val_conv_19_conv = UpdateFulfillHTLC_clone(&val_conv_19_conv);
39649                 val_constr.data[t] = val_conv_19_conv;
39650         }
39651         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
39652         CommitmentUpdate_set_update_fulfill_htlcs(&this_ptr_conv, val_constr);
39653 }
39654
39655 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1update_1fail_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
39656         LDKCommitmentUpdate this_ptr_conv;
39657         this_ptr_conv.inner = untag_ptr(this_ptr);
39658         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39659         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39660         this_ptr_conv.is_owned = false;
39661         LDKCVec_UpdateFailHTLCZ ret_var = CommitmentUpdate_get_update_fail_htlcs(&this_ptr_conv);
39662         int64_tArray ret_arr = NULL;
39663         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
39664         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
39665         for (size_t q = 0; q < ret_var.datalen; q++) {
39666                 LDKUpdateFailHTLC ret_conv_16_var = ret_var.data[q];
39667                 int64_t ret_conv_16_ref = 0;
39668                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
39669                 ret_conv_16_ref = tag_ptr(ret_conv_16_var.inner, ret_conv_16_var.is_owned);
39670                 ret_arr_ptr[q] = ret_conv_16_ref;
39671         }
39672         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
39673         FREE(ret_var.data);
39674         return ret_arr;
39675 }
39676
39677 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1fail_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
39678         LDKCommitmentUpdate this_ptr_conv;
39679         this_ptr_conv.inner = untag_ptr(this_ptr);
39680         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39681         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39682         this_ptr_conv.is_owned = false;
39683         LDKCVec_UpdateFailHTLCZ val_constr;
39684         val_constr.datalen = (*env)->GetArrayLength(env, val);
39685         if (val_constr.datalen > 0)
39686                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
39687         else
39688                 val_constr.data = NULL;
39689         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
39690         for (size_t q = 0; q < val_constr.datalen; q++) {
39691                 int64_t val_conv_16 = val_vals[q];
39692                 LDKUpdateFailHTLC val_conv_16_conv;
39693                 val_conv_16_conv.inner = untag_ptr(val_conv_16);
39694                 val_conv_16_conv.is_owned = ptr_is_owned(val_conv_16);
39695                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_16_conv);
39696                 val_conv_16_conv = UpdateFailHTLC_clone(&val_conv_16_conv);
39697                 val_constr.data[q] = val_conv_16_conv;
39698         }
39699         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
39700         CommitmentUpdate_set_update_fail_htlcs(&this_ptr_conv, val_constr);
39701 }
39702
39703 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1update_1fail_1malformed_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
39704         LDKCommitmentUpdate this_ptr_conv;
39705         this_ptr_conv.inner = untag_ptr(this_ptr);
39706         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39707         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39708         this_ptr_conv.is_owned = false;
39709         LDKCVec_UpdateFailMalformedHTLCZ ret_var = CommitmentUpdate_get_update_fail_malformed_htlcs(&this_ptr_conv);
39710         int64_tArray ret_arr = NULL;
39711         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
39712         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
39713         for (size_t z = 0; z < ret_var.datalen; z++) {
39714                 LDKUpdateFailMalformedHTLC ret_conv_25_var = ret_var.data[z];
39715                 int64_t ret_conv_25_ref = 0;
39716                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_25_var);
39717                 ret_conv_25_ref = tag_ptr(ret_conv_25_var.inner, ret_conv_25_var.is_owned);
39718                 ret_arr_ptr[z] = ret_conv_25_ref;
39719         }
39720         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
39721         FREE(ret_var.data);
39722         return ret_arr;
39723 }
39724
39725 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) {
39726         LDKCommitmentUpdate this_ptr_conv;
39727         this_ptr_conv.inner = untag_ptr(this_ptr);
39728         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39729         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39730         this_ptr_conv.is_owned = false;
39731         LDKCVec_UpdateFailMalformedHTLCZ val_constr;
39732         val_constr.datalen = (*env)->GetArrayLength(env, val);
39733         if (val_constr.datalen > 0)
39734                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
39735         else
39736                 val_constr.data = NULL;
39737         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
39738         for (size_t z = 0; z < val_constr.datalen; z++) {
39739                 int64_t val_conv_25 = val_vals[z];
39740                 LDKUpdateFailMalformedHTLC val_conv_25_conv;
39741                 val_conv_25_conv.inner = untag_ptr(val_conv_25);
39742                 val_conv_25_conv.is_owned = ptr_is_owned(val_conv_25);
39743                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_25_conv);
39744                 val_conv_25_conv = UpdateFailMalformedHTLC_clone(&val_conv_25_conv);
39745                 val_constr.data[z] = val_conv_25_conv;
39746         }
39747         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
39748         CommitmentUpdate_set_update_fail_malformed_htlcs(&this_ptr_conv, val_constr);
39749 }
39750
39751 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1update_1fee(JNIEnv *env, jclass clz, int64_t this_ptr) {
39752         LDKCommitmentUpdate this_ptr_conv;
39753         this_ptr_conv.inner = untag_ptr(this_ptr);
39754         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39755         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39756         this_ptr_conv.is_owned = false;
39757         LDKUpdateFee ret_var = CommitmentUpdate_get_update_fee(&this_ptr_conv);
39758         int64_t ret_ref = 0;
39759         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39760         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39761         return ret_ref;
39762 }
39763
39764 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1fee(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
39765         LDKCommitmentUpdate this_ptr_conv;
39766         this_ptr_conv.inner = untag_ptr(this_ptr);
39767         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39768         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39769         this_ptr_conv.is_owned = false;
39770         LDKUpdateFee val_conv;
39771         val_conv.inner = untag_ptr(val);
39772         val_conv.is_owned = ptr_is_owned(val);
39773         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
39774         val_conv = UpdateFee_clone(&val_conv);
39775         CommitmentUpdate_set_update_fee(&this_ptr_conv, val_conv);
39776 }
39777
39778 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1commitment_1signed(JNIEnv *env, jclass clz, int64_t this_ptr) {
39779         LDKCommitmentUpdate this_ptr_conv;
39780         this_ptr_conv.inner = untag_ptr(this_ptr);
39781         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39782         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39783         this_ptr_conv.is_owned = false;
39784         LDKCommitmentSigned ret_var = CommitmentUpdate_get_commitment_signed(&this_ptr_conv);
39785         int64_t ret_ref = 0;
39786         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39787         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39788         return ret_ref;
39789 }
39790
39791 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1commitment_1signed(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
39792         LDKCommitmentUpdate this_ptr_conv;
39793         this_ptr_conv.inner = untag_ptr(this_ptr);
39794         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
39795         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39796         this_ptr_conv.is_owned = false;
39797         LDKCommitmentSigned val_conv;
39798         val_conv.inner = untag_ptr(val);
39799         val_conv.is_owned = ptr_is_owned(val);
39800         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
39801         val_conv = CommitmentSigned_clone(&val_conv);
39802         CommitmentUpdate_set_commitment_signed(&this_ptr_conv, val_conv);
39803 }
39804
39805 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) {
39806         LDKCVec_UpdateAddHTLCZ update_add_htlcs_arg_constr;
39807         update_add_htlcs_arg_constr.datalen = (*env)->GetArrayLength(env, update_add_htlcs_arg);
39808         if (update_add_htlcs_arg_constr.datalen > 0)
39809                 update_add_htlcs_arg_constr.data = MALLOC(update_add_htlcs_arg_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
39810         else
39811                 update_add_htlcs_arg_constr.data = NULL;
39812         int64_t* update_add_htlcs_arg_vals = (*env)->GetLongArrayElements (env, update_add_htlcs_arg, NULL);
39813         for (size_t p = 0; p < update_add_htlcs_arg_constr.datalen; p++) {
39814                 int64_t update_add_htlcs_arg_conv_15 = update_add_htlcs_arg_vals[p];
39815                 LDKUpdateAddHTLC update_add_htlcs_arg_conv_15_conv;
39816                 update_add_htlcs_arg_conv_15_conv.inner = untag_ptr(update_add_htlcs_arg_conv_15);
39817                 update_add_htlcs_arg_conv_15_conv.is_owned = ptr_is_owned(update_add_htlcs_arg_conv_15);
39818                 CHECK_INNER_FIELD_ACCESS_OR_NULL(update_add_htlcs_arg_conv_15_conv);
39819                 update_add_htlcs_arg_conv_15_conv = UpdateAddHTLC_clone(&update_add_htlcs_arg_conv_15_conv);
39820                 update_add_htlcs_arg_constr.data[p] = update_add_htlcs_arg_conv_15_conv;
39821         }
39822         (*env)->ReleaseLongArrayElements(env, update_add_htlcs_arg, update_add_htlcs_arg_vals, 0);
39823         LDKCVec_UpdateFulfillHTLCZ update_fulfill_htlcs_arg_constr;
39824         update_fulfill_htlcs_arg_constr.datalen = (*env)->GetArrayLength(env, update_fulfill_htlcs_arg);
39825         if (update_fulfill_htlcs_arg_constr.datalen > 0)
39826                 update_fulfill_htlcs_arg_constr.data = MALLOC(update_fulfill_htlcs_arg_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
39827         else
39828                 update_fulfill_htlcs_arg_constr.data = NULL;
39829         int64_t* update_fulfill_htlcs_arg_vals = (*env)->GetLongArrayElements (env, update_fulfill_htlcs_arg, NULL);
39830         for (size_t t = 0; t < update_fulfill_htlcs_arg_constr.datalen; t++) {
39831                 int64_t update_fulfill_htlcs_arg_conv_19 = update_fulfill_htlcs_arg_vals[t];
39832                 LDKUpdateFulfillHTLC update_fulfill_htlcs_arg_conv_19_conv;
39833                 update_fulfill_htlcs_arg_conv_19_conv.inner = untag_ptr(update_fulfill_htlcs_arg_conv_19);
39834                 update_fulfill_htlcs_arg_conv_19_conv.is_owned = ptr_is_owned(update_fulfill_htlcs_arg_conv_19);
39835                 CHECK_INNER_FIELD_ACCESS_OR_NULL(update_fulfill_htlcs_arg_conv_19_conv);
39836                 update_fulfill_htlcs_arg_conv_19_conv = UpdateFulfillHTLC_clone(&update_fulfill_htlcs_arg_conv_19_conv);
39837                 update_fulfill_htlcs_arg_constr.data[t] = update_fulfill_htlcs_arg_conv_19_conv;
39838         }
39839         (*env)->ReleaseLongArrayElements(env, update_fulfill_htlcs_arg, update_fulfill_htlcs_arg_vals, 0);
39840         LDKCVec_UpdateFailHTLCZ update_fail_htlcs_arg_constr;
39841         update_fail_htlcs_arg_constr.datalen = (*env)->GetArrayLength(env, update_fail_htlcs_arg);
39842         if (update_fail_htlcs_arg_constr.datalen > 0)
39843                 update_fail_htlcs_arg_constr.data = MALLOC(update_fail_htlcs_arg_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
39844         else
39845                 update_fail_htlcs_arg_constr.data = NULL;
39846         int64_t* update_fail_htlcs_arg_vals = (*env)->GetLongArrayElements (env, update_fail_htlcs_arg, NULL);
39847         for (size_t q = 0; q < update_fail_htlcs_arg_constr.datalen; q++) {
39848                 int64_t update_fail_htlcs_arg_conv_16 = update_fail_htlcs_arg_vals[q];
39849                 LDKUpdateFailHTLC update_fail_htlcs_arg_conv_16_conv;
39850                 update_fail_htlcs_arg_conv_16_conv.inner = untag_ptr(update_fail_htlcs_arg_conv_16);
39851                 update_fail_htlcs_arg_conv_16_conv.is_owned = ptr_is_owned(update_fail_htlcs_arg_conv_16);
39852                 CHECK_INNER_FIELD_ACCESS_OR_NULL(update_fail_htlcs_arg_conv_16_conv);
39853                 update_fail_htlcs_arg_conv_16_conv = UpdateFailHTLC_clone(&update_fail_htlcs_arg_conv_16_conv);
39854                 update_fail_htlcs_arg_constr.data[q] = update_fail_htlcs_arg_conv_16_conv;
39855         }
39856         (*env)->ReleaseLongArrayElements(env, update_fail_htlcs_arg, update_fail_htlcs_arg_vals, 0);
39857         LDKCVec_UpdateFailMalformedHTLCZ update_fail_malformed_htlcs_arg_constr;
39858         update_fail_malformed_htlcs_arg_constr.datalen = (*env)->GetArrayLength(env, update_fail_malformed_htlcs_arg);
39859         if (update_fail_malformed_htlcs_arg_constr.datalen > 0)
39860                 update_fail_malformed_htlcs_arg_constr.data = MALLOC(update_fail_malformed_htlcs_arg_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
39861         else
39862                 update_fail_malformed_htlcs_arg_constr.data = NULL;
39863         int64_t* update_fail_malformed_htlcs_arg_vals = (*env)->GetLongArrayElements (env, update_fail_malformed_htlcs_arg, NULL);
39864         for (size_t z = 0; z < update_fail_malformed_htlcs_arg_constr.datalen; z++) {
39865                 int64_t update_fail_malformed_htlcs_arg_conv_25 = update_fail_malformed_htlcs_arg_vals[z];
39866                 LDKUpdateFailMalformedHTLC update_fail_malformed_htlcs_arg_conv_25_conv;
39867                 update_fail_malformed_htlcs_arg_conv_25_conv.inner = untag_ptr(update_fail_malformed_htlcs_arg_conv_25);
39868                 update_fail_malformed_htlcs_arg_conv_25_conv.is_owned = ptr_is_owned(update_fail_malformed_htlcs_arg_conv_25);
39869                 CHECK_INNER_FIELD_ACCESS_OR_NULL(update_fail_malformed_htlcs_arg_conv_25_conv);
39870                 update_fail_malformed_htlcs_arg_conv_25_conv = UpdateFailMalformedHTLC_clone(&update_fail_malformed_htlcs_arg_conv_25_conv);
39871                 update_fail_malformed_htlcs_arg_constr.data[z] = update_fail_malformed_htlcs_arg_conv_25_conv;
39872         }
39873         (*env)->ReleaseLongArrayElements(env, update_fail_malformed_htlcs_arg, update_fail_malformed_htlcs_arg_vals, 0);
39874         LDKUpdateFee update_fee_arg_conv;
39875         update_fee_arg_conv.inner = untag_ptr(update_fee_arg);
39876         update_fee_arg_conv.is_owned = ptr_is_owned(update_fee_arg);
39877         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_fee_arg_conv);
39878         update_fee_arg_conv = UpdateFee_clone(&update_fee_arg_conv);
39879         LDKCommitmentSigned commitment_signed_arg_conv;
39880         commitment_signed_arg_conv.inner = untag_ptr(commitment_signed_arg);
39881         commitment_signed_arg_conv.is_owned = ptr_is_owned(commitment_signed_arg);
39882         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_signed_arg_conv);
39883         commitment_signed_arg_conv = CommitmentSigned_clone(&commitment_signed_arg_conv);
39884         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);
39885         int64_t ret_ref = 0;
39886         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39887         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39888         return ret_ref;
39889 }
39890
39891 static inline uint64_t CommitmentUpdate_clone_ptr(LDKCommitmentUpdate *NONNULL_PTR arg) {
39892         LDKCommitmentUpdate ret_var = CommitmentUpdate_clone(arg);
39893         int64_t ret_ref = 0;
39894         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39895         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39896         return ret_ref;
39897 }
39898 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
39899         LDKCommitmentUpdate arg_conv;
39900         arg_conv.inner = untag_ptr(arg);
39901         arg_conv.is_owned = ptr_is_owned(arg);
39902         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
39903         arg_conv.is_owned = false;
39904         int64_t ret_conv = CommitmentUpdate_clone_ptr(&arg_conv);
39905         return ret_conv;
39906 }
39907
39908 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
39909         LDKCommitmentUpdate orig_conv;
39910         orig_conv.inner = untag_ptr(orig);
39911         orig_conv.is_owned = ptr_is_owned(orig);
39912         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
39913         orig_conv.is_owned = false;
39914         LDKCommitmentUpdate ret_var = CommitmentUpdate_clone(&orig_conv);
39915         int64_t ret_ref = 0;
39916         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39917         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
39918         return ret_ref;
39919 }
39920
39921 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
39922         LDKCommitmentUpdate a_conv;
39923         a_conv.inner = untag_ptr(a);
39924         a_conv.is_owned = ptr_is_owned(a);
39925         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
39926         a_conv.is_owned = false;
39927         LDKCommitmentUpdate b_conv;
39928         b_conv.inner = untag_ptr(b);
39929         b_conv.is_owned = ptr_is_owned(b);
39930         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
39931         b_conv.is_owned = false;
39932         jboolean ret_conv = CommitmentUpdate_eq(&a_conv, &b_conv);
39933         return ret_conv;
39934 }
39935
39936 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
39937         if (!ptr_is_owned(this_ptr)) return;
39938         void* this_ptr_ptr = untag_ptr(this_ptr);
39939         CHECK_ACCESS(this_ptr_ptr);
39940         LDKChannelMessageHandler this_ptr_conv = *(LDKChannelMessageHandler*)(this_ptr_ptr);
39941         FREE(untag_ptr(this_ptr));
39942         ChannelMessageHandler_free(this_ptr_conv);
39943 }
39944
39945 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
39946         if (!ptr_is_owned(this_ptr)) return;
39947         void* this_ptr_ptr = untag_ptr(this_ptr);
39948         CHECK_ACCESS(this_ptr_ptr);
39949         LDKRoutingMessageHandler this_ptr_conv = *(LDKRoutingMessageHandler*)(this_ptr_ptr);
39950         FREE(untag_ptr(this_ptr));
39951         RoutingMessageHandler_free(this_ptr_conv);
39952 }
39953
39954 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OnionMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
39955         if (!ptr_is_owned(this_ptr)) return;
39956         void* this_ptr_ptr = untag_ptr(this_ptr);
39957         CHECK_ACCESS(this_ptr_ptr);
39958         LDKOnionMessageHandler this_ptr_conv = *(LDKOnionMessageHandler*)(this_ptr_ptr);
39959         FREE(untag_ptr(this_ptr));
39960         OnionMessageHandler_free(this_ptr_conv);
39961 }
39962
39963 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1write(JNIEnv *env, jclass clz, int64_t obj) {
39964         LDKAcceptChannel obj_conv;
39965         obj_conv.inner = untag_ptr(obj);
39966         obj_conv.is_owned = ptr_is_owned(obj);
39967         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
39968         obj_conv.is_owned = false;
39969         LDKCVec_u8Z ret_var = AcceptChannel_write(&obj_conv);
39970         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
39971         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
39972         CVec_u8Z_free(ret_var);
39973         return ret_arr;
39974 }
39975
39976 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
39977         LDKu8slice ser_ref;
39978         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
39979         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
39980         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
39981         *ret_conv = AcceptChannel_read(ser_ref);
39982         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
39983         return tag_ptr(ret_conv, true);
39984 }
39985
39986 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
39987         LDKAnnouncementSignatures obj_conv;
39988         obj_conv.inner = untag_ptr(obj);
39989         obj_conv.is_owned = ptr_is_owned(obj);
39990         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
39991         obj_conv.is_owned = false;
39992         LDKCVec_u8Z ret_var = AnnouncementSignatures_write(&obj_conv);
39993         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
39994         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
39995         CVec_u8Z_free(ret_var);
39996         return ret_arr;
39997 }
39998
39999 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
40000         LDKu8slice ser_ref;
40001         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
40002         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
40003         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
40004         *ret_conv = AnnouncementSignatures_read(ser_ref);
40005         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
40006         return tag_ptr(ret_conv, true);
40007 }
40008
40009 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1write(JNIEnv *env, jclass clz, int64_t obj) {
40010         LDKChannelReestablish obj_conv;
40011         obj_conv.inner = untag_ptr(obj);
40012         obj_conv.is_owned = ptr_is_owned(obj);
40013         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
40014         obj_conv.is_owned = false;
40015         LDKCVec_u8Z ret_var = ChannelReestablish_write(&obj_conv);
40016         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
40017         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
40018         CVec_u8Z_free(ret_var);
40019         return ret_arr;
40020 }
40021
40022 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
40023         LDKu8slice ser_ref;
40024         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
40025         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
40026         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
40027         *ret_conv = ChannelReestablish_read(ser_ref);
40028         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
40029         return tag_ptr(ret_conv, true);
40030 }
40031
40032 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1write(JNIEnv *env, jclass clz, int64_t obj) {
40033         LDKClosingSigned obj_conv;
40034         obj_conv.inner = untag_ptr(obj);
40035         obj_conv.is_owned = ptr_is_owned(obj);
40036         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
40037         obj_conv.is_owned = false;
40038         LDKCVec_u8Z ret_var = ClosingSigned_write(&obj_conv);
40039         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
40040         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
40041         CVec_u8Z_free(ret_var);
40042         return ret_arr;
40043 }
40044
40045 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
40046         LDKu8slice ser_ref;
40047         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
40048         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
40049         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
40050         *ret_conv = ClosingSigned_read(ser_ref);
40051         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
40052         return tag_ptr(ret_conv, true);
40053 }
40054
40055 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1write(JNIEnv *env, jclass clz, int64_t obj) {
40056         LDKClosingSignedFeeRange obj_conv;
40057         obj_conv.inner = untag_ptr(obj);
40058         obj_conv.is_owned = ptr_is_owned(obj);
40059         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
40060         obj_conv.is_owned = false;
40061         LDKCVec_u8Z ret_var = ClosingSignedFeeRange_write(&obj_conv);
40062         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
40063         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
40064         CVec_u8Z_free(ret_var);
40065         return ret_arr;
40066 }
40067
40068 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
40069         LDKu8slice ser_ref;
40070         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
40071         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
40072         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
40073         *ret_conv = ClosingSignedFeeRange_read(ser_ref);
40074         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
40075         return tag_ptr(ret_conv, true);
40076 }
40077
40078 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1write(JNIEnv *env, jclass clz, int64_t obj) {
40079         LDKCommitmentSigned obj_conv;
40080         obj_conv.inner = untag_ptr(obj);
40081         obj_conv.is_owned = ptr_is_owned(obj);
40082         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
40083         obj_conv.is_owned = false;
40084         LDKCVec_u8Z ret_var = CommitmentSigned_write(&obj_conv);
40085         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
40086         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
40087         CVec_u8Z_free(ret_var);
40088         return ret_arr;
40089 }
40090
40091 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
40092         LDKu8slice ser_ref;
40093         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
40094         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
40095         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
40096         *ret_conv = CommitmentSigned_read(ser_ref);
40097         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
40098         return tag_ptr(ret_conv, true);
40099 }
40100
40101 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingCreated_1write(JNIEnv *env, jclass clz, int64_t obj) {
40102         LDKFundingCreated obj_conv;
40103         obj_conv.inner = untag_ptr(obj);
40104         obj_conv.is_owned = ptr_is_owned(obj);
40105         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
40106         obj_conv.is_owned = false;
40107         LDKCVec_u8Z ret_var = FundingCreated_write(&obj_conv);
40108         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
40109         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
40110         CVec_u8Z_free(ret_var);
40111         return ret_arr;
40112 }
40113
40114 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingCreated_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
40115         LDKu8slice ser_ref;
40116         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
40117         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
40118         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
40119         *ret_conv = FundingCreated_read(ser_ref);
40120         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
40121         return tag_ptr(ret_conv, true);
40122 }
40123
40124 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingSigned_1write(JNIEnv *env, jclass clz, int64_t obj) {
40125         LDKFundingSigned obj_conv;
40126         obj_conv.inner = untag_ptr(obj);
40127         obj_conv.is_owned = ptr_is_owned(obj);
40128         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
40129         obj_conv.is_owned = false;
40130         LDKCVec_u8Z ret_var = FundingSigned_write(&obj_conv);
40131         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
40132         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
40133         CVec_u8Z_free(ret_var);
40134         return ret_arr;
40135 }
40136
40137 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingSigned_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
40138         LDKu8slice ser_ref;
40139         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
40140         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
40141         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
40142         *ret_conv = FundingSigned_read(ser_ref);
40143         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
40144         return tag_ptr(ret_conv, true);
40145 }
40146
40147 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelReady_1write(JNIEnv *env, jclass clz, int64_t obj) {
40148         LDKChannelReady obj_conv;
40149         obj_conv.inner = untag_ptr(obj);
40150         obj_conv.is_owned = ptr_is_owned(obj);
40151         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
40152         obj_conv.is_owned = false;
40153         LDKCVec_u8Z ret_var = ChannelReady_write(&obj_conv);
40154         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
40155         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
40156         CVec_u8Z_free(ret_var);
40157         return ret_arr;
40158 }
40159
40160 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReady_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
40161         LDKu8slice ser_ref;
40162         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
40163         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
40164         LDKCResult_ChannelReadyDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReadyDecodeErrorZ), "LDKCResult_ChannelReadyDecodeErrorZ");
40165         *ret_conv = ChannelReady_read(ser_ref);
40166         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
40167         return tag_ptr(ret_conv, true);
40168 }
40169
40170 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Init_1write(JNIEnv *env, jclass clz, int64_t obj) {
40171         LDKInit obj_conv;
40172         obj_conv.inner = untag_ptr(obj);
40173         obj_conv.is_owned = ptr_is_owned(obj);
40174         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
40175         obj_conv.is_owned = false;
40176         LDKCVec_u8Z ret_var = Init_write(&obj_conv);
40177         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
40178         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
40179         CVec_u8Z_free(ret_var);
40180         return ret_arr;
40181 }
40182
40183 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
40184         LDKu8slice ser_ref;
40185         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
40186         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
40187         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
40188         *ret_conv = Init_read(ser_ref);
40189         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
40190         return tag_ptr(ret_conv, true);
40191 }
40192
40193 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1write(JNIEnv *env, jclass clz, int64_t obj) {
40194         LDKOpenChannel obj_conv;
40195         obj_conv.inner = untag_ptr(obj);
40196         obj_conv.is_owned = ptr_is_owned(obj);
40197         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
40198         obj_conv.is_owned = false;
40199         LDKCVec_u8Z ret_var = OpenChannel_write(&obj_conv);
40200         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
40201         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
40202         CVec_u8Z_free(ret_var);
40203         return ret_arr;
40204 }
40205
40206 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
40207         LDKu8slice ser_ref;
40208         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
40209         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
40210         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
40211         *ret_conv = OpenChannel_read(ser_ref);
40212         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
40213         return tag_ptr(ret_conv, true);
40214 }
40215
40216 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1write(JNIEnv *env, jclass clz, int64_t obj) {
40217         LDKRevokeAndACK obj_conv;
40218         obj_conv.inner = untag_ptr(obj);
40219         obj_conv.is_owned = ptr_is_owned(obj);
40220         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
40221         obj_conv.is_owned = false;
40222         LDKCVec_u8Z ret_var = RevokeAndACK_write(&obj_conv);
40223         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
40224         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
40225         CVec_u8Z_free(ret_var);
40226         return ret_arr;
40227 }
40228
40229 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
40230         LDKu8slice ser_ref;
40231         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
40232         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
40233         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
40234         *ret_conv = RevokeAndACK_read(ser_ref);
40235         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
40236         return tag_ptr(ret_conv, true);
40237 }
40238
40239 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Shutdown_1write(JNIEnv *env, jclass clz, int64_t obj) {
40240         LDKShutdown obj_conv;
40241         obj_conv.inner = untag_ptr(obj);
40242         obj_conv.is_owned = ptr_is_owned(obj);
40243         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
40244         obj_conv.is_owned = false;
40245         LDKCVec_u8Z ret_var = Shutdown_write(&obj_conv);
40246         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
40247         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
40248         CVec_u8Z_free(ret_var);
40249         return ret_arr;
40250 }
40251
40252 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Shutdown_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
40253         LDKu8slice ser_ref;
40254         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
40255         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
40256         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
40257         *ret_conv = Shutdown_read(ser_ref);
40258         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
40259         return tag_ptr(ret_conv, true);
40260 }
40261
40262 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1write(JNIEnv *env, jclass clz, int64_t obj) {
40263         LDKUpdateFailHTLC obj_conv;
40264         obj_conv.inner = untag_ptr(obj);
40265         obj_conv.is_owned = ptr_is_owned(obj);
40266         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
40267         obj_conv.is_owned = false;
40268         LDKCVec_u8Z ret_var = UpdateFailHTLC_write(&obj_conv);
40269         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
40270         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
40271         CVec_u8Z_free(ret_var);
40272         return ret_arr;
40273 }
40274
40275 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
40276         LDKu8slice ser_ref;
40277         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
40278         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
40279         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
40280         *ret_conv = UpdateFailHTLC_read(ser_ref);
40281         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
40282         return tag_ptr(ret_conv, true);
40283 }
40284
40285 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1write(JNIEnv *env, jclass clz, int64_t obj) {
40286         LDKUpdateFailMalformedHTLC obj_conv;
40287         obj_conv.inner = untag_ptr(obj);
40288         obj_conv.is_owned = ptr_is_owned(obj);
40289         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
40290         obj_conv.is_owned = false;
40291         LDKCVec_u8Z ret_var = UpdateFailMalformedHTLC_write(&obj_conv);
40292         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
40293         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
40294         CVec_u8Z_free(ret_var);
40295         return ret_arr;
40296 }
40297
40298 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
40299         LDKu8slice ser_ref;
40300         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
40301         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
40302         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
40303         *ret_conv = UpdateFailMalformedHTLC_read(ser_ref);
40304         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
40305         return tag_ptr(ret_conv, true);
40306 }
40307
40308 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFee_1write(JNIEnv *env, jclass clz, int64_t obj) {
40309         LDKUpdateFee obj_conv;
40310         obj_conv.inner = untag_ptr(obj);
40311         obj_conv.is_owned = ptr_is_owned(obj);
40312         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
40313         obj_conv.is_owned = false;
40314         LDKCVec_u8Z ret_var = UpdateFee_write(&obj_conv);
40315         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
40316         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
40317         CVec_u8Z_free(ret_var);
40318         return ret_arr;
40319 }
40320
40321 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFee_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
40322         LDKu8slice ser_ref;
40323         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
40324         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
40325         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
40326         *ret_conv = UpdateFee_read(ser_ref);
40327         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
40328         return tag_ptr(ret_conv, true);
40329 }
40330
40331 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1write(JNIEnv *env, jclass clz, int64_t obj) {
40332         LDKUpdateFulfillHTLC obj_conv;
40333         obj_conv.inner = untag_ptr(obj);
40334         obj_conv.is_owned = ptr_is_owned(obj);
40335         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
40336         obj_conv.is_owned = false;
40337         LDKCVec_u8Z ret_var = UpdateFulfillHTLC_write(&obj_conv);
40338         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
40339         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
40340         CVec_u8Z_free(ret_var);
40341         return ret_arr;
40342 }
40343
40344 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
40345         LDKu8slice ser_ref;
40346         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
40347         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
40348         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
40349         *ret_conv = UpdateFulfillHTLC_read(ser_ref);
40350         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
40351         return tag_ptr(ret_conv, true);
40352 }
40353
40354 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1write(JNIEnv *env, jclass clz, int64_t obj) {
40355         LDKUpdateAddHTLC obj_conv;
40356         obj_conv.inner = untag_ptr(obj);
40357         obj_conv.is_owned = ptr_is_owned(obj);
40358         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
40359         obj_conv.is_owned = false;
40360         LDKCVec_u8Z ret_var = UpdateAddHTLC_write(&obj_conv);
40361         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
40362         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
40363         CVec_u8Z_free(ret_var);
40364         return ret_arr;
40365 }
40366
40367 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
40368         LDKu8slice ser_ref;
40369         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
40370         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
40371         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
40372         *ret_conv = UpdateAddHTLC_read(ser_ref);
40373         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
40374         return tag_ptr(ret_conv, true);
40375 }
40376
40377 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OnionMessage_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
40378         LDKu8slice ser_ref;
40379         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
40380         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
40381         LDKCResult_OnionMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OnionMessageDecodeErrorZ), "LDKCResult_OnionMessageDecodeErrorZ");
40382         *ret_conv = OnionMessage_read(ser_ref);
40383         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
40384         return tag_ptr(ret_conv, true);
40385 }
40386
40387 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OnionMessage_1write(JNIEnv *env, jclass clz, int64_t obj) {
40388         LDKOnionMessage 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 = OnionMessage_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 int8_tArray JNICALL Java_org_ldk_impl_bindings_Ping_1write(JNIEnv *env, jclass clz, int64_t obj) {
40401         LDKPing obj_conv;
40402         obj_conv.inner = untag_ptr(obj);
40403         obj_conv.is_owned = ptr_is_owned(obj);
40404         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
40405         obj_conv.is_owned = false;
40406         LDKCVec_u8Z ret_var = Ping_write(&obj_conv);
40407         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
40408         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
40409         CVec_u8Z_free(ret_var);
40410         return ret_arr;
40411 }
40412
40413 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Ping_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
40414         LDKu8slice ser_ref;
40415         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
40416         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
40417         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
40418         *ret_conv = Ping_read(ser_ref);
40419         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
40420         return tag_ptr(ret_conv, true);
40421 }
40422
40423 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Pong_1write(JNIEnv *env, jclass clz, int64_t obj) {
40424         LDKPong obj_conv;
40425         obj_conv.inner = untag_ptr(obj);
40426         obj_conv.is_owned = ptr_is_owned(obj);
40427         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
40428         obj_conv.is_owned = false;
40429         LDKCVec_u8Z ret_var = Pong_write(&obj_conv);
40430         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
40431         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
40432         CVec_u8Z_free(ret_var);
40433         return ret_arr;
40434 }
40435
40436 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Pong_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
40437         LDKu8slice ser_ref;
40438         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
40439         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
40440         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
40441         *ret_conv = Pong_read(ser_ref);
40442         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
40443         return tag_ptr(ret_conv, true);
40444 }
40445
40446 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1write(JNIEnv *env, jclass clz, int64_t obj) {
40447         LDKUnsignedChannelAnnouncement obj_conv;
40448         obj_conv.inner = untag_ptr(obj);
40449         obj_conv.is_owned = ptr_is_owned(obj);
40450         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
40451         obj_conv.is_owned = false;
40452         LDKCVec_u8Z ret_var = UnsignedChannelAnnouncement_write(&obj_conv);
40453         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
40454         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
40455         CVec_u8Z_free(ret_var);
40456         return ret_arr;
40457 }
40458
40459 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
40460         LDKu8slice ser_ref;
40461         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
40462         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
40463         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
40464         *ret_conv = UnsignedChannelAnnouncement_read(ser_ref);
40465         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
40466         return tag_ptr(ret_conv, true);
40467 }
40468
40469 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1write(JNIEnv *env, jclass clz, int64_t obj) {
40470         LDKChannelAnnouncement obj_conv;
40471         obj_conv.inner = untag_ptr(obj);
40472         obj_conv.is_owned = ptr_is_owned(obj);
40473         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
40474         obj_conv.is_owned = false;
40475         LDKCVec_u8Z ret_var = ChannelAnnouncement_write(&obj_conv);
40476         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
40477         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
40478         CVec_u8Z_free(ret_var);
40479         return ret_arr;
40480 }
40481
40482 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
40483         LDKu8slice ser_ref;
40484         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
40485         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
40486         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
40487         *ret_conv = ChannelAnnouncement_read(ser_ref);
40488         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
40489         return tag_ptr(ret_conv, true);
40490 }
40491
40492 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) {
40493         LDKUnsignedChannelUpdate obj_conv;
40494         obj_conv.inner = untag_ptr(obj);
40495         obj_conv.is_owned = ptr_is_owned(obj);
40496         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
40497         obj_conv.is_owned = false;
40498         LDKCVec_u8Z ret_var = UnsignedChannelUpdate_write(&obj_conv);
40499         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
40500         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
40501         CVec_u8Z_free(ret_var);
40502         return ret_arr;
40503 }
40504
40505 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
40506         LDKu8slice ser_ref;
40507         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
40508         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
40509         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
40510         *ret_conv = UnsignedChannelUpdate_read(ser_ref);
40511         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
40512         return tag_ptr(ret_conv, true);
40513 }
40514
40515 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) {
40516         LDKChannelUpdate obj_conv;
40517         obj_conv.inner = untag_ptr(obj);
40518         obj_conv.is_owned = ptr_is_owned(obj);
40519         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
40520         obj_conv.is_owned = false;
40521         LDKCVec_u8Z ret_var = ChannelUpdate_write(&obj_conv);
40522         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
40523         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
40524         CVec_u8Z_free(ret_var);
40525         return ret_arr;
40526 }
40527
40528 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
40529         LDKu8slice ser_ref;
40530         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
40531         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
40532         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
40533         *ret_conv = ChannelUpdate_read(ser_ref);
40534         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
40535         return tag_ptr(ret_conv, true);
40536 }
40537
40538 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1write(JNIEnv *env, jclass clz, int64_t obj) {
40539         LDKErrorMessage obj_conv;
40540         obj_conv.inner = untag_ptr(obj);
40541         obj_conv.is_owned = ptr_is_owned(obj);
40542         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
40543         obj_conv.is_owned = false;
40544         LDKCVec_u8Z ret_var = ErrorMessage_write(&obj_conv);
40545         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
40546         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
40547         CVec_u8Z_free(ret_var);
40548         return ret_arr;
40549 }
40550
40551 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
40552         LDKu8slice ser_ref;
40553         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
40554         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
40555         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
40556         *ret_conv = ErrorMessage_read(ser_ref);
40557         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
40558         return tag_ptr(ret_conv, true);
40559 }
40560
40561 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_WarningMessage_1write(JNIEnv *env, jclass clz, int64_t obj) {
40562         LDKWarningMessage obj_conv;
40563         obj_conv.inner = untag_ptr(obj);
40564         obj_conv.is_owned = ptr_is_owned(obj);
40565         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
40566         obj_conv.is_owned = false;
40567         LDKCVec_u8Z ret_var = WarningMessage_write(&obj_conv);
40568         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
40569         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
40570         CVec_u8Z_free(ret_var);
40571         return ret_arr;
40572 }
40573
40574 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WarningMessage_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
40575         LDKu8slice ser_ref;
40576         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
40577         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
40578         LDKCResult_WarningMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_WarningMessageDecodeErrorZ), "LDKCResult_WarningMessageDecodeErrorZ");
40579         *ret_conv = WarningMessage_read(ser_ref);
40580         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
40581         return tag_ptr(ret_conv, true);
40582 }
40583
40584 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1write(JNIEnv *env, jclass clz, int64_t obj) {
40585         LDKUnsignedNodeAnnouncement obj_conv;
40586         obj_conv.inner = untag_ptr(obj);
40587         obj_conv.is_owned = ptr_is_owned(obj);
40588         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
40589         obj_conv.is_owned = false;
40590         LDKCVec_u8Z ret_var = UnsignedNodeAnnouncement_write(&obj_conv);
40591         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
40592         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
40593         CVec_u8Z_free(ret_var);
40594         return ret_arr;
40595 }
40596
40597 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
40598         LDKu8slice ser_ref;
40599         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
40600         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
40601         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
40602         *ret_conv = UnsignedNodeAnnouncement_read(ser_ref);
40603         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
40604         return tag_ptr(ret_conv, true);
40605 }
40606
40607 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1write(JNIEnv *env, jclass clz, int64_t obj) {
40608         LDKNodeAnnouncement obj_conv;
40609         obj_conv.inner = untag_ptr(obj);
40610         obj_conv.is_owned = ptr_is_owned(obj);
40611         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
40612         obj_conv.is_owned = false;
40613         LDKCVec_u8Z ret_var = NodeAnnouncement_write(&obj_conv);
40614         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
40615         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
40616         CVec_u8Z_free(ret_var);
40617         return ret_arr;
40618 }
40619
40620 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
40621         LDKu8slice ser_ref;
40622         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
40623         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
40624         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
40625         *ret_conv = NodeAnnouncement_read(ser_ref);
40626         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
40627         return tag_ptr(ret_conv, true);
40628 }
40629
40630 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
40631         LDKu8slice ser_ref;
40632         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
40633         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
40634         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
40635         *ret_conv = QueryShortChannelIds_read(ser_ref);
40636         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
40637         return tag_ptr(ret_conv, true);
40638 }
40639
40640 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1write(JNIEnv *env, jclass clz, int64_t obj) {
40641         LDKQueryShortChannelIds obj_conv;
40642         obj_conv.inner = untag_ptr(obj);
40643         obj_conv.is_owned = ptr_is_owned(obj);
40644         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
40645         obj_conv.is_owned = false;
40646         LDKCVec_u8Z ret_var = QueryShortChannelIds_write(&obj_conv);
40647         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
40648         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
40649         CVec_u8Z_free(ret_var);
40650         return ret_arr;
40651 }
40652
40653 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1write(JNIEnv *env, jclass clz, int64_t obj) {
40654         LDKReplyShortChannelIdsEnd obj_conv;
40655         obj_conv.inner = untag_ptr(obj);
40656         obj_conv.is_owned = ptr_is_owned(obj);
40657         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
40658         obj_conv.is_owned = false;
40659         LDKCVec_u8Z ret_var = ReplyShortChannelIdsEnd_write(&obj_conv);
40660         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
40661         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
40662         CVec_u8Z_free(ret_var);
40663         return ret_arr;
40664 }
40665
40666 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
40667         LDKu8slice ser_ref;
40668         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
40669         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
40670         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
40671         *ret_conv = ReplyShortChannelIdsEnd_read(ser_ref);
40672         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
40673         return tag_ptr(ret_conv, true);
40674 }
40675
40676 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1end_1blocknum(JNIEnv *env, jclass clz, int64_t this_arg) {
40677         LDKQueryChannelRange this_arg_conv;
40678         this_arg_conv.inner = untag_ptr(this_arg);
40679         this_arg_conv.is_owned = ptr_is_owned(this_arg);
40680         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40681         this_arg_conv.is_owned = false;
40682         int32_t ret_conv = QueryChannelRange_end_blocknum(&this_arg_conv);
40683         return ret_conv;
40684 }
40685
40686 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1write(JNIEnv *env, jclass clz, int64_t obj) {
40687         LDKQueryChannelRange obj_conv;
40688         obj_conv.inner = untag_ptr(obj);
40689         obj_conv.is_owned = ptr_is_owned(obj);
40690         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
40691         obj_conv.is_owned = false;
40692         LDKCVec_u8Z ret_var = QueryChannelRange_write(&obj_conv);
40693         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
40694         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
40695         CVec_u8Z_free(ret_var);
40696         return ret_arr;
40697 }
40698
40699 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
40700         LDKu8slice ser_ref;
40701         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
40702         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
40703         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
40704         *ret_conv = QueryChannelRange_read(ser_ref);
40705         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
40706         return tag_ptr(ret_conv, true);
40707 }
40708
40709 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
40710         LDKu8slice ser_ref;
40711         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
40712         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
40713         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
40714         *ret_conv = ReplyChannelRange_read(ser_ref);
40715         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
40716         return tag_ptr(ret_conv, true);
40717 }
40718
40719 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1write(JNIEnv *env, jclass clz, int64_t obj) {
40720         LDKReplyChannelRange obj_conv;
40721         obj_conv.inner = untag_ptr(obj);
40722         obj_conv.is_owned = ptr_is_owned(obj);
40723         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
40724         obj_conv.is_owned = false;
40725         LDKCVec_u8Z ret_var = ReplyChannelRange_write(&obj_conv);
40726         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
40727         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
40728         CVec_u8Z_free(ret_var);
40729         return ret_arr;
40730 }
40731
40732 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1write(JNIEnv *env, jclass clz, int64_t obj) {
40733         LDKGossipTimestampFilter obj_conv;
40734         obj_conv.inner = untag_ptr(obj);
40735         obj_conv.is_owned = ptr_is_owned(obj);
40736         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
40737         obj_conv.is_owned = false;
40738         LDKCVec_u8Z ret_var = GossipTimestampFilter_write(&obj_conv);
40739         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
40740         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
40741         CVec_u8Z_free(ret_var);
40742         return ret_arr;
40743 }
40744
40745 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
40746         LDKu8slice ser_ref;
40747         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
40748         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
40749         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
40750         *ret_conv = GossipTimestampFilter_read(ser_ref);
40751         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
40752         return tag_ptr(ret_conv, true);
40753 }
40754
40755 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CustomMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
40756         if (!ptr_is_owned(this_ptr)) return;
40757         void* this_ptr_ptr = untag_ptr(this_ptr);
40758         CHECK_ACCESS(this_ptr_ptr);
40759         LDKCustomMessageHandler this_ptr_conv = *(LDKCustomMessageHandler*)(this_ptr_ptr);
40760         FREE(untag_ptr(this_ptr));
40761         CustomMessageHandler_free(this_ptr_conv);
40762 }
40763
40764 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
40765         LDKIgnoringMessageHandler this_obj_conv;
40766         this_obj_conv.inner = untag_ptr(this_obj);
40767         this_obj_conv.is_owned = ptr_is_owned(this_obj);
40768         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
40769         IgnoringMessageHandler_free(this_obj_conv);
40770 }
40771
40772 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1new(JNIEnv *env, jclass clz) {
40773         LDKIgnoringMessageHandler ret_var = IgnoringMessageHandler_new();
40774         int64_t ret_ref = 0;
40775         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40776         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
40777         return ret_ref;
40778 }
40779
40780 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1as_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
40781         LDKIgnoringMessageHandler this_arg_conv;
40782         this_arg_conv.inner = untag_ptr(this_arg);
40783         this_arg_conv.is_owned = ptr_is_owned(this_arg);
40784         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40785         this_arg_conv.is_owned = false;
40786         LDKMessageSendEventsProvider* ret_ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
40787         *ret_ret = IgnoringMessageHandler_as_MessageSendEventsProvider(&this_arg_conv);
40788         return tag_ptr(ret_ret, true);
40789 }
40790
40791 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1as_1RoutingMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
40792         LDKIgnoringMessageHandler this_arg_conv;
40793         this_arg_conv.inner = untag_ptr(this_arg);
40794         this_arg_conv.is_owned = ptr_is_owned(this_arg);
40795         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40796         this_arg_conv.is_owned = false;
40797         LDKRoutingMessageHandler* ret_ret = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
40798         *ret_ret = IgnoringMessageHandler_as_RoutingMessageHandler(&this_arg_conv);
40799         return tag_ptr(ret_ret, true);
40800 }
40801
40802 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1as_1OnionMessageProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
40803         LDKIgnoringMessageHandler this_arg_conv;
40804         this_arg_conv.inner = untag_ptr(this_arg);
40805         this_arg_conv.is_owned = ptr_is_owned(this_arg);
40806         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40807         this_arg_conv.is_owned = false;
40808         LDKOnionMessageProvider* ret_ret = MALLOC(sizeof(LDKOnionMessageProvider), "LDKOnionMessageProvider");
40809         *ret_ret = IgnoringMessageHandler_as_OnionMessageProvider(&this_arg_conv);
40810         return tag_ptr(ret_ret, true);
40811 }
40812
40813 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1as_1OnionMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
40814         LDKIgnoringMessageHandler this_arg_conv;
40815         this_arg_conv.inner = untag_ptr(this_arg);
40816         this_arg_conv.is_owned = ptr_is_owned(this_arg);
40817         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40818         this_arg_conv.is_owned = false;
40819         LDKOnionMessageHandler* ret_ret = MALLOC(sizeof(LDKOnionMessageHandler), "LDKOnionMessageHandler");
40820         *ret_ret = IgnoringMessageHandler_as_OnionMessageHandler(&this_arg_conv);
40821         return tag_ptr(ret_ret, true);
40822 }
40823
40824 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1as_1CustomOnionMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
40825         LDKIgnoringMessageHandler this_arg_conv;
40826         this_arg_conv.inner = untag_ptr(this_arg);
40827         this_arg_conv.is_owned = ptr_is_owned(this_arg);
40828         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40829         this_arg_conv.is_owned = false;
40830         LDKCustomOnionMessageHandler* ret_ret = MALLOC(sizeof(LDKCustomOnionMessageHandler), "LDKCustomOnionMessageHandler");
40831         *ret_ret = IgnoringMessageHandler_as_CustomOnionMessageHandler(&this_arg_conv);
40832         return tag_ptr(ret_ret, true);
40833 }
40834
40835 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1as_1CustomMessageReader(JNIEnv *env, jclass clz, int64_t this_arg) {
40836         LDKIgnoringMessageHandler this_arg_conv;
40837         this_arg_conv.inner = untag_ptr(this_arg);
40838         this_arg_conv.is_owned = ptr_is_owned(this_arg);
40839         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40840         this_arg_conv.is_owned = false;
40841         LDKCustomMessageReader* ret_ret = MALLOC(sizeof(LDKCustomMessageReader), "LDKCustomMessageReader");
40842         *ret_ret = IgnoringMessageHandler_as_CustomMessageReader(&this_arg_conv);
40843         return tag_ptr(ret_ret, true);
40844 }
40845
40846 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1as_1CustomMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
40847         LDKIgnoringMessageHandler this_arg_conv;
40848         this_arg_conv.inner = untag_ptr(this_arg);
40849         this_arg_conv.is_owned = ptr_is_owned(this_arg);
40850         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40851         this_arg_conv.is_owned = false;
40852         LDKCustomMessageHandler* ret_ret = MALLOC(sizeof(LDKCustomMessageHandler), "LDKCustomMessageHandler");
40853         *ret_ret = IgnoringMessageHandler_as_CustomMessageHandler(&this_arg_conv);
40854         return tag_ptr(ret_ret, true);
40855 }
40856
40857 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErroringMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
40858         LDKErroringMessageHandler this_obj_conv;
40859         this_obj_conv.inner = untag_ptr(this_obj);
40860         this_obj_conv.is_owned = ptr_is_owned(this_obj);
40861         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
40862         ErroringMessageHandler_free(this_obj_conv);
40863 }
40864
40865 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErroringMessageHandler_1new(JNIEnv *env, jclass clz) {
40866         LDKErroringMessageHandler ret_var = ErroringMessageHandler_new();
40867         int64_t ret_ref = 0;
40868         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40869         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
40870         return ret_ref;
40871 }
40872
40873 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErroringMessageHandler_1as_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
40874         LDKErroringMessageHandler this_arg_conv;
40875         this_arg_conv.inner = untag_ptr(this_arg);
40876         this_arg_conv.is_owned = ptr_is_owned(this_arg);
40877         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40878         this_arg_conv.is_owned = false;
40879         LDKMessageSendEventsProvider* ret_ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
40880         *ret_ret = ErroringMessageHandler_as_MessageSendEventsProvider(&this_arg_conv);
40881         return tag_ptr(ret_ret, true);
40882 }
40883
40884 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErroringMessageHandler_1as_1ChannelMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
40885         LDKErroringMessageHandler this_arg_conv;
40886         this_arg_conv.inner = untag_ptr(this_arg);
40887         this_arg_conv.is_owned = ptr_is_owned(this_arg);
40888         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40889         this_arg_conv.is_owned = false;
40890         LDKChannelMessageHandler* ret_ret = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
40891         *ret_ret = ErroringMessageHandler_as_ChannelMessageHandler(&this_arg_conv);
40892         return tag_ptr(ret_ret, true);
40893 }
40894
40895 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
40896         LDKMessageHandler this_obj_conv;
40897         this_obj_conv.inner = untag_ptr(this_obj);
40898         this_obj_conv.is_owned = ptr_is_owned(this_obj);
40899         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
40900         MessageHandler_free(this_obj_conv);
40901 }
40902
40903 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageHandler_1get_1chan_1handler(JNIEnv *env, jclass clz, int64_t this_ptr) {
40904         LDKMessageHandler this_ptr_conv;
40905         this_ptr_conv.inner = untag_ptr(this_ptr);
40906         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40907         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40908         this_ptr_conv.is_owned = false;
40909         // WARNING: This object doesn't live past this scope, needs clone!
40910         int64_t ret_ret = tag_ptr(MessageHandler_get_chan_handler(&this_ptr_conv), false);
40911         return ret_ret;
40912 }
40913
40914 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageHandler_1set_1chan_1handler(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
40915         LDKMessageHandler this_ptr_conv;
40916         this_ptr_conv.inner = untag_ptr(this_ptr);
40917         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40918         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40919         this_ptr_conv.is_owned = false;
40920         void* val_ptr = untag_ptr(val);
40921         CHECK_ACCESS(val_ptr);
40922         LDKChannelMessageHandler val_conv = *(LDKChannelMessageHandler*)(val_ptr);
40923         if (val_conv.free == LDKChannelMessageHandler_JCalls_free) {
40924                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
40925                 LDKChannelMessageHandler_JCalls_cloned(&val_conv);
40926         }
40927         MessageHandler_set_chan_handler(&this_ptr_conv, val_conv);
40928 }
40929
40930 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageHandler_1get_1route_1handler(JNIEnv *env, jclass clz, int64_t this_ptr) {
40931         LDKMessageHandler this_ptr_conv;
40932         this_ptr_conv.inner = untag_ptr(this_ptr);
40933         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40934         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40935         this_ptr_conv.is_owned = false;
40936         // WARNING: This object doesn't live past this scope, needs clone!
40937         int64_t ret_ret = tag_ptr(MessageHandler_get_route_handler(&this_ptr_conv), false);
40938         return ret_ret;
40939 }
40940
40941 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageHandler_1set_1route_1handler(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
40942         LDKMessageHandler this_ptr_conv;
40943         this_ptr_conv.inner = untag_ptr(this_ptr);
40944         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40945         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40946         this_ptr_conv.is_owned = false;
40947         void* val_ptr = untag_ptr(val);
40948         CHECK_ACCESS(val_ptr);
40949         LDKRoutingMessageHandler val_conv = *(LDKRoutingMessageHandler*)(val_ptr);
40950         if (val_conv.free == LDKRoutingMessageHandler_JCalls_free) {
40951                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
40952                 LDKRoutingMessageHandler_JCalls_cloned(&val_conv);
40953         }
40954         MessageHandler_set_route_handler(&this_ptr_conv, val_conv);
40955 }
40956
40957 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageHandler_1get_1onion_1message_1handler(JNIEnv *env, jclass clz, int64_t this_ptr) {
40958         LDKMessageHandler this_ptr_conv;
40959         this_ptr_conv.inner = untag_ptr(this_ptr);
40960         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40961         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40962         this_ptr_conv.is_owned = false;
40963         // WARNING: This object doesn't live past this scope, needs clone!
40964         int64_t ret_ret = tag_ptr(MessageHandler_get_onion_message_handler(&this_ptr_conv), false);
40965         return ret_ret;
40966 }
40967
40968 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageHandler_1set_1onion_1message_1handler(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
40969         LDKMessageHandler this_ptr_conv;
40970         this_ptr_conv.inner = untag_ptr(this_ptr);
40971         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
40972         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
40973         this_ptr_conv.is_owned = false;
40974         void* val_ptr = untag_ptr(val);
40975         CHECK_ACCESS(val_ptr);
40976         LDKOnionMessageHandler val_conv = *(LDKOnionMessageHandler*)(val_ptr);
40977         if (val_conv.free == LDKOnionMessageHandler_JCalls_free) {
40978                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
40979                 LDKOnionMessageHandler_JCalls_cloned(&val_conv);
40980         }
40981         MessageHandler_set_onion_message_handler(&this_ptr_conv, val_conv);
40982 }
40983
40984 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) {
40985         void* chan_handler_arg_ptr = untag_ptr(chan_handler_arg);
40986         CHECK_ACCESS(chan_handler_arg_ptr);
40987         LDKChannelMessageHandler chan_handler_arg_conv = *(LDKChannelMessageHandler*)(chan_handler_arg_ptr);
40988         if (chan_handler_arg_conv.free == LDKChannelMessageHandler_JCalls_free) {
40989                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
40990                 LDKChannelMessageHandler_JCalls_cloned(&chan_handler_arg_conv);
40991         }
40992         void* route_handler_arg_ptr = untag_ptr(route_handler_arg);
40993         CHECK_ACCESS(route_handler_arg_ptr);
40994         LDKRoutingMessageHandler route_handler_arg_conv = *(LDKRoutingMessageHandler*)(route_handler_arg_ptr);
40995         if (route_handler_arg_conv.free == LDKRoutingMessageHandler_JCalls_free) {
40996                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
40997                 LDKRoutingMessageHandler_JCalls_cloned(&route_handler_arg_conv);
40998         }
40999         void* onion_message_handler_arg_ptr = untag_ptr(onion_message_handler_arg);
41000         CHECK_ACCESS(onion_message_handler_arg_ptr);
41001         LDKOnionMessageHandler onion_message_handler_arg_conv = *(LDKOnionMessageHandler*)(onion_message_handler_arg_ptr);
41002         if (onion_message_handler_arg_conv.free == LDKOnionMessageHandler_JCalls_free) {
41003                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
41004                 LDKOnionMessageHandler_JCalls_cloned(&onion_message_handler_arg_conv);
41005         }
41006         LDKMessageHandler ret_var = MessageHandler_new(chan_handler_arg_conv, route_handler_arg_conv, onion_message_handler_arg_conv);
41007         int64_t ret_ref = 0;
41008         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41009         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
41010         return ret_ref;
41011 }
41012
41013 static inline uint64_t SocketDescriptor_clone_ptr(LDKSocketDescriptor *NONNULL_PTR arg) {
41014         LDKSocketDescriptor* ret_ret = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
41015         *ret_ret = SocketDescriptor_clone(arg);
41016         return tag_ptr(ret_ret, true);
41017 }
41018 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
41019         void* arg_ptr = untag_ptr(arg);
41020         if (ptr_is_owned(arg)) { CHECK_ACCESS(arg_ptr); }
41021         LDKSocketDescriptor* arg_conv = (LDKSocketDescriptor*)arg_ptr;
41022         int64_t ret_conv = SocketDescriptor_clone_ptr(arg_conv);
41023         return ret_conv;
41024 }
41025
41026 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
41027         void* orig_ptr = untag_ptr(orig);
41028         if (ptr_is_owned(orig)) { CHECK_ACCESS(orig_ptr); }
41029         LDKSocketDescriptor* orig_conv = (LDKSocketDescriptor*)orig_ptr;
41030         LDKSocketDescriptor* ret_ret = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
41031         *ret_ret = SocketDescriptor_clone(orig_conv);
41032         return tag_ptr(ret_ret, true);
41033 }
41034
41035 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
41036         if (!ptr_is_owned(this_ptr)) return;
41037         void* this_ptr_ptr = untag_ptr(this_ptr);
41038         CHECK_ACCESS(this_ptr_ptr);
41039         LDKSocketDescriptor this_ptr_conv = *(LDKSocketDescriptor*)(this_ptr_ptr);
41040         FREE(untag_ptr(this_ptr));
41041         SocketDescriptor_free(this_ptr_conv);
41042 }
41043
41044 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
41045         LDKPeerHandleError this_obj_conv;
41046         this_obj_conv.inner = untag_ptr(this_obj);
41047         this_obj_conv.is_owned = ptr_is_owned(this_obj);
41048         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
41049         PeerHandleError_free(this_obj_conv);
41050 }
41051
41052 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1get_1no_1connection_1possible(JNIEnv *env, jclass clz, int64_t this_ptr) {
41053         LDKPeerHandleError this_ptr_conv;
41054         this_ptr_conv.inner = untag_ptr(this_ptr);
41055         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41056         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41057         this_ptr_conv.is_owned = false;
41058         jboolean ret_conv = PeerHandleError_get_no_connection_possible(&this_ptr_conv);
41059         return ret_conv;
41060 }
41061
41062 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1set_1no_1connection_1possible(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
41063         LDKPeerHandleError this_ptr_conv;
41064         this_ptr_conv.inner = untag_ptr(this_ptr);
41065         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41066         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41067         this_ptr_conv.is_owned = false;
41068         PeerHandleError_set_no_connection_possible(&this_ptr_conv, val);
41069 }
41070
41071 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1new(JNIEnv *env, jclass clz, jboolean no_connection_possible_arg) {
41072         LDKPeerHandleError ret_var = PeerHandleError_new(no_connection_possible_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
41079 static inline uint64_t PeerHandleError_clone_ptr(LDKPeerHandleError *NONNULL_PTR arg) {
41080         LDKPeerHandleError ret_var = PeerHandleError_clone(arg);
41081         int64_t ret_ref = 0;
41082         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41083         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
41084         return ret_ref;
41085 }
41086 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
41087         LDKPeerHandleError arg_conv;
41088         arg_conv.inner = untag_ptr(arg);
41089         arg_conv.is_owned = ptr_is_owned(arg);
41090         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
41091         arg_conv.is_owned = false;
41092         int64_t ret_conv = PeerHandleError_clone_ptr(&arg_conv);
41093         return ret_conv;
41094 }
41095
41096 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
41097         LDKPeerHandleError orig_conv;
41098         orig_conv.inner = untag_ptr(orig);
41099         orig_conv.is_owned = ptr_is_owned(orig);
41100         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
41101         orig_conv.is_owned = false;
41102         LDKPeerHandleError ret_var = PeerHandleError_clone(&orig_conv);
41103         int64_t ret_ref = 0;
41104         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41105         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
41106         return ret_ref;
41107 }
41108
41109 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
41110         LDKPeerManager this_obj_conv;
41111         this_obj_conv.inner = untag_ptr(this_obj);
41112         this_obj_conv.is_owned = ptr_is_owned(this_obj);
41113         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
41114         PeerManager_free(this_obj_conv);
41115 }
41116
41117 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) {
41118         LDKMessageHandler message_handler_conv;
41119         message_handler_conv.inner = untag_ptr(message_handler);
41120         message_handler_conv.is_owned = ptr_is_owned(message_handler);
41121         CHECK_INNER_FIELD_ACCESS_OR_NULL(message_handler_conv);
41122         // WARNING: we need a move here but no clone is available for LDKMessageHandler
41123         
41124         LDKSecretKey our_node_secret_ref;
41125         CHECK((*env)->GetArrayLength(env, our_node_secret) == 32);
41126         (*env)->GetByteArrayRegion(env, our_node_secret, 0, 32, our_node_secret_ref.bytes);
41127         unsigned char ephemeral_random_data_arr[32];
41128         CHECK((*env)->GetArrayLength(env, ephemeral_random_data) == 32);
41129         (*env)->GetByteArrayRegion(env, ephemeral_random_data, 0, 32, ephemeral_random_data_arr);
41130         unsigned char (*ephemeral_random_data_ref)[32] = &ephemeral_random_data_arr;
41131         void* logger_ptr = untag_ptr(logger);
41132         CHECK_ACCESS(logger_ptr);
41133         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
41134         if (logger_conv.free == LDKLogger_JCalls_free) {
41135                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
41136                 LDKLogger_JCalls_cloned(&logger_conv);
41137         }
41138         void* custom_message_handler_ptr = untag_ptr(custom_message_handler);
41139         CHECK_ACCESS(custom_message_handler_ptr);
41140         LDKCustomMessageHandler custom_message_handler_conv = *(LDKCustomMessageHandler*)(custom_message_handler_ptr);
41141         if (custom_message_handler_conv.free == LDKCustomMessageHandler_JCalls_free) {
41142                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
41143                 LDKCustomMessageHandler_JCalls_cloned(&custom_message_handler_conv);
41144         }
41145         LDKPeerManager ret_var = PeerManager_new(message_handler_conv, our_node_secret_ref, current_time, ephemeral_random_data_ref, logger_conv, custom_message_handler_conv);
41146         int64_t ret_ref = 0;
41147         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41148         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
41149         return ret_ref;
41150 }
41151
41152 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_PeerManager_1get_1peer_1node_1ids(JNIEnv *env, jclass clz, int64_t this_arg) {
41153         LDKPeerManager this_arg_conv;
41154         this_arg_conv.inner = untag_ptr(this_arg);
41155         this_arg_conv.is_owned = ptr_is_owned(this_arg);
41156         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41157         this_arg_conv.is_owned = false;
41158         LDKCVec_PublicKeyZ ret_var = PeerManager_get_peer_node_ids(&this_arg_conv);
41159         jobjectArray ret_arr = NULL;
41160         ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
41161         ;
41162         for (size_t i = 0; i < ret_var.datalen; i++) {
41163                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, 33);
41164                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, 33, ret_var.data[i].compressed_form);
41165                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
41166         }
41167         
41168         FREE(ret_var.data);
41169         return ret_arr;
41170 }
41171
41172 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) {
41173         LDKPeerManager this_arg_conv;
41174         this_arg_conv.inner = untag_ptr(this_arg);
41175         this_arg_conv.is_owned = ptr_is_owned(this_arg);
41176         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41177         this_arg_conv.is_owned = false;
41178         LDKPublicKey their_node_id_ref;
41179         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
41180         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
41181         void* descriptor_ptr = untag_ptr(descriptor);
41182         CHECK_ACCESS(descriptor_ptr);
41183         LDKSocketDescriptor descriptor_conv = *(LDKSocketDescriptor*)(descriptor_ptr);
41184         if (descriptor_conv.free == LDKSocketDescriptor_JCalls_free) {
41185                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
41186                 LDKSocketDescriptor_JCalls_cloned(&descriptor_conv);
41187         }
41188         void* remote_network_address_ptr = untag_ptr(remote_network_address);
41189         CHECK_ACCESS(remote_network_address_ptr);
41190         LDKCOption_NetAddressZ remote_network_address_conv = *(LDKCOption_NetAddressZ*)(remote_network_address_ptr);
41191         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
41192         *ret_conv = PeerManager_new_outbound_connection(&this_arg_conv, their_node_id_ref, descriptor_conv, remote_network_address_conv);
41193         return tag_ptr(ret_conv, true);
41194 }
41195
41196 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) {
41197         LDKPeerManager this_arg_conv;
41198         this_arg_conv.inner = untag_ptr(this_arg);
41199         this_arg_conv.is_owned = ptr_is_owned(this_arg);
41200         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41201         this_arg_conv.is_owned = false;
41202         void* descriptor_ptr = untag_ptr(descriptor);
41203         CHECK_ACCESS(descriptor_ptr);
41204         LDKSocketDescriptor descriptor_conv = *(LDKSocketDescriptor*)(descriptor_ptr);
41205         if (descriptor_conv.free == LDKSocketDescriptor_JCalls_free) {
41206                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
41207                 LDKSocketDescriptor_JCalls_cloned(&descriptor_conv);
41208         }
41209         void* remote_network_address_ptr = untag_ptr(remote_network_address);
41210         CHECK_ACCESS(remote_network_address_ptr);
41211         LDKCOption_NetAddressZ remote_network_address_conv = *(LDKCOption_NetAddressZ*)(remote_network_address_ptr);
41212         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
41213         *ret_conv = PeerManager_new_inbound_connection(&this_arg_conv, descriptor_conv, remote_network_address_conv);
41214         return tag_ptr(ret_conv, true);
41215 }
41216
41217 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) {
41218         LDKPeerManager this_arg_conv;
41219         this_arg_conv.inner = untag_ptr(this_arg);
41220         this_arg_conv.is_owned = ptr_is_owned(this_arg);
41221         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41222         this_arg_conv.is_owned = false;
41223         void* descriptor_ptr = untag_ptr(descriptor);
41224         if (ptr_is_owned(descriptor)) { CHECK_ACCESS(descriptor_ptr); }
41225         LDKSocketDescriptor* descriptor_conv = (LDKSocketDescriptor*)descriptor_ptr;
41226         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
41227         *ret_conv = PeerManager_write_buffer_space_avail(&this_arg_conv, descriptor_conv);
41228         return tag_ptr(ret_conv, true);
41229 }
41230
41231 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) {
41232         LDKPeerManager this_arg_conv;
41233         this_arg_conv.inner = untag_ptr(this_arg);
41234         this_arg_conv.is_owned = ptr_is_owned(this_arg);
41235         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41236         this_arg_conv.is_owned = false;
41237         void* peer_descriptor_ptr = untag_ptr(peer_descriptor);
41238         if (ptr_is_owned(peer_descriptor)) { CHECK_ACCESS(peer_descriptor_ptr); }
41239         LDKSocketDescriptor* peer_descriptor_conv = (LDKSocketDescriptor*)peer_descriptor_ptr;
41240         LDKu8slice data_ref;
41241         data_ref.datalen = (*env)->GetArrayLength(env, data);
41242         data_ref.data = (*env)->GetByteArrayElements (env, data, NULL);
41243         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
41244         *ret_conv = PeerManager_read_event(&this_arg_conv, peer_descriptor_conv, data_ref);
41245         (*env)->ReleaseByteArrayElements(env, data, (int8_t*)data_ref.data, 0);
41246         return tag_ptr(ret_conv, true);
41247 }
41248
41249 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1process_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
41250         LDKPeerManager this_arg_conv;
41251         this_arg_conv.inner = untag_ptr(this_arg);
41252         this_arg_conv.is_owned = ptr_is_owned(this_arg);
41253         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41254         this_arg_conv.is_owned = false;
41255         PeerManager_process_events(&this_arg_conv);
41256 }
41257
41258 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1socket_1disconnected(JNIEnv *env, jclass clz, int64_t this_arg, int64_t descriptor) {
41259         LDKPeerManager this_arg_conv;
41260         this_arg_conv.inner = untag_ptr(this_arg);
41261         this_arg_conv.is_owned = ptr_is_owned(this_arg);
41262         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41263         this_arg_conv.is_owned = false;
41264         void* descriptor_ptr = untag_ptr(descriptor);
41265         if (ptr_is_owned(descriptor)) { CHECK_ACCESS(descriptor_ptr); }
41266         LDKSocketDescriptor* descriptor_conv = (LDKSocketDescriptor*)descriptor_ptr;
41267         PeerManager_socket_disconnected(&this_arg_conv, descriptor_conv);
41268 }
41269
41270 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) {
41271         LDKPeerManager this_arg_conv;
41272         this_arg_conv.inner = untag_ptr(this_arg);
41273         this_arg_conv.is_owned = ptr_is_owned(this_arg);
41274         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41275         this_arg_conv.is_owned = false;
41276         LDKPublicKey node_id_ref;
41277         CHECK((*env)->GetArrayLength(env, node_id) == 33);
41278         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
41279         PeerManager_disconnect_by_node_id(&this_arg_conv, node_id_ref, no_connection_possible);
41280 }
41281
41282 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1disconnect_1all_1peers(JNIEnv *env, jclass clz, int64_t this_arg) {
41283         LDKPeerManager this_arg_conv;
41284         this_arg_conv.inner = untag_ptr(this_arg);
41285         this_arg_conv.is_owned = ptr_is_owned(this_arg);
41286         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41287         this_arg_conv.is_owned = false;
41288         PeerManager_disconnect_all_peers(&this_arg_conv);
41289 }
41290
41291 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1timer_1tick_1occurred(JNIEnv *env, jclass clz, int64_t this_arg) {
41292         LDKPeerManager this_arg_conv;
41293         this_arg_conv.inner = untag_ptr(this_arg);
41294         this_arg_conv.is_owned = ptr_is_owned(this_arg);
41295         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41296         this_arg_conv.is_owned = false;
41297         PeerManager_timer_tick_occurred(&this_arg_conv);
41298 }
41299
41300 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) {
41301         LDKPeerManager this_arg_conv;
41302         this_arg_conv.inner = untag_ptr(this_arg);
41303         this_arg_conv.is_owned = ptr_is_owned(this_arg);
41304         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41305         this_arg_conv.is_owned = false;
41306         LDKThreeBytes rgb_ref;
41307         CHECK((*env)->GetArrayLength(env, rgb) == 3);
41308         (*env)->GetByteArrayRegion(env, rgb, 0, 3, rgb_ref.data);
41309         LDKThirtyTwoBytes alias_ref;
41310         CHECK((*env)->GetArrayLength(env, alias) == 32);
41311         (*env)->GetByteArrayRegion(env, alias, 0, 32, alias_ref.data);
41312         LDKCVec_NetAddressZ addresses_constr;
41313         addresses_constr.datalen = (*env)->GetArrayLength(env, addresses);
41314         if (addresses_constr.datalen > 0)
41315                 addresses_constr.data = MALLOC(addresses_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
41316         else
41317                 addresses_constr.data = NULL;
41318         int64_t* addresses_vals = (*env)->GetLongArrayElements (env, addresses, NULL);
41319         for (size_t m = 0; m < addresses_constr.datalen; m++) {
41320                 int64_t addresses_conv_12 = addresses_vals[m];
41321                 void* addresses_conv_12_ptr = untag_ptr(addresses_conv_12);
41322                 CHECK_ACCESS(addresses_conv_12_ptr);
41323                 LDKNetAddress addresses_conv_12_conv = *(LDKNetAddress*)(addresses_conv_12_ptr);
41324                 addresses_constr.data[m] = addresses_conv_12_conv;
41325         }
41326         (*env)->ReleaseLongArrayElements(env, addresses, addresses_vals, 0);
41327         PeerManager_broadcast_node_announcement(&this_arg_conv, rgb_ref, alias_ref, addresses_constr);
41328 }
41329
41330 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_htlc_1success_1tx_1weight(JNIEnv *env, jclass clz, jboolean opt_anchors) {
41331         int64_t ret_conv = htlc_success_tx_weight(opt_anchors);
41332         return ret_conv;
41333 }
41334
41335 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_htlc_1timeout_1tx_1weight(JNIEnv *env, jclass clz, jboolean opt_anchors) {
41336         int64_t ret_conv = htlc_timeout_tx_weight(opt_anchors);
41337         return ret_conv;
41338 }
41339
41340 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_HTLCClaim_1clone(JNIEnv *env, jclass clz, int64_t orig) {
41341         LDKHTLCClaim* orig_conv = (LDKHTLCClaim*)untag_ptr(orig);
41342         jclass ret_conv = LDKHTLCClaim_to_java(env, HTLCClaim_clone(orig_conv));
41343         return ret_conv;
41344 }
41345
41346 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_HTLCClaim_1offered_1timeout(JNIEnv *env, jclass clz) {
41347         jclass ret_conv = LDKHTLCClaim_to_java(env, HTLCClaim_offered_timeout());
41348         return ret_conv;
41349 }
41350
41351 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_HTLCClaim_1offered_1preimage(JNIEnv *env, jclass clz) {
41352         jclass ret_conv = LDKHTLCClaim_to_java(env, HTLCClaim_offered_preimage());
41353         return ret_conv;
41354 }
41355
41356 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_HTLCClaim_1accepted_1timeout(JNIEnv *env, jclass clz) {
41357         jclass ret_conv = LDKHTLCClaim_to_java(env, HTLCClaim_accepted_timeout());
41358         return ret_conv;
41359 }
41360
41361 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_HTLCClaim_1accepted_1preimage(JNIEnv *env, jclass clz) {
41362         jclass ret_conv = LDKHTLCClaim_to_java(env, HTLCClaim_accepted_preimage());
41363         return ret_conv;
41364 }
41365
41366 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_HTLCClaim_1revocation(JNIEnv *env, jclass clz) {
41367         jclass ret_conv = LDKHTLCClaim_to_java(env, HTLCClaim_revocation());
41368         return ret_conv;
41369 }
41370
41371 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_HTLCClaim_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
41372         LDKHTLCClaim* a_conv = (LDKHTLCClaim*)untag_ptr(a);
41373         LDKHTLCClaim* b_conv = (LDKHTLCClaim*)untag_ptr(b);
41374         jboolean ret_conv = HTLCClaim_eq(a_conv, b_conv);
41375         return ret_conv;
41376 }
41377
41378 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCClaim_1from_1witness(JNIEnv *env, jclass clz, int8_tArray witness) {
41379         LDKWitness witness_ref;
41380         witness_ref.datalen = (*env)->GetArrayLength(env, witness);
41381         witness_ref.data = MALLOC(witness_ref.datalen, "LDKWitness Bytes");
41382         (*env)->GetByteArrayRegion(env, witness, 0, witness_ref.datalen, witness_ref.data);
41383         witness_ref.data_is_owned = true;
41384         LDKCOption_HTLCClaimZ *ret_copy = MALLOC(sizeof(LDKCOption_HTLCClaimZ), "LDKCOption_HTLCClaimZ");
41385         *ret_copy = HTLCClaim_from_witness(witness_ref);
41386         int64_t ret_ref = tag_ptr(ret_copy, true);
41387         return ret_ref;
41388 }
41389
41390 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_build_1commitment_1secret(JNIEnv *env, jclass clz, int8_tArray commitment_seed, int64_t idx) {
41391         unsigned char commitment_seed_arr[32];
41392         CHECK((*env)->GetArrayLength(env, commitment_seed) == 32);
41393         (*env)->GetByteArrayRegion(env, commitment_seed, 0, 32, commitment_seed_arr);
41394         unsigned char (*commitment_seed_ref)[32] = &commitment_seed_arr;
41395         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
41396         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, build_commitment_secret(commitment_seed_ref, idx).data);
41397         return ret_arr;
41398 }
41399
41400 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) {
41401         LDKCVec_u8Z to_holder_script_ref;
41402         to_holder_script_ref.datalen = (*env)->GetArrayLength(env, to_holder_script);
41403         to_holder_script_ref.data = MALLOC(to_holder_script_ref.datalen, "LDKCVec_u8Z Bytes");
41404         (*env)->GetByteArrayRegion(env, to_holder_script, 0, to_holder_script_ref.datalen, to_holder_script_ref.data);
41405         LDKCVec_u8Z to_counterparty_script_ref;
41406         to_counterparty_script_ref.datalen = (*env)->GetArrayLength(env, to_counterparty_script);
41407         to_counterparty_script_ref.data = MALLOC(to_counterparty_script_ref.datalen, "LDKCVec_u8Z Bytes");
41408         (*env)->GetByteArrayRegion(env, to_counterparty_script, 0, to_counterparty_script_ref.datalen, to_counterparty_script_ref.data);
41409         LDKOutPoint funding_outpoint_conv;
41410         funding_outpoint_conv.inner = untag_ptr(funding_outpoint);
41411         funding_outpoint_conv.is_owned = ptr_is_owned(funding_outpoint);
41412         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_outpoint_conv);
41413         funding_outpoint_conv = OutPoint_clone(&funding_outpoint_conv);
41414         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);
41415         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
41416         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
41417         Transaction_free(ret_var);
41418         return ret_arr;
41419 }
41420
41421 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyCommitmentSecrets_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
41422         LDKCounterpartyCommitmentSecrets this_obj_conv;
41423         this_obj_conv.inner = untag_ptr(this_obj);
41424         this_obj_conv.is_owned = ptr_is_owned(this_obj);
41425         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
41426         CounterpartyCommitmentSecrets_free(this_obj_conv);
41427 }
41428
41429 static inline uint64_t CounterpartyCommitmentSecrets_clone_ptr(LDKCounterpartyCommitmentSecrets *NONNULL_PTR arg) {
41430         LDKCounterpartyCommitmentSecrets ret_var = CounterpartyCommitmentSecrets_clone(arg);
41431         int64_t ret_ref = 0;
41432         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41433         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
41434         return ret_ref;
41435 }
41436 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyCommitmentSecrets_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
41437         LDKCounterpartyCommitmentSecrets arg_conv;
41438         arg_conv.inner = untag_ptr(arg);
41439         arg_conv.is_owned = ptr_is_owned(arg);
41440         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
41441         arg_conv.is_owned = false;
41442         int64_t ret_conv = CounterpartyCommitmentSecrets_clone_ptr(&arg_conv);
41443         return ret_conv;
41444 }
41445
41446 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyCommitmentSecrets_1clone(JNIEnv *env, jclass clz, int64_t orig) {
41447         LDKCounterpartyCommitmentSecrets orig_conv;
41448         orig_conv.inner = untag_ptr(orig);
41449         orig_conv.is_owned = ptr_is_owned(orig);
41450         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
41451         orig_conv.is_owned = false;
41452         LDKCounterpartyCommitmentSecrets ret_var = CounterpartyCommitmentSecrets_clone(&orig_conv);
41453         int64_t ret_ref = 0;
41454         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41455         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
41456         return ret_ref;
41457 }
41458
41459 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyCommitmentSecrets_1new(JNIEnv *env, jclass clz) {
41460         LDKCounterpartyCommitmentSecrets ret_var = CounterpartyCommitmentSecrets_new();
41461         int64_t ret_ref = 0;
41462         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41463         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
41464         return ret_ref;
41465 }
41466
41467 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyCommitmentSecrets_1get_1min_1seen_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
41468         LDKCounterpartyCommitmentSecrets this_arg_conv;
41469         this_arg_conv.inner = untag_ptr(this_arg);
41470         this_arg_conv.is_owned = ptr_is_owned(this_arg);
41471         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41472         this_arg_conv.is_owned = false;
41473         int64_t ret_conv = CounterpartyCommitmentSecrets_get_min_seen_secret(&this_arg_conv);
41474         return ret_conv;
41475 }
41476
41477 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) {
41478         LDKCounterpartyCommitmentSecrets this_arg_conv;
41479         this_arg_conv.inner = untag_ptr(this_arg);
41480         this_arg_conv.is_owned = ptr_is_owned(this_arg);
41481         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41482         this_arg_conv.is_owned = false;
41483         LDKThirtyTwoBytes secret_ref;
41484         CHECK((*env)->GetArrayLength(env, secret) == 32);
41485         (*env)->GetByteArrayRegion(env, secret, 0, 32, secret_ref.data);
41486         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
41487         *ret_conv = CounterpartyCommitmentSecrets_provide_secret(&this_arg_conv, idx, secret_ref);
41488         return tag_ptr(ret_conv, true);
41489 }
41490
41491 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CounterpartyCommitmentSecrets_1get_1secret(JNIEnv *env, jclass clz, int64_t this_arg, int64_t idx) {
41492         LDKCounterpartyCommitmentSecrets this_arg_conv;
41493         this_arg_conv.inner = untag_ptr(this_arg);
41494         this_arg_conv.is_owned = ptr_is_owned(this_arg);
41495         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
41496         this_arg_conv.is_owned = false;
41497         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
41498         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, CounterpartyCommitmentSecrets_get_secret(&this_arg_conv, idx).data);
41499         return ret_arr;
41500 }
41501
41502 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CounterpartyCommitmentSecrets_1write(JNIEnv *env, jclass clz, int64_t obj) {
41503         LDKCounterpartyCommitmentSecrets obj_conv;
41504         obj_conv.inner = untag_ptr(obj);
41505         obj_conv.is_owned = ptr_is_owned(obj);
41506         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
41507         obj_conv.is_owned = false;
41508         LDKCVec_u8Z ret_var = CounterpartyCommitmentSecrets_write(&obj_conv);
41509         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
41510         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
41511         CVec_u8Z_free(ret_var);
41512         return ret_arr;
41513 }
41514
41515 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyCommitmentSecrets_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
41516         LDKu8slice ser_ref;
41517         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
41518         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
41519         LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ), "LDKCResult_CounterpartyCommitmentSecretsDecodeErrorZ");
41520         *ret_conv = CounterpartyCommitmentSecrets_read(ser_ref);
41521         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
41522         return tag_ptr(ret_conv, true);
41523 }
41524
41525 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_derive_1private_1key(JNIEnv *env, jclass clz, int8_tArray per_commitment_point, int8_tArray base_secret) {
41526         LDKPublicKey per_commitment_point_ref;
41527         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
41528         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
41529         unsigned char base_secret_arr[32];
41530         CHECK((*env)->GetArrayLength(env, base_secret) == 32);
41531         (*env)->GetByteArrayRegion(env, base_secret, 0, 32, base_secret_arr);
41532         unsigned char (*base_secret_ref)[32] = &base_secret_arr;
41533         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
41534         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, derive_private_key(per_commitment_point_ref, base_secret_ref).bytes);
41535         return ret_arr;
41536 }
41537
41538 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_derive_1public_1key(JNIEnv *env, jclass clz, int8_tArray per_commitment_point, int8_tArray base_point) {
41539         LDKPublicKey per_commitment_point_ref;
41540         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
41541         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
41542         LDKPublicKey base_point_ref;
41543         CHECK((*env)->GetArrayLength(env, base_point) == 33);
41544         (*env)->GetByteArrayRegion(env, base_point, 0, 33, base_point_ref.compressed_form);
41545         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
41546         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, derive_public_key(per_commitment_point_ref, base_point_ref).compressed_form);
41547         return ret_arr;
41548 }
41549
41550 JNIEXPORT int8_tArray 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) {
41551         unsigned char per_commitment_secret_arr[32];
41552         CHECK((*env)->GetArrayLength(env, per_commitment_secret) == 32);
41553         (*env)->GetByteArrayRegion(env, per_commitment_secret, 0, 32, per_commitment_secret_arr);
41554         unsigned char (*per_commitment_secret_ref)[32] = &per_commitment_secret_arr;
41555         unsigned char countersignatory_revocation_base_secret_arr[32];
41556         CHECK((*env)->GetArrayLength(env, countersignatory_revocation_base_secret) == 32);
41557         (*env)->GetByteArrayRegion(env, countersignatory_revocation_base_secret, 0, 32, countersignatory_revocation_base_secret_arr);
41558         unsigned char (*countersignatory_revocation_base_secret_ref)[32] = &countersignatory_revocation_base_secret_arr;
41559         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
41560         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, derive_private_revocation_key(per_commitment_secret_ref, countersignatory_revocation_base_secret_ref).bytes);
41561         return ret_arr;
41562 }
41563
41564 JNIEXPORT int8_tArray 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) {
41565         LDKPublicKey per_commitment_point_ref;
41566         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
41567         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
41568         LDKPublicKey countersignatory_revocation_base_point_ref;
41569         CHECK((*env)->GetArrayLength(env, countersignatory_revocation_base_point) == 33);
41570         (*env)->GetByteArrayRegion(env, countersignatory_revocation_base_point, 0, 33, countersignatory_revocation_base_point_ref.compressed_form);
41571         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
41572         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, derive_public_revocation_key(per_commitment_point_ref, countersignatory_revocation_base_point_ref).compressed_form);
41573         return ret_arr;
41574 }
41575
41576 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
41577         LDKTxCreationKeys this_obj_conv;
41578         this_obj_conv.inner = untag_ptr(this_obj);
41579         this_obj_conv.is_owned = ptr_is_owned(this_obj);
41580         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
41581         TxCreationKeys_free(this_obj_conv);
41582 }
41583
41584 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
41585         LDKTxCreationKeys this_ptr_conv;
41586         this_ptr_conv.inner = untag_ptr(this_ptr);
41587         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41588         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41589         this_ptr_conv.is_owned = false;
41590         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
41591         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_per_commitment_point(&this_ptr_conv).compressed_form);
41592         return ret_arr;
41593 }
41594
41595 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
41596         LDKTxCreationKeys this_ptr_conv;
41597         this_ptr_conv.inner = untag_ptr(this_ptr);
41598         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41599         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41600         this_ptr_conv.is_owned = false;
41601         LDKPublicKey val_ref;
41602         CHECK((*env)->GetArrayLength(env, val) == 33);
41603         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
41604         TxCreationKeys_set_per_commitment_point(&this_ptr_conv, val_ref);
41605 }
41606
41607 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1revocation_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
41608         LDKTxCreationKeys this_ptr_conv;
41609         this_ptr_conv.inner = untag_ptr(this_ptr);
41610         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41611         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41612         this_ptr_conv.is_owned = false;
41613         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
41614         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_revocation_key(&this_ptr_conv).compressed_form);
41615         return ret_arr;
41616 }
41617
41618 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1revocation_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
41619         LDKTxCreationKeys this_ptr_conv;
41620         this_ptr_conv.inner = untag_ptr(this_ptr);
41621         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41622         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41623         this_ptr_conv.is_owned = false;
41624         LDKPublicKey val_ref;
41625         CHECK((*env)->GetArrayLength(env, val) == 33);
41626         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
41627         TxCreationKeys_set_revocation_key(&this_ptr_conv, val_ref);
41628 }
41629
41630 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1broadcaster_1htlc_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
41631         LDKTxCreationKeys this_ptr_conv;
41632         this_ptr_conv.inner = untag_ptr(this_ptr);
41633         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41634         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41635         this_ptr_conv.is_owned = false;
41636         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
41637         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_broadcaster_htlc_key(&this_ptr_conv).compressed_form);
41638         return ret_arr;
41639 }
41640
41641 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1broadcaster_1htlc_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
41642         LDKTxCreationKeys this_ptr_conv;
41643         this_ptr_conv.inner = untag_ptr(this_ptr);
41644         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41645         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41646         this_ptr_conv.is_owned = false;
41647         LDKPublicKey val_ref;
41648         CHECK((*env)->GetArrayLength(env, val) == 33);
41649         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
41650         TxCreationKeys_set_broadcaster_htlc_key(&this_ptr_conv, val_ref);
41651 }
41652
41653 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1countersignatory_1htlc_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
41654         LDKTxCreationKeys this_ptr_conv;
41655         this_ptr_conv.inner = untag_ptr(this_ptr);
41656         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41657         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41658         this_ptr_conv.is_owned = false;
41659         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
41660         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_countersignatory_htlc_key(&this_ptr_conv).compressed_form);
41661         return ret_arr;
41662 }
41663
41664 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1countersignatory_1htlc_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
41665         LDKTxCreationKeys this_ptr_conv;
41666         this_ptr_conv.inner = untag_ptr(this_ptr);
41667         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41668         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41669         this_ptr_conv.is_owned = false;
41670         LDKPublicKey val_ref;
41671         CHECK((*env)->GetArrayLength(env, val) == 33);
41672         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
41673         TxCreationKeys_set_countersignatory_htlc_key(&this_ptr_conv, val_ref);
41674 }
41675
41676 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1broadcaster_1delayed_1payment_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
41677         LDKTxCreationKeys this_ptr_conv;
41678         this_ptr_conv.inner = untag_ptr(this_ptr);
41679         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41680         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41681         this_ptr_conv.is_owned = false;
41682         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
41683         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_broadcaster_delayed_payment_key(&this_ptr_conv).compressed_form);
41684         return ret_arr;
41685 }
41686
41687 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) {
41688         LDKTxCreationKeys this_ptr_conv;
41689         this_ptr_conv.inner = untag_ptr(this_ptr);
41690         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41691         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41692         this_ptr_conv.is_owned = false;
41693         LDKPublicKey val_ref;
41694         CHECK((*env)->GetArrayLength(env, val) == 33);
41695         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
41696         TxCreationKeys_set_broadcaster_delayed_payment_key(&this_ptr_conv, val_ref);
41697 }
41698
41699 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) {
41700         LDKPublicKey per_commitment_point_arg_ref;
41701         CHECK((*env)->GetArrayLength(env, per_commitment_point_arg) == 33);
41702         (*env)->GetByteArrayRegion(env, per_commitment_point_arg, 0, 33, per_commitment_point_arg_ref.compressed_form);
41703         LDKPublicKey revocation_key_arg_ref;
41704         CHECK((*env)->GetArrayLength(env, revocation_key_arg) == 33);
41705         (*env)->GetByteArrayRegion(env, revocation_key_arg, 0, 33, revocation_key_arg_ref.compressed_form);
41706         LDKPublicKey broadcaster_htlc_key_arg_ref;
41707         CHECK((*env)->GetArrayLength(env, broadcaster_htlc_key_arg) == 33);
41708         (*env)->GetByteArrayRegion(env, broadcaster_htlc_key_arg, 0, 33, broadcaster_htlc_key_arg_ref.compressed_form);
41709         LDKPublicKey countersignatory_htlc_key_arg_ref;
41710         CHECK((*env)->GetArrayLength(env, countersignatory_htlc_key_arg) == 33);
41711         (*env)->GetByteArrayRegion(env, countersignatory_htlc_key_arg, 0, 33, countersignatory_htlc_key_arg_ref.compressed_form);
41712         LDKPublicKey broadcaster_delayed_payment_key_arg_ref;
41713         CHECK((*env)->GetArrayLength(env, broadcaster_delayed_payment_key_arg) == 33);
41714         (*env)->GetByteArrayRegion(env, broadcaster_delayed_payment_key_arg, 0, 33, broadcaster_delayed_payment_key_arg_ref.compressed_form);
41715         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);
41716         int64_t ret_ref = 0;
41717         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41718         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
41719         return ret_ref;
41720 }
41721
41722 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
41723         LDKTxCreationKeys a_conv;
41724         a_conv.inner = untag_ptr(a);
41725         a_conv.is_owned = ptr_is_owned(a);
41726         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
41727         a_conv.is_owned = false;
41728         LDKTxCreationKeys b_conv;
41729         b_conv.inner = untag_ptr(b);
41730         b_conv.is_owned = ptr_is_owned(b);
41731         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
41732         b_conv.is_owned = false;
41733         jboolean ret_conv = TxCreationKeys_eq(&a_conv, &b_conv);
41734         return ret_conv;
41735 }
41736
41737 static inline uint64_t TxCreationKeys_clone_ptr(LDKTxCreationKeys *NONNULL_PTR arg) {
41738         LDKTxCreationKeys ret_var = TxCreationKeys_clone(arg);
41739         int64_t ret_ref = 0;
41740         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41741         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
41742         return ret_ref;
41743 }
41744 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
41745         LDKTxCreationKeys arg_conv;
41746         arg_conv.inner = untag_ptr(arg);
41747         arg_conv.is_owned = ptr_is_owned(arg);
41748         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
41749         arg_conv.is_owned = false;
41750         int64_t ret_conv = TxCreationKeys_clone_ptr(&arg_conv);
41751         return ret_conv;
41752 }
41753
41754 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1clone(JNIEnv *env, jclass clz, int64_t orig) {
41755         LDKTxCreationKeys orig_conv;
41756         orig_conv.inner = untag_ptr(orig);
41757         orig_conv.is_owned = ptr_is_owned(orig);
41758         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
41759         orig_conv.is_owned = false;
41760         LDKTxCreationKeys ret_var = TxCreationKeys_clone(&orig_conv);
41761         int64_t ret_ref = 0;
41762         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41763         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
41764         return ret_ref;
41765 }
41766
41767 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1write(JNIEnv *env, jclass clz, int64_t obj) {
41768         LDKTxCreationKeys obj_conv;
41769         obj_conv.inner = untag_ptr(obj);
41770         obj_conv.is_owned = ptr_is_owned(obj);
41771         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
41772         obj_conv.is_owned = false;
41773         LDKCVec_u8Z ret_var = TxCreationKeys_write(&obj_conv);
41774         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
41775         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
41776         CVec_u8Z_free(ret_var);
41777         return ret_arr;
41778 }
41779
41780 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
41781         LDKu8slice ser_ref;
41782         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
41783         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
41784         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
41785         *ret_conv = TxCreationKeys_read(ser_ref);
41786         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
41787         return tag_ptr(ret_conv, true);
41788 }
41789
41790 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
41791         LDKChannelPublicKeys this_obj_conv;
41792         this_obj_conv.inner = untag_ptr(this_obj);
41793         this_obj_conv.is_owned = ptr_is_owned(this_obj);
41794         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
41795         ChannelPublicKeys_free(this_obj_conv);
41796 }
41797
41798 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
41799         LDKChannelPublicKeys this_ptr_conv;
41800         this_ptr_conv.inner = untag_ptr(this_ptr);
41801         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41802         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41803         this_ptr_conv.is_owned = false;
41804         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
41805         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_funding_pubkey(&this_ptr_conv).compressed_form);
41806         return ret_arr;
41807 }
41808
41809 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
41810         LDKChannelPublicKeys this_ptr_conv;
41811         this_ptr_conv.inner = untag_ptr(this_ptr);
41812         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41813         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41814         this_ptr_conv.is_owned = false;
41815         LDKPublicKey val_ref;
41816         CHECK((*env)->GetArrayLength(env, val) == 33);
41817         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
41818         ChannelPublicKeys_set_funding_pubkey(&this_ptr_conv, val_ref);
41819 }
41820
41821 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
41822         LDKChannelPublicKeys this_ptr_conv;
41823         this_ptr_conv.inner = untag_ptr(this_ptr);
41824         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41825         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41826         this_ptr_conv.is_owned = false;
41827         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
41828         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_revocation_basepoint(&this_ptr_conv).compressed_form);
41829         return ret_arr;
41830 }
41831
41832 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
41833         LDKChannelPublicKeys this_ptr_conv;
41834         this_ptr_conv.inner = untag_ptr(this_ptr);
41835         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41836         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41837         this_ptr_conv.is_owned = false;
41838         LDKPublicKey val_ref;
41839         CHECK((*env)->GetArrayLength(env, val) == 33);
41840         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
41841         ChannelPublicKeys_set_revocation_basepoint(&this_ptr_conv, val_ref);
41842 }
41843
41844 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
41845         LDKChannelPublicKeys 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         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
41851         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_payment_point(&this_ptr_conv).compressed_form);
41852         return ret_arr;
41853 }
41854
41855 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
41856         LDKChannelPublicKeys this_ptr_conv;
41857         this_ptr_conv.inner = untag_ptr(this_ptr);
41858         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41859         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41860         this_ptr_conv.is_owned = false;
41861         LDKPublicKey val_ref;
41862         CHECK((*env)->GetArrayLength(env, val) == 33);
41863         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
41864         ChannelPublicKeys_set_payment_point(&this_ptr_conv, val_ref);
41865 }
41866
41867 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
41868         LDKChannelPublicKeys this_ptr_conv;
41869         this_ptr_conv.inner = untag_ptr(this_ptr);
41870         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41871         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41872         this_ptr_conv.is_owned = false;
41873         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
41874         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form);
41875         return ret_arr;
41876 }
41877
41878 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
41879         LDKChannelPublicKeys this_ptr_conv;
41880         this_ptr_conv.inner = untag_ptr(this_ptr);
41881         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41882         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41883         this_ptr_conv.is_owned = false;
41884         LDKPublicKey val_ref;
41885         CHECK((*env)->GetArrayLength(env, val) == 33);
41886         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
41887         ChannelPublicKeys_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
41888 }
41889
41890 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
41891         LDKChannelPublicKeys this_ptr_conv;
41892         this_ptr_conv.inner = untag_ptr(this_ptr);
41893         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41894         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41895         this_ptr_conv.is_owned = false;
41896         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
41897         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_htlc_basepoint(&this_ptr_conv).compressed_form);
41898         return ret_arr;
41899 }
41900
41901 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
41902         LDKChannelPublicKeys this_ptr_conv;
41903         this_ptr_conv.inner = untag_ptr(this_ptr);
41904         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
41905         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
41906         this_ptr_conv.is_owned = false;
41907         LDKPublicKey val_ref;
41908         CHECK((*env)->GetArrayLength(env, val) == 33);
41909         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
41910         ChannelPublicKeys_set_htlc_basepoint(&this_ptr_conv, val_ref);
41911 }
41912
41913 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) {
41914         LDKPublicKey funding_pubkey_arg_ref;
41915         CHECK((*env)->GetArrayLength(env, funding_pubkey_arg) == 33);
41916         (*env)->GetByteArrayRegion(env, funding_pubkey_arg, 0, 33, funding_pubkey_arg_ref.compressed_form);
41917         LDKPublicKey revocation_basepoint_arg_ref;
41918         CHECK((*env)->GetArrayLength(env, revocation_basepoint_arg) == 33);
41919         (*env)->GetByteArrayRegion(env, revocation_basepoint_arg, 0, 33, revocation_basepoint_arg_ref.compressed_form);
41920         LDKPublicKey payment_point_arg_ref;
41921         CHECK((*env)->GetArrayLength(env, payment_point_arg) == 33);
41922         (*env)->GetByteArrayRegion(env, payment_point_arg, 0, 33, payment_point_arg_ref.compressed_form);
41923         LDKPublicKey delayed_payment_basepoint_arg_ref;
41924         CHECK((*env)->GetArrayLength(env, delayed_payment_basepoint_arg) == 33);
41925         (*env)->GetByteArrayRegion(env, delayed_payment_basepoint_arg, 0, 33, delayed_payment_basepoint_arg_ref.compressed_form);
41926         LDKPublicKey htlc_basepoint_arg_ref;
41927         CHECK((*env)->GetArrayLength(env, htlc_basepoint_arg) == 33);
41928         (*env)->GetByteArrayRegion(env, htlc_basepoint_arg, 0, 33, htlc_basepoint_arg_ref.compressed_form);
41929         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);
41930         int64_t ret_ref = 0;
41931         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41932         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
41933         return ret_ref;
41934 }
41935
41936 static inline uint64_t ChannelPublicKeys_clone_ptr(LDKChannelPublicKeys *NONNULL_PTR arg) {
41937         LDKChannelPublicKeys ret_var = ChannelPublicKeys_clone(arg);
41938         int64_t ret_ref = 0;
41939         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41940         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
41941         return ret_ref;
41942 }
41943 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
41944         LDKChannelPublicKeys arg_conv;
41945         arg_conv.inner = untag_ptr(arg);
41946         arg_conv.is_owned = ptr_is_owned(arg);
41947         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
41948         arg_conv.is_owned = false;
41949         int64_t ret_conv = ChannelPublicKeys_clone_ptr(&arg_conv);
41950         return ret_conv;
41951 }
41952
41953 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1clone(JNIEnv *env, jclass clz, int64_t orig) {
41954         LDKChannelPublicKeys orig_conv;
41955         orig_conv.inner = untag_ptr(orig);
41956         orig_conv.is_owned = ptr_is_owned(orig);
41957         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
41958         orig_conv.is_owned = false;
41959         LDKChannelPublicKeys ret_var = ChannelPublicKeys_clone(&orig_conv);
41960         int64_t ret_ref = 0;
41961         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
41962         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
41963         return ret_ref;
41964 }
41965
41966 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
41967         LDKChannelPublicKeys a_conv;
41968         a_conv.inner = untag_ptr(a);
41969         a_conv.is_owned = ptr_is_owned(a);
41970         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
41971         a_conv.is_owned = false;
41972         LDKChannelPublicKeys b_conv;
41973         b_conv.inner = untag_ptr(b);
41974         b_conv.is_owned = ptr_is_owned(b);
41975         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
41976         b_conv.is_owned = false;
41977         jboolean ret_conv = ChannelPublicKeys_eq(&a_conv, &b_conv);
41978         return ret_conv;
41979 }
41980
41981 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1write(JNIEnv *env, jclass clz, int64_t obj) {
41982         LDKChannelPublicKeys obj_conv;
41983         obj_conv.inner = untag_ptr(obj);
41984         obj_conv.is_owned = ptr_is_owned(obj);
41985         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
41986         obj_conv.is_owned = false;
41987         LDKCVec_u8Z ret_var = ChannelPublicKeys_write(&obj_conv);
41988         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
41989         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
41990         CVec_u8Z_free(ret_var);
41991         return ret_arr;
41992 }
41993
41994 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
41995         LDKu8slice ser_ref;
41996         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
41997         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
41998         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
41999         *ret_conv = ChannelPublicKeys_read(ser_ref);
42000         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
42001         return tag_ptr(ret_conv, true);
42002 }
42003
42004 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) {
42005         LDKPublicKey per_commitment_point_ref;
42006         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
42007         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
42008         LDKPublicKey broadcaster_delayed_payment_base_ref;
42009         CHECK((*env)->GetArrayLength(env, broadcaster_delayed_payment_base) == 33);
42010         (*env)->GetByteArrayRegion(env, broadcaster_delayed_payment_base, 0, 33, broadcaster_delayed_payment_base_ref.compressed_form);
42011         LDKPublicKey broadcaster_htlc_base_ref;
42012         CHECK((*env)->GetArrayLength(env, broadcaster_htlc_base) == 33);
42013         (*env)->GetByteArrayRegion(env, broadcaster_htlc_base, 0, 33, broadcaster_htlc_base_ref.compressed_form);
42014         LDKPublicKey countersignatory_revocation_base_ref;
42015         CHECK((*env)->GetArrayLength(env, countersignatory_revocation_base) == 33);
42016         (*env)->GetByteArrayRegion(env, countersignatory_revocation_base, 0, 33, countersignatory_revocation_base_ref.compressed_form);
42017         LDKPublicKey countersignatory_htlc_base_ref;
42018         CHECK((*env)->GetArrayLength(env, countersignatory_htlc_base) == 33);
42019         (*env)->GetByteArrayRegion(env, countersignatory_htlc_base, 0, 33, countersignatory_htlc_base_ref.compressed_form);
42020         LDKTxCreationKeys ret_var = TxCreationKeys_derive_new(per_commitment_point_ref, broadcaster_delayed_payment_base_ref, broadcaster_htlc_base_ref, countersignatory_revocation_base_ref, countersignatory_htlc_base_ref);
42021         int64_t ret_ref = 0;
42022         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42023         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42024         return ret_ref;
42025 }
42026
42027 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) {
42028         LDKPublicKey per_commitment_point_ref;
42029         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
42030         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
42031         LDKChannelPublicKeys broadcaster_keys_conv;
42032         broadcaster_keys_conv.inner = untag_ptr(broadcaster_keys);
42033         broadcaster_keys_conv.is_owned = ptr_is_owned(broadcaster_keys);
42034         CHECK_INNER_FIELD_ACCESS_OR_NULL(broadcaster_keys_conv);
42035         broadcaster_keys_conv.is_owned = false;
42036         LDKChannelPublicKeys countersignatory_keys_conv;
42037         countersignatory_keys_conv.inner = untag_ptr(countersignatory_keys);
42038         countersignatory_keys_conv.is_owned = ptr_is_owned(countersignatory_keys);
42039         CHECK_INNER_FIELD_ACCESS_OR_NULL(countersignatory_keys_conv);
42040         countersignatory_keys_conv.is_owned = false;
42041         LDKTxCreationKeys ret_var = TxCreationKeys_from_channel_static_keys(per_commitment_point_ref, &broadcaster_keys_conv, &countersignatory_keys_conv);
42042         int64_t ret_ref = 0;
42043         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42044         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42045         return ret_ref;
42046 }
42047
42048 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) {
42049         LDKPublicKey revocation_key_ref;
42050         CHECK((*env)->GetArrayLength(env, revocation_key) == 33);
42051         (*env)->GetByteArrayRegion(env, revocation_key, 0, 33, revocation_key_ref.compressed_form);
42052         LDKPublicKey broadcaster_delayed_payment_key_ref;
42053         CHECK((*env)->GetArrayLength(env, broadcaster_delayed_payment_key) == 33);
42054         (*env)->GetByteArrayRegion(env, broadcaster_delayed_payment_key, 0, 33, broadcaster_delayed_payment_key_ref.compressed_form);
42055         LDKCVec_u8Z ret_var = get_revokeable_redeemscript(revocation_key_ref, contest_delay, broadcaster_delayed_payment_key_ref);
42056         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
42057         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
42058         CVec_u8Z_free(ret_var);
42059         return ret_arr;
42060 }
42061
42062 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
42063         LDKHTLCOutputInCommitment this_obj_conv;
42064         this_obj_conv.inner = untag_ptr(this_obj);
42065         this_obj_conv.is_owned = ptr_is_owned(this_obj);
42066         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
42067         HTLCOutputInCommitment_free(this_obj_conv);
42068 }
42069
42070 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1offered(JNIEnv *env, jclass clz, int64_t this_ptr) {
42071         LDKHTLCOutputInCommitment this_ptr_conv;
42072         this_ptr_conv.inner = untag_ptr(this_ptr);
42073         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42074         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42075         this_ptr_conv.is_owned = false;
42076         jboolean ret_conv = HTLCOutputInCommitment_get_offered(&this_ptr_conv);
42077         return ret_conv;
42078 }
42079
42080 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1offered(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
42081         LDKHTLCOutputInCommitment this_ptr_conv;
42082         this_ptr_conv.inner = untag_ptr(this_ptr);
42083         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42084         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42085         this_ptr_conv.is_owned = false;
42086         HTLCOutputInCommitment_set_offered(&this_ptr_conv, val);
42087 }
42088
42089 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
42090         LDKHTLCOutputInCommitment this_ptr_conv;
42091         this_ptr_conv.inner = untag_ptr(this_ptr);
42092         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42093         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42094         this_ptr_conv.is_owned = false;
42095         int64_t ret_conv = HTLCOutputInCommitment_get_amount_msat(&this_ptr_conv);
42096         return ret_conv;
42097 }
42098
42099 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
42100         LDKHTLCOutputInCommitment this_ptr_conv;
42101         this_ptr_conv.inner = untag_ptr(this_ptr);
42102         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42103         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42104         this_ptr_conv.is_owned = false;
42105         HTLCOutputInCommitment_set_amount_msat(&this_ptr_conv, val);
42106 }
42107
42108 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_ptr) {
42109         LDKHTLCOutputInCommitment this_ptr_conv;
42110         this_ptr_conv.inner = untag_ptr(this_ptr);
42111         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42112         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42113         this_ptr_conv.is_owned = false;
42114         int32_t ret_conv = HTLCOutputInCommitment_get_cltv_expiry(&this_ptr_conv);
42115         return ret_conv;
42116 }
42117
42118 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
42119         LDKHTLCOutputInCommitment this_ptr_conv;
42120         this_ptr_conv.inner = untag_ptr(this_ptr);
42121         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42122         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42123         this_ptr_conv.is_owned = false;
42124         HTLCOutputInCommitment_set_cltv_expiry(&this_ptr_conv, val);
42125 }
42126
42127 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
42128         LDKHTLCOutputInCommitment this_ptr_conv;
42129         this_ptr_conv.inner = untag_ptr(this_ptr);
42130         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42131         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42132         this_ptr_conv.is_owned = false;
42133         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
42134         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *HTLCOutputInCommitment_get_payment_hash(&this_ptr_conv));
42135         return ret_arr;
42136 }
42137
42138 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
42139         LDKHTLCOutputInCommitment this_ptr_conv;
42140         this_ptr_conv.inner = untag_ptr(this_ptr);
42141         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42142         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42143         this_ptr_conv.is_owned = false;
42144         LDKThirtyTwoBytes val_ref;
42145         CHECK((*env)->GetArrayLength(env, val) == 32);
42146         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
42147         HTLCOutputInCommitment_set_payment_hash(&this_ptr_conv, val_ref);
42148 }
42149
42150 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1transaction_1output_1index(JNIEnv *env, jclass clz, int64_t this_ptr) {
42151         LDKHTLCOutputInCommitment this_ptr_conv;
42152         this_ptr_conv.inner = untag_ptr(this_ptr);
42153         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42154         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42155         this_ptr_conv.is_owned = false;
42156         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
42157         *ret_copy = HTLCOutputInCommitment_get_transaction_output_index(&this_ptr_conv);
42158         int64_t ret_ref = tag_ptr(ret_copy, true);
42159         return ret_ref;
42160 }
42161
42162 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1transaction_1output_1index(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
42163         LDKHTLCOutputInCommitment this_ptr_conv;
42164         this_ptr_conv.inner = untag_ptr(this_ptr);
42165         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42166         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42167         this_ptr_conv.is_owned = false;
42168         void* val_ptr = untag_ptr(val);
42169         CHECK_ACCESS(val_ptr);
42170         LDKCOption_u32Z val_conv = *(LDKCOption_u32Z*)(val_ptr);
42171         val_conv = COption_u32Z_clone((LDKCOption_u32Z*)untag_ptr(val));
42172         HTLCOutputInCommitment_set_transaction_output_index(&this_ptr_conv, val_conv);
42173 }
42174
42175 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) {
42176         LDKThirtyTwoBytes payment_hash_arg_ref;
42177         CHECK((*env)->GetArrayLength(env, payment_hash_arg) == 32);
42178         (*env)->GetByteArrayRegion(env, payment_hash_arg, 0, 32, payment_hash_arg_ref.data);
42179         void* transaction_output_index_arg_ptr = untag_ptr(transaction_output_index_arg);
42180         CHECK_ACCESS(transaction_output_index_arg_ptr);
42181         LDKCOption_u32Z transaction_output_index_arg_conv = *(LDKCOption_u32Z*)(transaction_output_index_arg_ptr);
42182         transaction_output_index_arg_conv = COption_u32Z_clone((LDKCOption_u32Z*)untag_ptr(transaction_output_index_arg));
42183         LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_new(offered_arg, amount_msat_arg, cltv_expiry_arg, payment_hash_arg_ref, transaction_output_index_arg_conv);
42184         int64_t ret_ref = 0;
42185         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42186         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42187         return ret_ref;
42188 }
42189
42190 static inline uint64_t HTLCOutputInCommitment_clone_ptr(LDKHTLCOutputInCommitment *NONNULL_PTR arg) {
42191         LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_clone(arg);
42192         int64_t ret_ref = 0;
42193         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42194         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42195         return ret_ref;
42196 }
42197 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
42198         LDKHTLCOutputInCommitment arg_conv;
42199         arg_conv.inner = untag_ptr(arg);
42200         arg_conv.is_owned = ptr_is_owned(arg);
42201         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
42202         arg_conv.is_owned = false;
42203         int64_t ret_conv = HTLCOutputInCommitment_clone_ptr(&arg_conv);
42204         return ret_conv;
42205 }
42206
42207 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1clone(JNIEnv *env, jclass clz, int64_t orig) {
42208         LDKHTLCOutputInCommitment orig_conv;
42209         orig_conv.inner = untag_ptr(orig);
42210         orig_conv.is_owned = ptr_is_owned(orig);
42211         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
42212         orig_conv.is_owned = false;
42213         LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_clone(&orig_conv);
42214         int64_t ret_ref = 0;
42215         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42216         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42217         return ret_ref;
42218 }
42219
42220 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
42221         LDKHTLCOutputInCommitment a_conv;
42222         a_conv.inner = untag_ptr(a);
42223         a_conv.is_owned = ptr_is_owned(a);
42224         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
42225         a_conv.is_owned = false;
42226         LDKHTLCOutputInCommitment b_conv;
42227         b_conv.inner = untag_ptr(b);
42228         b_conv.is_owned = ptr_is_owned(b);
42229         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
42230         b_conv.is_owned = false;
42231         jboolean ret_conv = HTLCOutputInCommitment_eq(&a_conv, &b_conv);
42232         return ret_conv;
42233 }
42234
42235 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1write(JNIEnv *env, jclass clz, int64_t obj) {
42236         LDKHTLCOutputInCommitment obj_conv;
42237         obj_conv.inner = untag_ptr(obj);
42238         obj_conv.is_owned = ptr_is_owned(obj);
42239         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
42240         obj_conv.is_owned = false;
42241         LDKCVec_u8Z ret_var = HTLCOutputInCommitment_write(&obj_conv);
42242         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
42243         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
42244         CVec_u8Z_free(ret_var);
42245         return ret_arr;
42246 }
42247
42248 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
42249         LDKu8slice ser_ref;
42250         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
42251         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
42252         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
42253         *ret_conv = HTLCOutputInCommitment_read(ser_ref);
42254         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
42255         return tag_ptr(ret_conv, true);
42256 }
42257
42258 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) {
42259         LDKHTLCOutputInCommitment htlc_conv;
42260         htlc_conv.inner = untag_ptr(htlc);
42261         htlc_conv.is_owned = ptr_is_owned(htlc);
42262         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_conv);
42263         htlc_conv.is_owned = false;
42264         LDKTxCreationKeys keys_conv;
42265         keys_conv.inner = untag_ptr(keys);
42266         keys_conv.is_owned = ptr_is_owned(keys);
42267         CHECK_INNER_FIELD_ACCESS_OR_NULL(keys_conv);
42268         keys_conv.is_owned = false;
42269         LDKCVec_u8Z ret_var = get_htlc_redeemscript(&htlc_conv, opt_anchors, &keys_conv);
42270         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
42271         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
42272         CVec_u8Z_free(ret_var);
42273         return ret_arr;
42274 }
42275
42276 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_make_1funding_1redeemscript(JNIEnv *env, jclass clz, int8_tArray broadcaster, int8_tArray countersignatory) {
42277         LDKPublicKey broadcaster_ref;
42278         CHECK((*env)->GetArrayLength(env, broadcaster) == 33);
42279         (*env)->GetByteArrayRegion(env, broadcaster, 0, 33, broadcaster_ref.compressed_form);
42280         LDKPublicKey countersignatory_ref;
42281         CHECK((*env)->GetArrayLength(env, countersignatory) == 33);
42282         (*env)->GetByteArrayRegion(env, countersignatory, 0, 33, countersignatory_ref.compressed_form);
42283         LDKCVec_u8Z ret_var = make_funding_redeemscript(broadcaster_ref, countersignatory_ref);
42284         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
42285         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
42286         CVec_u8Z_free(ret_var);
42287         return ret_arr;
42288 }
42289
42290 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, jboolean use_non_zero_fee_anchors, int8_tArray broadcaster_delayed_payment_key, int8_tArray revocation_key) {
42291         unsigned char commitment_txid_arr[32];
42292         CHECK((*env)->GetArrayLength(env, commitment_txid) == 32);
42293         (*env)->GetByteArrayRegion(env, commitment_txid, 0, 32, commitment_txid_arr);
42294         unsigned char (*commitment_txid_ref)[32] = &commitment_txid_arr;
42295         LDKHTLCOutputInCommitment htlc_conv;
42296         htlc_conv.inner = untag_ptr(htlc);
42297         htlc_conv.is_owned = ptr_is_owned(htlc);
42298         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_conv);
42299         htlc_conv.is_owned = false;
42300         LDKPublicKey broadcaster_delayed_payment_key_ref;
42301         CHECK((*env)->GetArrayLength(env, broadcaster_delayed_payment_key) == 33);
42302         (*env)->GetByteArrayRegion(env, broadcaster_delayed_payment_key, 0, 33, broadcaster_delayed_payment_key_ref.compressed_form);
42303         LDKPublicKey revocation_key_ref;
42304         CHECK((*env)->GetArrayLength(env, revocation_key) == 33);
42305         (*env)->GetByteArrayRegion(env, revocation_key, 0, 33, revocation_key_ref.compressed_form);
42306         LDKTransaction ret_var = build_htlc_transaction(commitment_txid_ref, feerate_per_kw, contest_delay, &htlc_conv, opt_anchors, use_non_zero_fee_anchors, broadcaster_delayed_payment_key_ref, revocation_key_ref);
42307         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
42308         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
42309         Transaction_free(ret_var);
42310         return ret_arr;
42311 }
42312
42313 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_build_1htlc_1input_1witness(JNIEnv *env, jclass clz, int8_tArray local_sig, int8_tArray remote_sig, int8_tArray preimage, int8_tArray redeem_script, jboolean opt_anchors) {
42314         LDKSignature local_sig_ref;
42315         CHECK((*env)->GetArrayLength(env, local_sig) == 64);
42316         (*env)->GetByteArrayRegion(env, local_sig, 0, 64, local_sig_ref.compact_form);
42317         LDKSignature remote_sig_ref;
42318         CHECK((*env)->GetArrayLength(env, remote_sig) == 64);
42319         (*env)->GetByteArrayRegion(env, remote_sig, 0, 64, remote_sig_ref.compact_form);
42320         LDKThirtyTwoBytes preimage_ref;
42321         CHECK((*env)->GetArrayLength(env, preimage) == 32);
42322         (*env)->GetByteArrayRegion(env, preimage, 0, 32, preimage_ref.data);
42323         LDKu8slice redeem_script_ref;
42324         redeem_script_ref.datalen = (*env)->GetArrayLength(env, redeem_script);
42325         redeem_script_ref.data = (*env)->GetByteArrayElements (env, redeem_script, NULL);
42326         LDKWitness ret_var = build_htlc_input_witness(local_sig_ref, remote_sig_ref, preimage_ref, redeem_script_ref, opt_anchors);
42327         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
42328         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
42329         Witness_free(ret_var);
42330         (*env)->ReleaseByteArrayElements(env, redeem_script, (int8_t*)redeem_script_ref.data, 0);
42331         return ret_arr;
42332 }
42333
42334 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_get_1to_1countersignatory_1with_1anchors_1redeemscript(JNIEnv *env, jclass clz, int8_tArray payment_point) {
42335         LDKPublicKey payment_point_ref;
42336         CHECK((*env)->GetArrayLength(env, payment_point) == 33);
42337         (*env)->GetByteArrayRegion(env, payment_point, 0, 33, payment_point_ref.compressed_form);
42338         LDKCVec_u8Z ret_var = get_to_countersignatory_with_anchors_redeemscript(payment_point_ref);
42339         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
42340         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
42341         CVec_u8Z_free(ret_var);
42342         return ret_arr;
42343 }
42344
42345 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_get_1anchor_1redeemscript(JNIEnv *env, jclass clz, int8_tArray funding_pubkey) {
42346         LDKPublicKey funding_pubkey_ref;
42347         CHECK((*env)->GetArrayLength(env, funding_pubkey) == 33);
42348         (*env)->GetByteArrayRegion(env, funding_pubkey, 0, 33, funding_pubkey_ref.compressed_form);
42349         LDKCVec_u8Z ret_var = get_anchor_redeemscript(funding_pubkey_ref);
42350         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
42351         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
42352         CVec_u8Z_free(ret_var);
42353         return ret_arr;
42354 }
42355
42356 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_build_1anchor_1input_1witness(JNIEnv *env, jclass clz, int8_tArray funding_key, int8_tArray funding_sig) {
42357         LDKPublicKey funding_key_ref;
42358         CHECK((*env)->GetArrayLength(env, funding_key) == 33);
42359         (*env)->GetByteArrayRegion(env, funding_key, 0, 33, funding_key_ref.compressed_form);
42360         LDKSignature funding_sig_ref;
42361         CHECK((*env)->GetArrayLength(env, funding_sig) == 64);
42362         (*env)->GetByteArrayRegion(env, funding_sig, 0, 64, funding_sig_ref.compact_form);
42363         LDKWitness ret_var = build_anchor_input_witness(funding_key_ref, funding_sig_ref);
42364         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
42365         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
42366         Witness_free(ret_var);
42367         return ret_arr;
42368 }
42369
42370 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
42371         LDKChannelTransactionParameters this_obj_conv;
42372         this_obj_conv.inner = untag_ptr(this_obj);
42373         this_obj_conv.is_owned = ptr_is_owned(this_obj);
42374         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
42375         ChannelTransactionParameters_free(this_obj_conv);
42376 }
42377
42378 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1holder_1pubkeys(JNIEnv *env, jclass clz, int64_t this_ptr) {
42379         LDKChannelTransactionParameters this_ptr_conv;
42380         this_ptr_conv.inner = untag_ptr(this_ptr);
42381         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42382         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42383         this_ptr_conv.is_owned = false;
42384         LDKChannelPublicKeys ret_var = ChannelTransactionParameters_get_holder_pubkeys(&this_ptr_conv);
42385         int64_t ret_ref = 0;
42386         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42387         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42388         return ret_ref;
42389 }
42390
42391 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1set_1holder_1pubkeys(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
42392         LDKChannelTransactionParameters this_ptr_conv;
42393         this_ptr_conv.inner = untag_ptr(this_ptr);
42394         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42395         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42396         this_ptr_conv.is_owned = false;
42397         LDKChannelPublicKeys val_conv;
42398         val_conv.inner = untag_ptr(val);
42399         val_conv.is_owned = ptr_is_owned(val);
42400         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
42401         val_conv = ChannelPublicKeys_clone(&val_conv);
42402         ChannelTransactionParameters_set_holder_pubkeys(&this_ptr_conv, val_conv);
42403 }
42404
42405 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1holder_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
42406         LDKChannelTransactionParameters this_ptr_conv;
42407         this_ptr_conv.inner = untag_ptr(this_ptr);
42408         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42409         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42410         this_ptr_conv.is_owned = false;
42411         int16_t ret_conv = ChannelTransactionParameters_get_holder_selected_contest_delay(&this_ptr_conv);
42412         return ret_conv;
42413 }
42414
42415 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) {
42416         LDKChannelTransactionParameters this_ptr_conv;
42417         this_ptr_conv.inner = untag_ptr(this_ptr);
42418         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42419         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42420         this_ptr_conv.is_owned = false;
42421         ChannelTransactionParameters_set_holder_selected_contest_delay(&this_ptr_conv, val);
42422 }
42423
42424 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1is_1outbound_1from_1holder(JNIEnv *env, jclass clz, int64_t this_ptr) {
42425         LDKChannelTransactionParameters this_ptr_conv;
42426         this_ptr_conv.inner = untag_ptr(this_ptr);
42427         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42428         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42429         this_ptr_conv.is_owned = false;
42430         jboolean ret_conv = ChannelTransactionParameters_get_is_outbound_from_holder(&this_ptr_conv);
42431         return ret_conv;
42432 }
42433
42434 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1set_1is_1outbound_1from_1holder(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
42435         LDKChannelTransactionParameters this_ptr_conv;
42436         this_ptr_conv.inner = untag_ptr(this_ptr);
42437         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42438         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42439         this_ptr_conv.is_owned = false;
42440         ChannelTransactionParameters_set_is_outbound_from_holder(&this_ptr_conv, val);
42441 }
42442
42443 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1counterparty_1parameters(JNIEnv *env, jclass clz, int64_t this_ptr) {
42444         LDKChannelTransactionParameters this_ptr_conv;
42445         this_ptr_conv.inner = untag_ptr(this_ptr);
42446         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42447         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42448         this_ptr_conv.is_owned = false;
42449         LDKCounterpartyChannelTransactionParameters ret_var = ChannelTransactionParameters_get_counterparty_parameters(&this_ptr_conv);
42450         int64_t ret_ref = 0;
42451         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42452         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42453         return ret_ref;
42454 }
42455
42456 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1set_1counterparty_1parameters(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
42457         LDKChannelTransactionParameters this_ptr_conv;
42458         this_ptr_conv.inner = untag_ptr(this_ptr);
42459         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42460         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42461         this_ptr_conv.is_owned = false;
42462         LDKCounterpartyChannelTransactionParameters val_conv;
42463         val_conv.inner = untag_ptr(val);
42464         val_conv.is_owned = ptr_is_owned(val);
42465         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
42466         val_conv = CounterpartyChannelTransactionParameters_clone(&val_conv);
42467         ChannelTransactionParameters_set_counterparty_parameters(&this_ptr_conv, val_conv);
42468 }
42469
42470 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1funding_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
42471         LDKChannelTransactionParameters this_ptr_conv;
42472         this_ptr_conv.inner = untag_ptr(this_ptr);
42473         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42474         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42475         this_ptr_conv.is_owned = false;
42476         LDKOutPoint ret_var = ChannelTransactionParameters_get_funding_outpoint(&this_ptr_conv);
42477         int64_t ret_ref = 0;
42478         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42479         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42480         return ret_ref;
42481 }
42482
42483 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1set_1funding_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
42484         LDKChannelTransactionParameters this_ptr_conv;
42485         this_ptr_conv.inner = untag_ptr(this_ptr);
42486         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42487         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42488         this_ptr_conv.is_owned = false;
42489         LDKOutPoint val_conv;
42490         val_conv.inner = untag_ptr(val);
42491         val_conv.is_owned = ptr_is_owned(val);
42492         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
42493         val_conv = OutPoint_clone(&val_conv);
42494         ChannelTransactionParameters_set_funding_outpoint(&this_ptr_conv, val_conv);
42495 }
42496
42497 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1opt_1anchors(JNIEnv *env, jclass clz, int64_t this_ptr) {
42498         LDKChannelTransactionParameters this_ptr_conv;
42499         this_ptr_conv.inner = untag_ptr(this_ptr);
42500         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42501         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42502         this_ptr_conv.is_owned = false;
42503         jclass ret_conv = LDKCOption_NoneZ_to_java(env, ChannelTransactionParameters_get_opt_anchors(&this_ptr_conv));
42504         return ret_conv;
42505 }
42506
42507 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1set_1opt_1anchors(JNIEnv *env, jclass clz, int64_t this_ptr, jclass val) {
42508         LDKChannelTransactionParameters this_ptr_conv;
42509         this_ptr_conv.inner = untag_ptr(this_ptr);
42510         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42511         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42512         this_ptr_conv.is_owned = false;
42513         LDKCOption_NoneZ val_conv = LDKCOption_NoneZ_from_java(env, val);
42514         ChannelTransactionParameters_set_opt_anchors(&this_ptr_conv, val_conv);
42515 }
42516
42517 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1opt_1non_1zero_1fee_1anchors(JNIEnv *env, jclass clz, int64_t this_ptr) {
42518         LDKChannelTransactionParameters this_ptr_conv;
42519         this_ptr_conv.inner = untag_ptr(this_ptr);
42520         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42521         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42522         this_ptr_conv.is_owned = false;
42523         jclass ret_conv = LDKCOption_NoneZ_to_java(env, ChannelTransactionParameters_get_opt_non_zero_fee_anchors(&this_ptr_conv));
42524         return ret_conv;
42525 }
42526
42527 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1set_1opt_1non_1zero_1fee_1anchors(JNIEnv *env, jclass clz, int64_t this_ptr, jclass val) {
42528         LDKChannelTransactionParameters this_ptr_conv;
42529         this_ptr_conv.inner = untag_ptr(this_ptr);
42530         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42531         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42532         this_ptr_conv.is_owned = false;
42533         LDKCOption_NoneZ val_conv = LDKCOption_NoneZ_from_java(env, val);
42534         ChannelTransactionParameters_set_opt_non_zero_fee_anchors(&this_ptr_conv, val_conv);
42535 }
42536
42537 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, jclass opt_non_zero_fee_anchors_arg) {
42538         LDKChannelPublicKeys holder_pubkeys_arg_conv;
42539         holder_pubkeys_arg_conv.inner = untag_ptr(holder_pubkeys_arg);
42540         holder_pubkeys_arg_conv.is_owned = ptr_is_owned(holder_pubkeys_arg);
42541         CHECK_INNER_FIELD_ACCESS_OR_NULL(holder_pubkeys_arg_conv);
42542         holder_pubkeys_arg_conv = ChannelPublicKeys_clone(&holder_pubkeys_arg_conv);
42543         LDKCounterpartyChannelTransactionParameters counterparty_parameters_arg_conv;
42544         counterparty_parameters_arg_conv.inner = untag_ptr(counterparty_parameters_arg);
42545         counterparty_parameters_arg_conv.is_owned = ptr_is_owned(counterparty_parameters_arg);
42546         CHECK_INNER_FIELD_ACCESS_OR_NULL(counterparty_parameters_arg_conv);
42547         counterparty_parameters_arg_conv = CounterpartyChannelTransactionParameters_clone(&counterparty_parameters_arg_conv);
42548         LDKOutPoint funding_outpoint_arg_conv;
42549         funding_outpoint_arg_conv.inner = untag_ptr(funding_outpoint_arg);
42550         funding_outpoint_arg_conv.is_owned = ptr_is_owned(funding_outpoint_arg);
42551         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_outpoint_arg_conv);
42552         funding_outpoint_arg_conv = OutPoint_clone(&funding_outpoint_arg_conv);
42553         LDKCOption_NoneZ opt_anchors_arg_conv = LDKCOption_NoneZ_from_java(env, opt_anchors_arg);
42554         LDKCOption_NoneZ opt_non_zero_fee_anchors_arg_conv = LDKCOption_NoneZ_from_java(env, opt_non_zero_fee_anchors_arg);
42555         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, opt_non_zero_fee_anchors_arg_conv);
42556         int64_t ret_ref = 0;
42557         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42558         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42559         return ret_ref;
42560 }
42561
42562 static inline uint64_t ChannelTransactionParameters_clone_ptr(LDKChannelTransactionParameters *NONNULL_PTR arg) {
42563         LDKChannelTransactionParameters ret_var = ChannelTransactionParameters_clone(arg);
42564         int64_t ret_ref = 0;
42565         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42566         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42567         return ret_ref;
42568 }
42569 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
42570         LDKChannelTransactionParameters arg_conv;
42571         arg_conv.inner = untag_ptr(arg);
42572         arg_conv.is_owned = ptr_is_owned(arg);
42573         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
42574         arg_conv.is_owned = false;
42575         int64_t ret_conv = ChannelTransactionParameters_clone_ptr(&arg_conv);
42576         return ret_conv;
42577 }
42578
42579 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1clone(JNIEnv *env, jclass clz, int64_t orig) {
42580         LDKChannelTransactionParameters orig_conv;
42581         orig_conv.inner = untag_ptr(orig);
42582         orig_conv.is_owned = ptr_is_owned(orig);
42583         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
42584         orig_conv.is_owned = false;
42585         LDKChannelTransactionParameters ret_var = ChannelTransactionParameters_clone(&orig_conv);
42586         int64_t ret_ref = 0;
42587         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42588         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42589         return ret_ref;
42590 }
42591
42592 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
42593         LDKCounterpartyChannelTransactionParameters this_obj_conv;
42594         this_obj_conv.inner = untag_ptr(this_obj);
42595         this_obj_conv.is_owned = ptr_is_owned(this_obj);
42596         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
42597         CounterpartyChannelTransactionParameters_free(this_obj_conv);
42598 }
42599
42600 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1get_1pubkeys(JNIEnv *env, jclass clz, int64_t this_ptr) {
42601         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
42602         this_ptr_conv.inner = untag_ptr(this_ptr);
42603         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42604         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42605         this_ptr_conv.is_owned = false;
42606         LDKChannelPublicKeys ret_var = CounterpartyChannelTransactionParameters_get_pubkeys(&this_ptr_conv);
42607         int64_t ret_ref = 0;
42608         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42609         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42610         return ret_ref;
42611 }
42612
42613 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1set_1pubkeys(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
42614         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
42615         this_ptr_conv.inner = untag_ptr(this_ptr);
42616         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42617         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42618         this_ptr_conv.is_owned = false;
42619         LDKChannelPublicKeys val_conv;
42620         val_conv.inner = untag_ptr(val);
42621         val_conv.is_owned = ptr_is_owned(val);
42622         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
42623         val_conv = ChannelPublicKeys_clone(&val_conv);
42624         CounterpartyChannelTransactionParameters_set_pubkeys(&this_ptr_conv, val_conv);
42625 }
42626
42627 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1get_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
42628         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
42629         this_ptr_conv.inner = untag_ptr(this_ptr);
42630         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42631         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42632         this_ptr_conv.is_owned = false;
42633         int16_t ret_conv = CounterpartyChannelTransactionParameters_get_selected_contest_delay(&this_ptr_conv);
42634         return ret_conv;
42635 }
42636
42637 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1set_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
42638         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
42639         this_ptr_conv.inner = untag_ptr(this_ptr);
42640         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42641         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42642         this_ptr_conv.is_owned = false;
42643         CounterpartyChannelTransactionParameters_set_selected_contest_delay(&this_ptr_conv, val);
42644 }
42645
42646 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) {
42647         LDKChannelPublicKeys pubkeys_arg_conv;
42648         pubkeys_arg_conv.inner = untag_ptr(pubkeys_arg);
42649         pubkeys_arg_conv.is_owned = ptr_is_owned(pubkeys_arg);
42650         CHECK_INNER_FIELD_ACCESS_OR_NULL(pubkeys_arg_conv);
42651         pubkeys_arg_conv = ChannelPublicKeys_clone(&pubkeys_arg_conv);
42652         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_new(pubkeys_arg_conv, selected_contest_delay_arg);
42653         int64_t ret_ref = 0;
42654         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42655         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42656         return ret_ref;
42657 }
42658
42659 static inline uint64_t CounterpartyChannelTransactionParameters_clone_ptr(LDKCounterpartyChannelTransactionParameters *NONNULL_PTR arg) {
42660         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_clone(arg);
42661         int64_t ret_ref = 0;
42662         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42663         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42664         return ret_ref;
42665 }
42666 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
42667         LDKCounterpartyChannelTransactionParameters arg_conv;
42668         arg_conv.inner = untag_ptr(arg);
42669         arg_conv.is_owned = ptr_is_owned(arg);
42670         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
42671         arg_conv.is_owned = false;
42672         int64_t ret_conv = CounterpartyChannelTransactionParameters_clone_ptr(&arg_conv);
42673         return ret_conv;
42674 }
42675
42676 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1clone(JNIEnv *env, jclass clz, int64_t orig) {
42677         LDKCounterpartyChannelTransactionParameters orig_conv;
42678         orig_conv.inner = untag_ptr(orig);
42679         orig_conv.is_owned = ptr_is_owned(orig);
42680         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
42681         orig_conv.is_owned = false;
42682         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_clone(&orig_conv);
42683         int64_t ret_ref = 0;
42684         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42685         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42686         return ret_ref;
42687 }
42688
42689 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1is_1populated(JNIEnv *env, jclass clz, int64_t this_arg) {
42690         LDKChannelTransactionParameters this_arg_conv;
42691         this_arg_conv.inner = untag_ptr(this_arg);
42692         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42693         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42694         this_arg_conv.is_owned = false;
42695         jboolean ret_conv = ChannelTransactionParameters_is_populated(&this_arg_conv);
42696         return ret_conv;
42697 }
42698
42699 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1as_1holder_1broadcastable(JNIEnv *env, jclass clz, int64_t this_arg) {
42700         LDKChannelTransactionParameters this_arg_conv;
42701         this_arg_conv.inner = untag_ptr(this_arg);
42702         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42703         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42704         this_arg_conv.is_owned = false;
42705         LDKDirectedChannelTransactionParameters ret_var = ChannelTransactionParameters_as_holder_broadcastable(&this_arg_conv);
42706         int64_t ret_ref = 0;
42707         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42708         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42709         return ret_ref;
42710 }
42711
42712 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1as_1counterparty_1broadcastable(JNIEnv *env, jclass clz, int64_t this_arg) {
42713         LDKChannelTransactionParameters this_arg_conv;
42714         this_arg_conv.inner = untag_ptr(this_arg);
42715         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42716         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42717         this_arg_conv.is_owned = false;
42718         LDKDirectedChannelTransactionParameters ret_var = ChannelTransactionParameters_as_counterparty_broadcastable(&this_arg_conv);
42719         int64_t ret_ref = 0;
42720         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42721         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42722         return ret_ref;
42723 }
42724
42725 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1write(JNIEnv *env, jclass clz, int64_t obj) {
42726         LDKCounterpartyChannelTransactionParameters obj_conv;
42727         obj_conv.inner = untag_ptr(obj);
42728         obj_conv.is_owned = ptr_is_owned(obj);
42729         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
42730         obj_conv.is_owned = false;
42731         LDKCVec_u8Z ret_var = CounterpartyChannelTransactionParameters_write(&obj_conv);
42732         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
42733         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
42734         CVec_u8Z_free(ret_var);
42735         return ret_arr;
42736 }
42737
42738 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
42739         LDKu8slice ser_ref;
42740         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
42741         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
42742         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
42743         *ret_conv = CounterpartyChannelTransactionParameters_read(ser_ref);
42744         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
42745         return tag_ptr(ret_conv, true);
42746 }
42747
42748 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1write(JNIEnv *env, jclass clz, int64_t obj) {
42749         LDKChannelTransactionParameters obj_conv;
42750         obj_conv.inner = untag_ptr(obj);
42751         obj_conv.is_owned = ptr_is_owned(obj);
42752         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
42753         obj_conv.is_owned = false;
42754         LDKCVec_u8Z ret_var = ChannelTransactionParameters_write(&obj_conv);
42755         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
42756         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
42757         CVec_u8Z_free(ret_var);
42758         return ret_arr;
42759 }
42760
42761 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
42762         LDKu8slice ser_ref;
42763         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
42764         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
42765         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
42766         *ret_conv = ChannelTransactionParameters_read(ser_ref);
42767         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
42768         return tag_ptr(ret_conv, true);
42769 }
42770
42771 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
42772         LDKDirectedChannelTransactionParameters this_obj_conv;
42773         this_obj_conv.inner = untag_ptr(this_obj);
42774         this_obj_conv.is_owned = ptr_is_owned(this_obj);
42775         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
42776         DirectedChannelTransactionParameters_free(this_obj_conv);
42777 }
42778
42779 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1broadcaster_1pubkeys(JNIEnv *env, jclass clz, int64_t this_arg) {
42780         LDKDirectedChannelTransactionParameters this_arg_conv;
42781         this_arg_conv.inner = untag_ptr(this_arg);
42782         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42783         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42784         this_arg_conv.is_owned = false;
42785         LDKChannelPublicKeys ret_var = DirectedChannelTransactionParameters_broadcaster_pubkeys(&this_arg_conv);
42786         int64_t ret_ref = 0;
42787         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42788         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42789         return ret_ref;
42790 }
42791
42792 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1countersignatory_1pubkeys(JNIEnv *env, jclass clz, int64_t this_arg) {
42793         LDKDirectedChannelTransactionParameters this_arg_conv;
42794         this_arg_conv.inner = untag_ptr(this_arg);
42795         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42796         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42797         this_arg_conv.is_owned = false;
42798         LDKChannelPublicKeys ret_var = DirectedChannelTransactionParameters_countersignatory_pubkeys(&this_arg_conv);
42799         int64_t ret_ref = 0;
42800         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42801         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42802         return ret_ref;
42803 }
42804
42805 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_arg) {
42806         LDKDirectedChannelTransactionParameters this_arg_conv;
42807         this_arg_conv.inner = untag_ptr(this_arg);
42808         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42809         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42810         this_arg_conv.is_owned = false;
42811         int16_t ret_conv = DirectedChannelTransactionParameters_contest_delay(&this_arg_conv);
42812         return ret_conv;
42813 }
42814
42815 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1is_1outbound(JNIEnv *env, jclass clz, int64_t this_arg) {
42816         LDKDirectedChannelTransactionParameters this_arg_conv;
42817         this_arg_conv.inner = untag_ptr(this_arg);
42818         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42819         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42820         this_arg_conv.is_owned = false;
42821         jboolean ret_conv = DirectedChannelTransactionParameters_is_outbound(&this_arg_conv);
42822         return ret_conv;
42823 }
42824
42825 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1funding_1outpoint(JNIEnv *env, jclass clz, int64_t this_arg) {
42826         LDKDirectedChannelTransactionParameters this_arg_conv;
42827         this_arg_conv.inner = untag_ptr(this_arg);
42828         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42829         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42830         this_arg_conv.is_owned = false;
42831         LDKOutPoint ret_var = DirectedChannelTransactionParameters_funding_outpoint(&this_arg_conv);
42832         int64_t ret_ref = 0;
42833         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42834         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42835         return ret_ref;
42836 }
42837
42838 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1opt_1anchors(JNIEnv *env, jclass clz, int64_t this_arg) {
42839         LDKDirectedChannelTransactionParameters this_arg_conv;
42840         this_arg_conv.inner = untag_ptr(this_arg);
42841         this_arg_conv.is_owned = ptr_is_owned(this_arg);
42842         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
42843         this_arg_conv.is_owned = false;
42844         jboolean ret_conv = DirectedChannelTransactionParameters_opt_anchors(&this_arg_conv);
42845         return ret_conv;
42846 }
42847
42848 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
42849         LDKHolderCommitmentTransaction this_obj_conv;
42850         this_obj_conv.inner = untag_ptr(this_obj);
42851         this_obj_conv.is_owned = ptr_is_owned(this_obj);
42852         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
42853         HolderCommitmentTransaction_free(this_obj_conv);
42854 }
42855
42856 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1get_1counterparty_1sig(JNIEnv *env, jclass clz, int64_t this_ptr) {
42857         LDKHolderCommitmentTransaction this_ptr_conv;
42858         this_ptr_conv.inner = untag_ptr(this_ptr);
42859         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42860         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42861         this_ptr_conv.is_owned = false;
42862         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
42863         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, HolderCommitmentTransaction_get_counterparty_sig(&this_ptr_conv).compact_form);
42864         return ret_arr;
42865 }
42866
42867 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1set_1counterparty_1sig(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
42868         LDKHolderCommitmentTransaction this_ptr_conv;
42869         this_ptr_conv.inner = untag_ptr(this_ptr);
42870         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42871         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42872         this_ptr_conv.is_owned = false;
42873         LDKSignature val_ref;
42874         CHECK((*env)->GetArrayLength(env, val) == 64);
42875         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
42876         HolderCommitmentTransaction_set_counterparty_sig(&this_ptr_conv, val_ref);
42877 }
42878
42879 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1get_1counterparty_1htlc_1sigs(JNIEnv *env, jclass clz, int64_t this_ptr) {
42880         LDKHolderCommitmentTransaction this_ptr_conv;
42881         this_ptr_conv.inner = untag_ptr(this_ptr);
42882         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42883         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42884         this_ptr_conv.is_owned = false;
42885         LDKCVec_SignatureZ ret_var = HolderCommitmentTransaction_get_counterparty_htlc_sigs(&this_ptr_conv);
42886         jobjectArray ret_arr = NULL;
42887         ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
42888         ;
42889         for (size_t i = 0; i < ret_var.datalen; i++) {
42890                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, 64);
42891                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, 64, ret_var.data[i].compact_form);
42892                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
42893         }
42894         
42895         FREE(ret_var.data);
42896         return ret_arr;
42897 }
42898
42899 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1set_1counterparty_1htlc_1sigs(JNIEnv *env, jclass clz, int64_t this_ptr, jobjectArray val) {
42900         LDKHolderCommitmentTransaction this_ptr_conv;
42901         this_ptr_conv.inner = untag_ptr(this_ptr);
42902         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
42903         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
42904         this_ptr_conv.is_owned = false;
42905         LDKCVec_SignatureZ val_constr;
42906         val_constr.datalen = (*env)->GetArrayLength(env, val);
42907         if (val_constr.datalen > 0)
42908                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
42909         else
42910                 val_constr.data = NULL;
42911         for (size_t i = 0; i < val_constr.datalen; i++) {
42912                 int8_tArray val_conv_8 = (*env)->GetObjectArrayElement(env, val, i);
42913                 LDKSignature val_conv_8_ref;
42914                 CHECK((*env)->GetArrayLength(env, val_conv_8) == 64);
42915                 (*env)->GetByteArrayRegion(env, val_conv_8, 0, 64, val_conv_8_ref.compact_form);
42916                 val_constr.data[i] = val_conv_8_ref;
42917         }
42918         HolderCommitmentTransaction_set_counterparty_htlc_sigs(&this_ptr_conv, val_constr);
42919 }
42920
42921 static inline uint64_t HolderCommitmentTransaction_clone_ptr(LDKHolderCommitmentTransaction *NONNULL_PTR arg) {
42922         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_clone(arg);
42923         int64_t ret_ref = 0;
42924         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42925         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42926         return ret_ref;
42927 }
42928 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
42929         LDKHolderCommitmentTransaction arg_conv;
42930         arg_conv.inner = untag_ptr(arg);
42931         arg_conv.is_owned = ptr_is_owned(arg);
42932         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
42933         arg_conv.is_owned = false;
42934         int64_t ret_conv = HolderCommitmentTransaction_clone_ptr(&arg_conv);
42935         return ret_conv;
42936 }
42937
42938 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
42939         LDKHolderCommitmentTransaction orig_conv;
42940         orig_conv.inner = untag_ptr(orig);
42941         orig_conv.is_owned = ptr_is_owned(orig);
42942         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
42943         orig_conv.is_owned = false;
42944         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_clone(&orig_conv);
42945         int64_t ret_ref = 0;
42946         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
42947         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
42948         return ret_ref;
42949 }
42950
42951 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1write(JNIEnv *env, jclass clz, int64_t obj) {
42952         LDKHolderCommitmentTransaction obj_conv;
42953         obj_conv.inner = untag_ptr(obj);
42954         obj_conv.is_owned = ptr_is_owned(obj);
42955         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
42956         obj_conv.is_owned = false;
42957         LDKCVec_u8Z ret_var = HolderCommitmentTransaction_write(&obj_conv);
42958         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
42959         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
42960         CVec_u8Z_free(ret_var);
42961         return ret_arr;
42962 }
42963
42964 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
42965         LDKu8slice ser_ref;
42966         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
42967         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
42968         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
42969         *ret_conv = HolderCommitmentTransaction_read(ser_ref);
42970         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
42971         return tag_ptr(ret_conv, true);
42972 }
42973
42974 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) {
42975         LDKCommitmentTransaction commitment_tx_conv;
42976         commitment_tx_conv.inner = untag_ptr(commitment_tx);
42977         commitment_tx_conv.is_owned = ptr_is_owned(commitment_tx);
42978         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_conv);
42979         commitment_tx_conv = CommitmentTransaction_clone(&commitment_tx_conv);
42980         LDKSignature counterparty_sig_ref;
42981         CHECK((*env)->GetArrayLength(env, counterparty_sig) == 64);
42982         (*env)->GetByteArrayRegion(env, counterparty_sig, 0, 64, counterparty_sig_ref.compact_form);
42983         LDKCVec_SignatureZ counterparty_htlc_sigs_constr;
42984         counterparty_htlc_sigs_constr.datalen = (*env)->GetArrayLength(env, counterparty_htlc_sigs);
42985         if (counterparty_htlc_sigs_constr.datalen > 0)
42986                 counterparty_htlc_sigs_constr.data = MALLOC(counterparty_htlc_sigs_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
42987         else
42988                 counterparty_htlc_sigs_constr.data = NULL;
42989         for (size_t i = 0; i < counterparty_htlc_sigs_constr.datalen; i++) {
42990                 int8_tArray counterparty_htlc_sigs_conv_8 = (*env)->GetObjectArrayElement(env, counterparty_htlc_sigs, i);
42991                 LDKSignature counterparty_htlc_sigs_conv_8_ref;
42992                 CHECK((*env)->GetArrayLength(env, counterparty_htlc_sigs_conv_8) == 64);
42993                 (*env)->GetByteArrayRegion(env, counterparty_htlc_sigs_conv_8, 0, 64, counterparty_htlc_sigs_conv_8_ref.compact_form);
42994                 counterparty_htlc_sigs_constr.data[i] = counterparty_htlc_sigs_conv_8_ref;
42995         }
42996         LDKPublicKey holder_funding_key_ref;
42997         CHECK((*env)->GetArrayLength(env, holder_funding_key) == 33);
42998         (*env)->GetByteArrayRegion(env, holder_funding_key, 0, 33, holder_funding_key_ref.compressed_form);
42999         LDKPublicKey counterparty_funding_key_ref;
43000         CHECK((*env)->GetArrayLength(env, counterparty_funding_key) == 33);
43001         (*env)->GetByteArrayRegion(env, counterparty_funding_key, 0, 33, counterparty_funding_key_ref.compressed_form);
43002         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_new(commitment_tx_conv, counterparty_sig_ref, counterparty_htlc_sigs_constr, holder_funding_key_ref, counterparty_funding_key_ref);
43003         int64_t ret_ref = 0;
43004         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43005         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43006         return ret_ref;
43007 }
43008
43009 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
43010         LDKBuiltCommitmentTransaction this_obj_conv;
43011         this_obj_conv.inner = untag_ptr(this_obj);
43012         this_obj_conv.is_owned = ptr_is_owned(this_obj);
43013         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
43014         BuiltCommitmentTransaction_free(this_obj_conv);
43015 }
43016
43017 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1get_1transaction(JNIEnv *env, jclass clz, int64_t this_ptr) {
43018         LDKBuiltCommitmentTransaction this_ptr_conv;
43019         this_ptr_conv.inner = untag_ptr(this_ptr);
43020         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43021         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43022         this_ptr_conv.is_owned = false;
43023         LDKTransaction ret_var = BuiltCommitmentTransaction_get_transaction(&this_ptr_conv);
43024         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
43025         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
43026         Transaction_free(ret_var);
43027         return ret_arr;
43028 }
43029
43030 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1set_1transaction(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
43031         LDKBuiltCommitmentTransaction this_ptr_conv;
43032         this_ptr_conv.inner = untag_ptr(this_ptr);
43033         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43034         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43035         this_ptr_conv.is_owned = false;
43036         LDKTransaction val_ref;
43037         val_ref.datalen = (*env)->GetArrayLength(env, val);
43038         val_ref.data = MALLOC(val_ref.datalen, "LDKTransaction Bytes");
43039         (*env)->GetByteArrayRegion(env, val, 0, val_ref.datalen, val_ref.data);
43040         val_ref.data_is_owned = true;
43041         BuiltCommitmentTransaction_set_transaction(&this_ptr_conv, val_ref);
43042 }
43043
43044 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1get_1txid(JNIEnv *env, jclass clz, int64_t this_ptr) {
43045         LDKBuiltCommitmentTransaction this_ptr_conv;
43046         this_ptr_conv.inner = untag_ptr(this_ptr);
43047         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43048         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43049         this_ptr_conv.is_owned = false;
43050         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
43051         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *BuiltCommitmentTransaction_get_txid(&this_ptr_conv));
43052         return ret_arr;
43053 }
43054
43055 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1set_1txid(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
43056         LDKBuiltCommitmentTransaction this_ptr_conv;
43057         this_ptr_conv.inner = untag_ptr(this_ptr);
43058         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
43059         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
43060         this_ptr_conv.is_owned = false;
43061         LDKThirtyTwoBytes val_ref;
43062         CHECK((*env)->GetArrayLength(env, val) == 32);
43063         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
43064         BuiltCommitmentTransaction_set_txid(&this_ptr_conv, val_ref);
43065 }
43066
43067 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1new(JNIEnv *env, jclass clz, int8_tArray transaction_arg, int8_tArray txid_arg) {
43068         LDKTransaction transaction_arg_ref;
43069         transaction_arg_ref.datalen = (*env)->GetArrayLength(env, transaction_arg);
43070         transaction_arg_ref.data = MALLOC(transaction_arg_ref.datalen, "LDKTransaction Bytes");
43071         (*env)->GetByteArrayRegion(env, transaction_arg, 0, transaction_arg_ref.datalen, transaction_arg_ref.data);
43072         transaction_arg_ref.data_is_owned = true;
43073         LDKThirtyTwoBytes txid_arg_ref;
43074         CHECK((*env)->GetArrayLength(env, txid_arg) == 32);
43075         (*env)->GetByteArrayRegion(env, txid_arg, 0, 32, txid_arg_ref.data);
43076         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_new(transaction_arg_ref, txid_arg_ref);
43077         int64_t ret_ref = 0;
43078         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43079         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43080         return ret_ref;
43081 }
43082
43083 static inline uint64_t BuiltCommitmentTransaction_clone_ptr(LDKBuiltCommitmentTransaction *NONNULL_PTR arg) {
43084         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_clone(arg);
43085         int64_t ret_ref = 0;
43086         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43087         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43088         return ret_ref;
43089 }
43090 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
43091         LDKBuiltCommitmentTransaction arg_conv;
43092         arg_conv.inner = untag_ptr(arg);
43093         arg_conv.is_owned = ptr_is_owned(arg);
43094         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
43095         arg_conv.is_owned = false;
43096         int64_t ret_conv = BuiltCommitmentTransaction_clone_ptr(&arg_conv);
43097         return ret_conv;
43098 }
43099
43100 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
43101         LDKBuiltCommitmentTransaction orig_conv;
43102         orig_conv.inner = untag_ptr(orig);
43103         orig_conv.is_owned = ptr_is_owned(orig);
43104         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
43105         orig_conv.is_owned = false;
43106         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_clone(&orig_conv);
43107         int64_t ret_ref = 0;
43108         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43109         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43110         return ret_ref;
43111 }
43112
43113 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1write(JNIEnv *env, jclass clz, int64_t obj) {
43114         LDKBuiltCommitmentTransaction obj_conv;
43115         obj_conv.inner = untag_ptr(obj);
43116         obj_conv.is_owned = ptr_is_owned(obj);
43117         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
43118         obj_conv.is_owned = false;
43119         LDKCVec_u8Z ret_var = BuiltCommitmentTransaction_write(&obj_conv);
43120         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
43121         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
43122         CVec_u8Z_free(ret_var);
43123         return ret_arr;
43124 }
43125
43126 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
43127         LDKu8slice ser_ref;
43128         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
43129         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
43130         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
43131         *ret_conv = BuiltCommitmentTransaction_read(ser_ref);
43132         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
43133         return tag_ptr(ret_conv, true);
43134 }
43135
43136 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) {
43137         LDKBuiltCommitmentTransaction this_arg_conv;
43138         this_arg_conv.inner = untag_ptr(this_arg);
43139         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43140         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43141         this_arg_conv.is_owned = false;
43142         LDKu8slice funding_redeemscript_ref;
43143         funding_redeemscript_ref.datalen = (*env)->GetArrayLength(env, funding_redeemscript);
43144         funding_redeemscript_ref.data = (*env)->GetByteArrayElements (env, funding_redeemscript, NULL);
43145         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
43146         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, BuiltCommitmentTransaction_get_sighash_all(&this_arg_conv, funding_redeemscript_ref, channel_value_satoshis).data);
43147         (*env)->ReleaseByteArrayElements(env, funding_redeemscript, (int8_t*)funding_redeemscript_ref.data, 0);
43148         return ret_arr;
43149 }
43150
43151 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) {
43152         LDKBuiltCommitmentTransaction this_arg_conv;
43153         this_arg_conv.inner = untag_ptr(this_arg);
43154         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43155         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43156         this_arg_conv.is_owned = false;
43157         unsigned char funding_key_arr[32];
43158         CHECK((*env)->GetArrayLength(env, funding_key) == 32);
43159         (*env)->GetByteArrayRegion(env, funding_key, 0, 32, funding_key_arr);
43160         unsigned char (*funding_key_ref)[32] = &funding_key_arr;
43161         LDKu8slice funding_redeemscript_ref;
43162         funding_redeemscript_ref.datalen = (*env)->GetArrayLength(env, funding_redeemscript);
43163         funding_redeemscript_ref.data = (*env)->GetByteArrayElements (env, funding_redeemscript, NULL);
43164         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
43165         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, BuiltCommitmentTransaction_sign(&this_arg_conv, funding_key_ref, funding_redeemscript_ref, channel_value_satoshis).compact_form);
43166         (*env)->ReleaseByteArrayElements(env, funding_redeemscript, (int8_t*)funding_redeemscript_ref.data, 0);
43167         return ret_arr;
43168 }
43169
43170 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
43171         LDKClosingTransaction this_obj_conv;
43172         this_obj_conv.inner = untag_ptr(this_obj);
43173         this_obj_conv.is_owned = ptr_is_owned(this_obj);
43174         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
43175         ClosingTransaction_free(this_obj_conv);
43176 }
43177
43178 static inline uint64_t ClosingTransaction_clone_ptr(LDKClosingTransaction *NONNULL_PTR arg) {
43179         LDKClosingTransaction ret_var = ClosingTransaction_clone(arg);
43180         int64_t ret_ref = 0;
43181         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43182         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43183         return ret_ref;
43184 }
43185 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
43186         LDKClosingTransaction arg_conv;
43187         arg_conv.inner = untag_ptr(arg);
43188         arg_conv.is_owned = ptr_is_owned(arg);
43189         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
43190         arg_conv.is_owned = false;
43191         int64_t ret_conv = ClosingTransaction_clone_ptr(&arg_conv);
43192         return ret_conv;
43193 }
43194
43195 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
43196         LDKClosingTransaction orig_conv;
43197         orig_conv.inner = untag_ptr(orig);
43198         orig_conv.is_owned = ptr_is_owned(orig);
43199         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
43200         orig_conv.is_owned = false;
43201         LDKClosingTransaction ret_var = ClosingTransaction_clone(&orig_conv);
43202         int64_t ret_ref = 0;
43203         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43204         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43205         return ret_ref;
43206 }
43207
43208 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1hash(JNIEnv *env, jclass clz, int64_t o) {
43209         LDKClosingTransaction o_conv;
43210         o_conv.inner = untag_ptr(o);
43211         o_conv.is_owned = ptr_is_owned(o);
43212         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
43213         o_conv.is_owned = false;
43214         int64_t ret_conv = ClosingTransaction_hash(&o_conv);
43215         return ret_conv;
43216 }
43217
43218 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
43219         LDKClosingTransaction a_conv;
43220         a_conv.inner = untag_ptr(a);
43221         a_conv.is_owned = ptr_is_owned(a);
43222         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
43223         a_conv.is_owned = false;
43224         LDKClosingTransaction b_conv;
43225         b_conv.inner = untag_ptr(b);
43226         b_conv.is_owned = ptr_is_owned(b);
43227         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
43228         b_conv.is_owned = false;
43229         jboolean ret_conv = ClosingTransaction_eq(&a_conv, &b_conv);
43230         return ret_conv;
43231 }
43232
43233 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) {
43234         LDKCVec_u8Z to_holder_script_ref;
43235         to_holder_script_ref.datalen = (*env)->GetArrayLength(env, to_holder_script);
43236         to_holder_script_ref.data = MALLOC(to_holder_script_ref.datalen, "LDKCVec_u8Z Bytes");
43237         (*env)->GetByteArrayRegion(env, to_holder_script, 0, to_holder_script_ref.datalen, to_holder_script_ref.data);
43238         LDKCVec_u8Z to_counterparty_script_ref;
43239         to_counterparty_script_ref.datalen = (*env)->GetArrayLength(env, to_counterparty_script);
43240         to_counterparty_script_ref.data = MALLOC(to_counterparty_script_ref.datalen, "LDKCVec_u8Z Bytes");
43241         (*env)->GetByteArrayRegion(env, to_counterparty_script, 0, to_counterparty_script_ref.datalen, to_counterparty_script_ref.data);
43242         LDKOutPoint funding_outpoint_conv;
43243         funding_outpoint_conv.inner = untag_ptr(funding_outpoint);
43244         funding_outpoint_conv.is_owned = ptr_is_owned(funding_outpoint);
43245         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_outpoint_conv);
43246         funding_outpoint_conv = OutPoint_clone(&funding_outpoint_conv);
43247         LDKClosingTransaction ret_var = ClosingTransaction_new(to_holder_value_sat, to_counterparty_value_sat, to_holder_script_ref, to_counterparty_script_ref, funding_outpoint_conv);
43248         int64_t ret_ref = 0;
43249         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43250         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43251         return ret_ref;
43252 }
43253
43254 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1trust(JNIEnv *env, jclass clz, int64_t this_arg) {
43255         LDKClosingTransaction this_arg_conv;
43256         this_arg_conv.inner = untag_ptr(this_arg);
43257         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43258         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43259         this_arg_conv.is_owned = false;
43260         LDKTrustedClosingTransaction ret_var = ClosingTransaction_trust(&this_arg_conv);
43261         int64_t ret_ref = 0;
43262         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43263         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43264         return ret_ref;
43265 }
43266
43267 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1verify(JNIEnv *env, jclass clz, int64_t this_arg, int64_t funding_outpoint) {
43268         LDKClosingTransaction this_arg_conv;
43269         this_arg_conv.inner = untag_ptr(this_arg);
43270         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43271         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43272         this_arg_conv.is_owned = false;
43273         LDKOutPoint funding_outpoint_conv;
43274         funding_outpoint_conv.inner = untag_ptr(funding_outpoint);
43275         funding_outpoint_conv.is_owned = ptr_is_owned(funding_outpoint);
43276         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_outpoint_conv);
43277         funding_outpoint_conv = OutPoint_clone(&funding_outpoint_conv);
43278         LDKCResult_TrustedClosingTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedClosingTransactionNoneZ), "LDKCResult_TrustedClosingTransactionNoneZ");
43279         *ret_conv = ClosingTransaction_verify(&this_arg_conv, funding_outpoint_conv);
43280         return tag_ptr(ret_conv, true);
43281 }
43282
43283 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1to_1holder_1value_1sat(JNIEnv *env, jclass clz, int64_t this_arg) {
43284         LDKClosingTransaction this_arg_conv;
43285         this_arg_conv.inner = untag_ptr(this_arg);
43286         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43287         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43288         this_arg_conv.is_owned = false;
43289         int64_t ret_conv = ClosingTransaction_to_holder_value_sat(&this_arg_conv);
43290         return ret_conv;
43291 }
43292
43293 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1to_1counterparty_1value_1sat(JNIEnv *env, jclass clz, int64_t this_arg) {
43294         LDKClosingTransaction this_arg_conv;
43295         this_arg_conv.inner = untag_ptr(this_arg);
43296         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43297         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43298         this_arg_conv.is_owned = false;
43299         int64_t ret_conv = ClosingTransaction_to_counterparty_value_sat(&this_arg_conv);
43300         return ret_conv;
43301 }
43302
43303 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1to_1holder_1script(JNIEnv *env, jclass clz, int64_t this_arg) {
43304         LDKClosingTransaction this_arg_conv;
43305         this_arg_conv.inner = untag_ptr(this_arg);
43306         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43307         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43308         this_arg_conv.is_owned = false;
43309         LDKu8slice ret_var = ClosingTransaction_to_holder_script(&this_arg_conv);
43310         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
43311         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
43312         return ret_arr;
43313 }
43314
43315 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1to_1counterparty_1script(JNIEnv *env, jclass clz, int64_t this_arg) {
43316         LDKClosingTransaction this_arg_conv;
43317         this_arg_conv.inner = untag_ptr(this_arg);
43318         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43319         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43320         this_arg_conv.is_owned = false;
43321         LDKu8slice ret_var = ClosingTransaction_to_counterparty_script(&this_arg_conv);
43322         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
43323         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
43324         return ret_arr;
43325 }
43326
43327 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TrustedClosingTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
43328         LDKTrustedClosingTransaction this_obj_conv;
43329         this_obj_conv.inner = untag_ptr(this_obj);
43330         this_obj_conv.is_owned = ptr_is_owned(this_obj);
43331         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
43332         TrustedClosingTransaction_free(this_obj_conv);
43333 }
43334
43335 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TrustedClosingTransaction_1built_1transaction(JNIEnv *env, jclass clz, int64_t this_arg) {
43336         LDKTrustedClosingTransaction this_arg_conv;
43337         this_arg_conv.inner = untag_ptr(this_arg);
43338         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43339         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43340         this_arg_conv.is_owned = false;
43341         LDKTransaction ret_var = TrustedClosingTransaction_built_transaction(&this_arg_conv);
43342         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
43343         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
43344         Transaction_free(ret_var);
43345         return ret_arr;
43346 }
43347
43348 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) {
43349         LDKTrustedClosingTransaction this_arg_conv;
43350         this_arg_conv.inner = untag_ptr(this_arg);
43351         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43352         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43353         this_arg_conv.is_owned = false;
43354         LDKu8slice funding_redeemscript_ref;
43355         funding_redeemscript_ref.datalen = (*env)->GetArrayLength(env, funding_redeemscript);
43356         funding_redeemscript_ref.data = (*env)->GetByteArrayElements (env, funding_redeemscript, NULL);
43357         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
43358         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, TrustedClosingTransaction_get_sighash_all(&this_arg_conv, funding_redeemscript_ref, channel_value_satoshis).data);
43359         (*env)->ReleaseByteArrayElements(env, funding_redeemscript, (int8_t*)funding_redeemscript_ref.data, 0);
43360         return ret_arr;
43361 }
43362
43363 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) {
43364         LDKTrustedClosingTransaction this_arg_conv;
43365         this_arg_conv.inner = untag_ptr(this_arg);
43366         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43367         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43368         this_arg_conv.is_owned = false;
43369         unsigned char funding_key_arr[32];
43370         CHECK((*env)->GetArrayLength(env, funding_key) == 32);
43371         (*env)->GetByteArrayRegion(env, funding_key, 0, 32, funding_key_arr);
43372         unsigned char (*funding_key_ref)[32] = &funding_key_arr;
43373         LDKu8slice funding_redeemscript_ref;
43374         funding_redeemscript_ref.datalen = (*env)->GetArrayLength(env, funding_redeemscript);
43375         funding_redeemscript_ref.data = (*env)->GetByteArrayElements (env, funding_redeemscript, NULL);
43376         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
43377         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, TrustedClosingTransaction_sign(&this_arg_conv, funding_key_ref, funding_redeemscript_ref, channel_value_satoshis).compact_form);
43378         (*env)->ReleaseByteArrayElements(env, funding_redeemscript, (int8_t*)funding_redeemscript_ref.data, 0);
43379         return ret_arr;
43380 }
43381
43382 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
43383         LDKCommitmentTransaction this_obj_conv;
43384         this_obj_conv.inner = untag_ptr(this_obj);
43385         this_obj_conv.is_owned = ptr_is_owned(this_obj);
43386         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
43387         CommitmentTransaction_free(this_obj_conv);
43388 }
43389
43390 static inline uint64_t CommitmentTransaction_clone_ptr(LDKCommitmentTransaction *NONNULL_PTR arg) {
43391         LDKCommitmentTransaction ret_var = CommitmentTransaction_clone(arg);
43392         int64_t ret_ref = 0;
43393         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43394         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43395         return ret_ref;
43396 }
43397 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
43398         LDKCommitmentTransaction arg_conv;
43399         arg_conv.inner = untag_ptr(arg);
43400         arg_conv.is_owned = ptr_is_owned(arg);
43401         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
43402         arg_conv.is_owned = false;
43403         int64_t ret_conv = CommitmentTransaction_clone_ptr(&arg_conv);
43404         return ret_conv;
43405 }
43406
43407 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
43408         LDKCommitmentTransaction orig_conv;
43409         orig_conv.inner = untag_ptr(orig);
43410         orig_conv.is_owned = ptr_is_owned(orig);
43411         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
43412         orig_conv.is_owned = false;
43413         LDKCommitmentTransaction ret_var = CommitmentTransaction_clone(&orig_conv);
43414         int64_t ret_ref = 0;
43415         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43416         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43417         return ret_ref;
43418 }
43419
43420 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1write(JNIEnv *env, jclass clz, int64_t obj) {
43421         LDKCommitmentTransaction obj_conv;
43422         obj_conv.inner = untag_ptr(obj);
43423         obj_conv.is_owned = ptr_is_owned(obj);
43424         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
43425         obj_conv.is_owned = false;
43426         LDKCVec_u8Z ret_var = CommitmentTransaction_write(&obj_conv);
43427         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
43428         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
43429         CVec_u8Z_free(ret_var);
43430         return ret_arr;
43431 }
43432
43433 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
43434         LDKu8slice ser_ref;
43435         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
43436         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
43437         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
43438         *ret_conv = CommitmentTransaction_read(ser_ref);
43439         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
43440         return tag_ptr(ret_conv, true);
43441 }
43442
43443 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1commitment_1number(JNIEnv *env, jclass clz, int64_t this_arg) {
43444         LDKCommitmentTransaction this_arg_conv;
43445         this_arg_conv.inner = untag_ptr(this_arg);
43446         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43447         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43448         this_arg_conv.is_owned = false;
43449         int64_t ret_conv = CommitmentTransaction_commitment_number(&this_arg_conv);
43450         return ret_conv;
43451 }
43452
43453 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1to_1broadcaster_1value_1sat(JNIEnv *env, jclass clz, int64_t this_arg) {
43454         LDKCommitmentTransaction this_arg_conv;
43455         this_arg_conv.inner = untag_ptr(this_arg);
43456         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43457         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43458         this_arg_conv.is_owned = false;
43459         int64_t ret_conv = CommitmentTransaction_to_broadcaster_value_sat(&this_arg_conv);
43460         return ret_conv;
43461 }
43462
43463 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1to_1countersignatory_1value_1sat(JNIEnv *env, jclass clz, int64_t this_arg) {
43464         LDKCommitmentTransaction this_arg_conv;
43465         this_arg_conv.inner = untag_ptr(this_arg);
43466         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43467         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43468         this_arg_conv.is_owned = false;
43469         int64_t ret_conv = CommitmentTransaction_to_countersignatory_value_sat(&this_arg_conv);
43470         return ret_conv;
43471 }
43472
43473 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_arg) {
43474         LDKCommitmentTransaction this_arg_conv;
43475         this_arg_conv.inner = untag_ptr(this_arg);
43476         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43477         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43478         this_arg_conv.is_owned = false;
43479         int32_t ret_conv = CommitmentTransaction_feerate_per_kw(&this_arg_conv);
43480         return ret_conv;
43481 }
43482
43483 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1trust(JNIEnv *env, jclass clz, int64_t this_arg) {
43484         LDKCommitmentTransaction this_arg_conv;
43485         this_arg_conv.inner = untag_ptr(this_arg);
43486         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43487         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43488         this_arg_conv.is_owned = false;
43489         LDKTrustedCommitmentTransaction ret_var = CommitmentTransaction_trust(&this_arg_conv);
43490         int64_t ret_ref = 0;
43491         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43492         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43493         return ret_ref;
43494 }
43495
43496 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) {
43497         LDKCommitmentTransaction this_arg_conv;
43498         this_arg_conv.inner = untag_ptr(this_arg);
43499         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43500         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43501         this_arg_conv.is_owned = false;
43502         LDKDirectedChannelTransactionParameters channel_parameters_conv;
43503         channel_parameters_conv.inner = untag_ptr(channel_parameters);
43504         channel_parameters_conv.is_owned = ptr_is_owned(channel_parameters);
43505         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_parameters_conv);
43506         channel_parameters_conv.is_owned = false;
43507         LDKChannelPublicKeys broadcaster_keys_conv;
43508         broadcaster_keys_conv.inner = untag_ptr(broadcaster_keys);
43509         broadcaster_keys_conv.is_owned = ptr_is_owned(broadcaster_keys);
43510         CHECK_INNER_FIELD_ACCESS_OR_NULL(broadcaster_keys_conv);
43511         broadcaster_keys_conv.is_owned = false;
43512         LDKChannelPublicKeys countersignatory_keys_conv;
43513         countersignatory_keys_conv.inner = untag_ptr(countersignatory_keys);
43514         countersignatory_keys_conv.is_owned = ptr_is_owned(countersignatory_keys);
43515         CHECK_INNER_FIELD_ACCESS_OR_NULL(countersignatory_keys_conv);
43516         countersignatory_keys_conv.is_owned = false;
43517         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
43518         *ret_conv = CommitmentTransaction_verify(&this_arg_conv, &channel_parameters_conv, &broadcaster_keys_conv, &countersignatory_keys_conv);
43519         return tag_ptr(ret_conv, true);
43520 }
43521
43522 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
43523         LDKTrustedCommitmentTransaction this_obj_conv;
43524         this_obj_conv.inner = untag_ptr(this_obj);
43525         this_obj_conv.is_owned = ptr_is_owned(this_obj);
43526         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
43527         TrustedCommitmentTransaction_free(this_obj_conv);
43528 }
43529
43530 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1txid(JNIEnv *env, jclass clz, int64_t this_arg) {
43531         LDKTrustedCommitmentTransaction this_arg_conv;
43532         this_arg_conv.inner = untag_ptr(this_arg);
43533         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43534         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43535         this_arg_conv.is_owned = false;
43536         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
43537         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, TrustedCommitmentTransaction_txid(&this_arg_conv).data);
43538         return ret_arr;
43539 }
43540
43541 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1built_1transaction(JNIEnv *env, jclass clz, int64_t this_arg) {
43542         LDKTrustedCommitmentTransaction this_arg_conv;
43543         this_arg_conv.inner = untag_ptr(this_arg);
43544         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43545         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43546         this_arg_conv.is_owned = false;
43547         LDKBuiltCommitmentTransaction ret_var = TrustedCommitmentTransaction_built_transaction(&this_arg_conv);
43548         int64_t ret_ref = 0;
43549         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43550         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43551         return ret_ref;
43552 }
43553
43554 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1keys(JNIEnv *env, jclass clz, int64_t this_arg) {
43555         LDKTrustedCommitmentTransaction this_arg_conv;
43556         this_arg_conv.inner = untag_ptr(this_arg);
43557         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43558         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43559         this_arg_conv.is_owned = false;
43560         LDKTxCreationKeys ret_var = TrustedCommitmentTransaction_keys(&this_arg_conv);
43561         int64_t ret_ref = 0;
43562         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43563         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43564         return ret_ref;
43565 }
43566
43567 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1opt_1anchors(JNIEnv *env, jclass clz, int64_t this_arg) {
43568         LDKTrustedCommitmentTransaction this_arg_conv;
43569         this_arg_conv.inner = untag_ptr(this_arg);
43570         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43571         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43572         this_arg_conv.is_owned = false;
43573         jboolean ret_conv = TrustedCommitmentTransaction_opt_anchors(&this_arg_conv);
43574         return ret_conv;
43575 }
43576
43577 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) {
43578         LDKTrustedCommitmentTransaction this_arg_conv;
43579         this_arg_conv.inner = untag_ptr(this_arg);
43580         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43581         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43582         this_arg_conv.is_owned = false;
43583         unsigned char htlc_base_key_arr[32];
43584         CHECK((*env)->GetArrayLength(env, htlc_base_key) == 32);
43585         (*env)->GetByteArrayRegion(env, htlc_base_key, 0, 32, htlc_base_key_arr);
43586         unsigned char (*htlc_base_key_ref)[32] = &htlc_base_key_arr;
43587         LDKDirectedChannelTransactionParameters channel_parameters_conv;
43588         channel_parameters_conv.inner = untag_ptr(channel_parameters);
43589         channel_parameters_conv.is_owned = ptr_is_owned(channel_parameters);
43590         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_parameters_conv);
43591         channel_parameters_conv.is_owned = false;
43592         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
43593         *ret_conv = TrustedCommitmentTransaction_get_htlc_sigs(&this_arg_conv, htlc_base_key_ref, &channel_parameters_conv);
43594         return tag_ptr(ret_conv, true);
43595 }
43596
43597 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) {
43598         LDKPublicKey broadcaster_payment_basepoint_ref;
43599         CHECK((*env)->GetArrayLength(env, broadcaster_payment_basepoint) == 33);
43600         (*env)->GetByteArrayRegion(env, broadcaster_payment_basepoint, 0, 33, broadcaster_payment_basepoint_ref.compressed_form);
43601         LDKPublicKey countersignatory_payment_basepoint_ref;
43602         CHECK((*env)->GetArrayLength(env, countersignatory_payment_basepoint) == 33);
43603         (*env)->GetByteArrayRegion(env, countersignatory_payment_basepoint, 0, 33, countersignatory_payment_basepoint_ref.compressed_form);
43604         int64_t ret_conv = get_commitment_transaction_number_obscure_factor(broadcaster_payment_basepoint_ref, countersignatory_payment_basepoint_ref, outbound_from_broadcaster);
43605         return ret_conv;
43606 }
43607
43608 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
43609         LDKInitFeatures a_conv;
43610         a_conv.inner = untag_ptr(a);
43611         a_conv.is_owned = ptr_is_owned(a);
43612         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
43613         a_conv.is_owned = false;
43614         LDKInitFeatures b_conv;
43615         b_conv.inner = untag_ptr(b);
43616         b_conv.is_owned = ptr_is_owned(b);
43617         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
43618         b_conv.is_owned = false;
43619         jboolean ret_conv = InitFeatures_eq(&a_conv, &b_conv);
43620         return ret_conv;
43621 }
43622
43623 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
43624         LDKNodeFeatures a_conv;
43625         a_conv.inner = untag_ptr(a);
43626         a_conv.is_owned = ptr_is_owned(a);
43627         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
43628         a_conv.is_owned = false;
43629         LDKNodeFeatures b_conv;
43630         b_conv.inner = untag_ptr(b);
43631         b_conv.is_owned = ptr_is_owned(b);
43632         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
43633         b_conv.is_owned = false;
43634         jboolean ret_conv = NodeFeatures_eq(&a_conv, &b_conv);
43635         return ret_conv;
43636 }
43637
43638 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
43639         LDKChannelFeatures a_conv;
43640         a_conv.inner = untag_ptr(a);
43641         a_conv.is_owned = ptr_is_owned(a);
43642         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
43643         a_conv.is_owned = false;
43644         LDKChannelFeatures b_conv;
43645         b_conv.inner = untag_ptr(b);
43646         b_conv.is_owned = ptr_is_owned(b);
43647         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
43648         b_conv.is_owned = false;
43649         jboolean ret_conv = ChannelFeatures_eq(&a_conv, &b_conv);
43650         return ret_conv;
43651 }
43652
43653 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
43654         LDKInvoiceFeatures a_conv;
43655         a_conv.inner = untag_ptr(a);
43656         a_conv.is_owned = ptr_is_owned(a);
43657         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
43658         a_conv.is_owned = false;
43659         LDKInvoiceFeatures b_conv;
43660         b_conv.inner = untag_ptr(b);
43661         b_conv.is_owned = ptr_is_owned(b);
43662         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
43663         b_conv.is_owned = false;
43664         jboolean ret_conv = InvoiceFeatures_eq(&a_conv, &b_conv);
43665         return ret_conv;
43666 }
43667
43668 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_OfferFeatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
43669         LDKOfferFeatures a_conv;
43670         a_conv.inner = untag_ptr(a);
43671         a_conv.is_owned = ptr_is_owned(a);
43672         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
43673         a_conv.is_owned = false;
43674         LDKOfferFeatures b_conv;
43675         b_conv.inner = untag_ptr(b);
43676         b_conv.is_owned = ptr_is_owned(b);
43677         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
43678         b_conv.is_owned = false;
43679         jboolean ret_conv = OfferFeatures_eq(&a_conv, &b_conv);
43680         return ret_conv;
43681 }
43682
43683 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceRequestFeatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
43684         LDKInvoiceRequestFeatures a_conv;
43685         a_conv.inner = untag_ptr(a);
43686         a_conv.is_owned = ptr_is_owned(a);
43687         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
43688         a_conv.is_owned = false;
43689         LDKInvoiceRequestFeatures b_conv;
43690         b_conv.inner = untag_ptr(b);
43691         b_conv.is_owned = ptr_is_owned(b);
43692         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
43693         b_conv.is_owned = false;
43694         jboolean ret_conv = InvoiceRequestFeatures_eq(&a_conv, &b_conv);
43695         return ret_conv;
43696 }
43697
43698 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
43699         LDKChannelTypeFeatures a_conv;
43700         a_conv.inner = untag_ptr(a);
43701         a_conv.is_owned = ptr_is_owned(a);
43702         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
43703         a_conv.is_owned = false;
43704         LDKChannelTypeFeatures b_conv;
43705         b_conv.inner = untag_ptr(b);
43706         b_conv.is_owned = ptr_is_owned(b);
43707         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
43708         b_conv.is_owned = false;
43709         jboolean ret_conv = ChannelTypeFeatures_eq(&a_conv, &b_conv);
43710         return ret_conv;
43711 }
43712
43713 static inline uint64_t InitFeatures_clone_ptr(LDKInitFeatures *NONNULL_PTR arg) {
43714         LDKInitFeatures ret_var = InitFeatures_clone(arg);
43715         int64_t ret_ref = 0;
43716         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43717         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43718         return ret_ref;
43719 }
43720 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
43721         LDKInitFeatures arg_conv;
43722         arg_conv.inner = untag_ptr(arg);
43723         arg_conv.is_owned = ptr_is_owned(arg);
43724         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
43725         arg_conv.is_owned = false;
43726         int64_t ret_conv = InitFeatures_clone_ptr(&arg_conv);
43727         return ret_conv;
43728 }
43729
43730 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
43731         LDKInitFeatures orig_conv;
43732         orig_conv.inner = untag_ptr(orig);
43733         orig_conv.is_owned = ptr_is_owned(orig);
43734         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
43735         orig_conv.is_owned = false;
43736         LDKInitFeatures ret_var = InitFeatures_clone(&orig_conv);
43737         int64_t ret_ref = 0;
43738         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43739         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43740         return ret_ref;
43741 }
43742
43743 static inline uint64_t NodeFeatures_clone_ptr(LDKNodeFeatures *NONNULL_PTR arg) {
43744         LDKNodeFeatures ret_var = NodeFeatures_clone(arg);
43745         int64_t ret_ref = 0;
43746         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43747         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43748         return ret_ref;
43749 }
43750 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
43751         LDKNodeFeatures arg_conv;
43752         arg_conv.inner = untag_ptr(arg);
43753         arg_conv.is_owned = ptr_is_owned(arg);
43754         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
43755         arg_conv.is_owned = false;
43756         int64_t ret_conv = NodeFeatures_clone_ptr(&arg_conv);
43757         return ret_conv;
43758 }
43759
43760 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
43761         LDKNodeFeatures orig_conv;
43762         orig_conv.inner = untag_ptr(orig);
43763         orig_conv.is_owned = ptr_is_owned(orig);
43764         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
43765         orig_conv.is_owned = false;
43766         LDKNodeFeatures ret_var = NodeFeatures_clone(&orig_conv);
43767         int64_t ret_ref = 0;
43768         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43769         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43770         return ret_ref;
43771 }
43772
43773 static inline uint64_t ChannelFeatures_clone_ptr(LDKChannelFeatures *NONNULL_PTR arg) {
43774         LDKChannelFeatures ret_var = ChannelFeatures_clone(arg);
43775         int64_t ret_ref = 0;
43776         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43777         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43778         return ret_ref;
43779 }
43780 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
43781         LDKChannelFeatures arg_conv;
43782         arg_conv.inner = untag_ptr(arg);
43783         arg_conv.is_owned = ptr_is_owned(arg);
43784         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
43785         arg_conv.is_owned = false;
43786         int64_t ret_conv = ChannelFeatures_clone_ptr(&arg_conv);
43787         return ret_conv;
43788 }
43789
43790 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
43791         LDKChannelFeatures orig_conv;
43792         orig_conv.inner = untag_ptr(orig);
43793         orig_conv.is_owned = ptr_is_owned(orig);
43794         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
43795         orig_conv.is_owned = false;
43796         LDKChannelFeatures ret_var = ChannelFeatures_clone(&orig_conv);
43797         int64_t ret_ref = 0;
43798         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43799         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43800         return ret_ref;
43801 }
43802
43803 static inline uint64_t InvoiceFeatures_clone_ptr(LDKInvoiceFeatures *NONNULL_PTR arg) {
43804         LDKInvoiceFeatures ret_var = InvoiceFeatures_clone(arg);
43805         int64_t ret_ref = 0;
43806         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43807         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43808         return ret_ref;
43809 }
43810 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
43811         LDKInvoiceFeatures arg_conv;
43812         arg_conv.inner = untag_ptr(arg);
43813         arg_conv.is_owned = ptr_is_owned(arg);
43814         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
43815         arg_conv.is_owned = false;
43816         int64_t ret_conv = InvoiceFeatures_clone_ptr(&arg_conv);
43817         return ret_conv;
43818 }
43819
43820 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
43821         LDKInvoiceFeatures orig_conv;
43822         orig_conv.inner = untag_ptr(orig);
43823         orig_conv.is_owned = ptr_is_owned(orig);
43824         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
43825         orig_conv.is_owned = false;
43826         LDKInvoiceFeatures ret_var = InvoiceFeatures_clone(&orig_conv);
43827         int64_t ret_ref = 0;
43828         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43829         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43830         return ret_ref;
43831 }
43832
43833 static inline uint64_t OfferFeatures_clone_ptr(LDKOfferFeatures *NONNULL_PTR arg) {
43834         LDKOfferFeatures ret_var = OfferFeatures_clone(arg);
43835         int64_t ret_ref = 0;
43836         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43837         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43838         return ret_ref;
43839 }
43840 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OfferFeatures_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
43841         LDKOfferFeatures arg_conv;
43842         arg_conv.inner = untag_ptr(arg);
43843         arg_conv.is_owned = ptr_is_owned(arg);
43844         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
43845         arg_conv.is_owned = false;
43846         int64_t ret_conv = OfferFeatures_clone_ptr(&arg_conv);
43847         return ret_conv;
43848 }
43849
43850 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OfferFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
43851         LDKOfferFeatures orig_conv;
43852         orig_conv.inner = untag_ptr(orig);
43853         orig_conv.is_owned = ptr_is_owned(orig);
43854         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
43855         orig_conv.is_owned = false;
43856         LDKOfferFeatures ret_var = OfferFeatures_clone(&orig_conv);
43857         int64_t ret_ref = 0;
43858         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43859         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43860         return ret_ref;
43861 }
43862
43863 static inline uint64_t InvoiceRequestFeatures_clone_ptr(LDKInvoiceRequestFeatures *NONNULL_PTR arg) {
43864         LDKInvoiceRequestFeatures ret_var = InvoiceRequestFeatures_clone(arg);
43865         int64_t ret_ref = 0;
43866         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43867         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43868         return ret_ref;
43869 }
43870 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceRequestFeatures_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
43871         LDKInvoiceRequestFeatures arg_conv;
43872         arg_conv.inner = untag_ptr(arg);
43873         arg_conv.is_owned = ptr_is_owned(arg);
43874         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
43875         arg_conv.is_owned = false;
43876         int64_t ret_conv = InvoiceRequestFeatures_clone_ptr(&arg_conv);
43877         return ret_conv;
43878 }
43879
43880 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceRequestFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
43881         LDKInvoiceRequestFeatures orig_conv;
43882         orig_conv.inner = untag_ptr(orig);
43883         orig_conv.is_owned = ptr_is_owned(orig);
43884         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
43885         orig_conv.is_owned = false;
43886         LDKInvoiceRequestFeatures ret_var = InvoiceRequestFeatures_clone(&orig_conv);
43887         int64_t ret_ref = 0;
43888         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43889         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43890         return ret_ref;
43891 }
43892
43893 static inline uint64_t ChannelTypeFeatures_clone_ptr(LDKChannelTypeFeatures *NONNULL_PTR arg) {
43894         LDKChannelTypeFeatures ret_var = ChannelTypeFeatures_clone(arg);
43895         int64_t ret_ref = 0;
43896         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43897         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43898         return ret_ref;
43899 }
43900 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
43901         LDKChannelTypeFeatures arg_conv;
43902         arg_conv.inner = untag_ptr(arg);
43903         arg_conv.is_owned = ptr_is_owned(arg);
43904         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
43905         arg_conv.is_owned = false;
43906         int64_t ret_conv = ChannelTypeFeatures_clone_ptr(&arg_conv);
43907         return ret_conv;
43908 }
43909
43910 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
43911         LDKChannelTypeFeatures orig_conv;
43912         orig_conv.inner = untag_ptr(orig);
43913         orig_conv.is_owned = ptr_is_owned(orig);
43914         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
43915         orig_conv.is_owned = false;
43916         LDKChannelTypeFeatures ret_var = ChannelTypeFeatures_clone(&orig_conv);
43917         int64_t ret_ref = 0;
43918         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43919         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43920         return ret_ref;
43921 }
43922
43923 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
43924         LDKInitFeatures this_obj_conv;
43925         this_obj_conv.inner = untag_ptr(this_obj);
43926         this_obj_conv.is_owned = ptr_is_owned(this_obj);
43927         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
43928         InitFeatures_free(this_obj_conv);
43929 }
43930
43931 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
43932         LDKNodeFeatures this_obj_conv;
43933         this_obj_conv.inner = untag_ptr(this_obj);
43934         this_obj_conv.is_owned = ptr_is_owned(this_obj);
43935         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
43936         NodeFeatures_free(this_obj_conv);
43937 }
43938
43939 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
43940         LDKChannelFeatures this_obj_conv;
43941         this_obj_conv.inner = untag_ptr(this_obj);
43942         this_obj_conv.is_owned = ptr_is_owned(this_obj);
43943         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
43944         ChannelFeatures_free(this_obj_conv);
43945 }
43946
43947 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
43948         LDKInvoiceFeatures this_obj_conv;
43949         this_obj_conv.inner = untag_ptr(this_obj);
43950         this_obj_conv.is_owned = ptr_is_owned(this_obj);
43951         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
43952         InvoiceFeatures_free(this_obj_conv);
43953 }
43954
43955 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OfferFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
43956         LDKOfferFeatures this_obj_conv;
43957         this_obj_conv.inner = untag_ptr(this_obj);
43958         this_obj_conv.is_owned = ptr_is_owned(this_obj);
43959         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
43960         OfferFeatures_free(this_obj_conv);
43961 }
43962
43963 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoiceRequestFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
43964         LDKInvoiceRequestFeatures this_obj_conv;
43965         this_obj_conv.inner = untag_ptr(this_obj);
43966         this_obj_conv.is_owned = ptr_is_owned(this_obj);
43967         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
43968         InvoiceRequestFeatures_free(this_obj_conv);
43969 }
43970
43971 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
43972         LDKChannelTypeFeatures this_obj_conv;
43973         this_obj_conv.inner = untag_ptr(this_obj);
43974         this_obj_conv.is_owned = ptr_is_owned(this_obj);
43975         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
43976         ChannelTypeFeatures_free(this_obj_conv);
43977 }
43978
43979 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1empty(JNIEnv *env, jclass clz) {
43980         LDKInitFeatures ret_var = InitFeatures_empty();
43981         int64_t ret_ref = 0;
43982         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
43983         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
43984         return ret_ref;
43985 }
43986
43987 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1unknown_1bits(JNIEnv *env, jclass clz, int64_t this_arg) {
43988         LDKInitFeatures this_arg_conv;
43989         this_arg_conv.inner = untag_ptr(this_arg);
43990         this_arg_conv.is_owned = ptr_is_owned(this_arg);
43991         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
43992         this_arg_conv.is_owned = false;
43993         jboolean ret_conv = InitFeatures_requires_unknown_bits(&this_arg_conv);
43994         return ret_conv;
43995 }
43996
43997 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1empty(JNIEnv *env, jclass clz) {
43998         LDKNodeFeatures ret_var = NodeFeatures_empty();
43999         int64_t ret_ref = 0;
44000         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44001         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44002         return ret_ref;
44003 }
44004
44005 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1unknown_1bits(JNIEnv *env, jclass clz, int64_t this_arg) {
44006         LDKNodeFeatures this_arg_conv;
44007         this_arg_conv.inner = untag_ptr(this_arg);
44008         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44009         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44010         this_arg_conv.is_owned = false;
44011         jboolean ret_conv = NodeFeatures_requires_unknown_bits(&this_arg_conv);
44012         return ret_conv;
44013 }
44014
44015 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1empty(JNIEnv *env, jclass clz) {
44016         LDKChannelFeatures ret_var = ChannelFeatures_empty();
44017         int64_t ret_ref = 0;
44018         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44019         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44020         return ret_ref;
44021 }
44022
44023 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1requires_1unknown_1bits(JNIEnv *env, jclass clz, int64_t this_arg) {
44024         LDKChannelFeatures this_arg_conv;
44025         this_arg_conv.inner = untag_ptr(this_arg);
44026         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44027         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44028         this_arg_conv.is_owned = false;
44029         jboolean ret_conv = ChannelFeatures_requires_unknown_bits(&this_arg_conv);
44030         return ret_conv;
44031 }
44032
44033 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1empty(JNIEnv *env, jclass clz) {
44034         LDKInvoiceFeatures ret_var = InvoiceFeatures_empty();
44035         int64_t ret_ref = 0;
44036         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44037         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44038         return ret_ref;
44039 }
44040
44041 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1requires_1unknown_1bits(JNIEnv *env, jclass clz, int64_t this_arg) {
44042         LDKInvoiceFeatures this_arg_conv;
44043         this_arg_conv.inner = untag_ptr(this_arg);
44044         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44045         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44046         this_arg_conv.is_owned = false;
44047         jboolean ret_conv = InvoiceFeatures_requires_unknown_bits(&this_arg_conv);
44048         return ret_conv;
44049 }
44050
44051 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OfferFeatures_1empty(JNIEnv *env, jclass clz) {
44052         LDKOfferFeatures ret_var = OfferFeatures_empty();
44053         int64_t ret_ref = 0;
44054         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44055         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44056         return ret_ref;
44057 }
44058
44059 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_OfferFeatures_1requires_1unknown_1bits(JNIEnv *env, jclass clz, int64_t this_arg) {
44060         LDKOfferFeatures 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         jboolean ret_conv = OfferFeatures_requires_unknown_bits(&this_arg_conv);
44066         return ret_conv;
44067 }
44068
44069 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceRequestFeatures_1empty(JNIEnv *env, jclass clz) {
44070         LDKInvoiceRequestFeatures ret_var = InvoiceRequestFeatures_empty();
44071         int64_t ret_ref = 0;
44072         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44073         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44074         return ret_ref;
44075 }
44076
44077 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceRequestFeatures_1requires_1unknown_1bits(JNIEnv *env, jclass clz, int64_t this_arg) {
44078         LDKInvoiceRequestFeatures this_arg_conv;
44079         this_arg_conv.inner = untag_ptr(this_arg);
44080         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44081         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44082         this_arg_conv.is_owned = false;
44083         jboolean ret_conv = InvoiceRequestFeatures_requires_unknown_bits(&this_arg_conv);
44084         return ret_conv;
44085 }
44086
44087 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1empty(JNIEnv *env, jclass clz) {
44088         LDKChannelTypeFeatures ret_var = ChannelTypeFeatures_empty();
44089         int64_t ret_ref = 0;
44090         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
44091         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
44092         return ret_ref;
44093 }
44094
44095 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1requires_1unknown_1bits(JNIEnv *env, jclass clz, int64_t this_arg) {
44096         LDKChannelTypeFeatures this_arg_conv;
44097         this_arg_conv.inner = untag_ptr(this_arg);
44098         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44099         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44100         this_arg_conv.is_owned = false;
44101         jboolean ret_conv = ChannelTypeFeatures_requires_unknown_bits(&this_arg_conv);
44102         return ret_conv;
44103 }
44104
44105 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InitFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
44106         LDKInitFeatures obj_conv;
44107         obj_conv.inner = untag_ptr(obj);
44108         obj_conv.is_owned = ptr_is_owned(obj);
44109         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
44110         obj_conv.is_owned = false;
44111         LDKCVec_u8Z ret_var = InitFeatures_write(&obj_conv);
44112         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
44113         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
44114         CVec_u8Z_free(ret_var);
44115         return ret_arr;
44116 }
44117
44118 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
44119         LDKu8slice ser_ref;
44120         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
44121         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
44122         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
44123         *ret_conv = InitFeatures_read(ser_ref);
44124         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
44125         return tag_ptr(ret_conv, true);
44126 }
44127
44128 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
44129         LDKChannelFeatures obj_conv;
44130         obj_conv.inner = untag_ptr(obj);
44131         obj_conv.is_owned = ptr_is_owned(obj);
44132         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
44133         obj_conv.is_owned = false;
44134         LDKCVec_u8Z ret_var = ChannelFeatures_write(&obj_conv);
44135         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
44136         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
44137         CVec_u8Z_free(ret_var);
44138         return ret_arr;
44139 }
44140
44141 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
44142         LDKu8slice ser_ref;
44143         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
44144         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
44145         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
44146         *ret_conv = ChannelFeatures_read(ser_ref);
44147         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
44148         return tag_ptr(ret_conv, true);
44149 }
44150
44151 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
44152         LDKNodeFeatures obj_conv;
44153         obj_conv.inner = untag_ptr(obj);
44154         obj_conv.is_owned = ptr_is_owned(obj);
44155         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
44156         obj_conv.is_owned = false;
44157         LDKCVec_u8Z ret_var = NodeFeatures_write(&obj_conv);
44158         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
44159         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
44160         CVec_u8Z_free(ret_var);
44161         return ret_arr;
44162 }
44163
44164 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
44165         LDKu8slice ser_ref;
44166         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
44167         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
44168         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
44169         *ret_conv = NodeFeatures_read(ser_ref);
44170         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
44171         return tag_ptr(ret_conv, true);
44172 }
44173
44174 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
44175         LDKInvoiceFeatures obj_conv;
44176         obj_conv.inner = untag_ptr(obj);
44177         obj_conv.is_owned = ptr_is_owned(obj);
44178         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
44179         obj_conv.is_owned = false;
44180         LDKCVec_u8Z ret_var = InvoiceFeatures_write(&obj_conv);
44181         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
44182         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
44183         CVec_u8Z_free(ret_var);
44184         return ret_arr;
44185 }
44186
44187 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
44188         LDKu8slice ser_ref;
44189         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
44190         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
44191         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
44192         *ret_conv = InvoiceFeatures_read(ser_ref);
44193         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
44194         return tag_ptr(ret_conv, true);
44195 }
44196
44197 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
44198         LDKChannelTypeFeatures obj_conv;
44199         obj_conv.inner = untag_ptr(obj);
44200         obj_conv.is_owned = ptr_is_owned(obj);
44201         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
44202         obj_conv.is_owned = false;
44203         LDKCVec_u8Z ret_var = ChannelTypeFeatures_write(&obj_conv);
44204         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
44205         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
44206         CVec_u8Z_free(ret_var);
44207         return ret_arr;
44208 }
44209
44210 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
44211         LDKu8slice ser_ref;
44212         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
44213         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
44214         LDKCResult_ChannelTypeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTypeFeaturesDecodeErrorZ), "LDKCResult_ChannelTypeFeaturesDecodeErrorZ");
44215         *ret_conv = ChannelTypeFeatures_read(ser_ref);
44216         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
44217         return tag_ptr(ret_conv, true);
44218 }
44219
44220 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OfferFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
44221         LDKOfferFeatures obj_conv;
44222         obj_conv.inner = untag_ptr(obj);
44223         obj_conv.is_owned = ptr_is_owned(obj);
44224         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
44225         obj_conv.is_owned = false;
44226         LDKCVec_u8Z ret_var = OfferFeatures_write(&obj_conv);
44227         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
44228         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
44229         CVec_u8Z_free(ret_var);
44230         return ret_arr;
44231 }
44232
44233 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OfferFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
44234         LDKu8slice ser_ref;
44235         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
44236         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
44237         LDKCResult_OfferFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OfferFeaturesDecodeErrorZ), "LDKCResult_OfferFeaturesDecodeErrorZ");
44238         *ret_conv = OfferFeatures_read(ser_ref);
44239         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
44240         return tag_ptr(ret_conv, true);
44241 }
44242
44243 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InvoiceRequestFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
44244         LDKInvoiceRequestFeatures obj_conv;
44245         obj_conv.inner = untag_ptr(obj);
44246         obj_conv.is_owned = ptr_is_owned(obj);
44247         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
44248         obj_conv.is_owned = false;
44249         LDKCVec_u8Z ret_var = InvoiceRequestFeatures_write(&obj_conv);
44250         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
44251         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
44252         CVec_u8Z_free(ret_var);
44253         return ret_arr;
44254 }
44255
44256 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceRequestFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
44257         LDKu8slice ser_ref;
44258         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
44259         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
44260         LDKCResult_InvoiceRequestFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceRequestFeaturesDecodeErrorZ), "LDKCResult_InvoiceRequestFeaturesDecodeErrorZ");
44261         *ret_conv = InvoiceRequestFeatures_read(ser_ref);
44262         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
44263         return tag_ptr(ret_conv, true);
44264 }
44265
44266 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1data_1loss_1protect_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
44267         LDKInitFeatures this_arg_conv;
44268         this_arg_conv.inner = untag_ptr(this_arg);
44269         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44270         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44271         this_arg_conv.is_owned = false;
44272         InitFeatures_set_data_loss_protect_optional(&this_arg_conv);
44273 }
44274
44275 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1data_1loss_1protect_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
44276         LDKInitFeatures this_arg_conv;
44277         this_arg_conv.inner = untag_ptr(this_arg);
44278         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44279         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44280         this_arg_conv.is_owned = false;
44281         InitFeatures_set_data_loss_protect_required(&this_arg_conv);
44282 }
44283
44284 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1data_1loss_1protect(JNIEnv *env, jclass clz, int64_t this_arg) {
44285         LDKInitFeatures this_arg_conv;
44286         this_arg_conv.inner = untag_ptr(this_arg);
44287         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44288         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44289         this_arg_conv.is_owned = false;
44290         jboolean ret_conv = InitFeatures_supports_data_loss_protect(&this_arg_conv);
44291         return ret_conv;
44292 }
44293
44294 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1data_1loss_1protect_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
44295         LDKNodeFeatures this_arg_conv;
44296         this_arg_conv.inner = untag_ptr(this_arg);
44297         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44298         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44299         this_arg_conv.is_owned = false;
44300         NodeFeatures_set_data_loss_protect_optional(&this_arg_conv);
44301 }
44302
44303 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1data_1loss_1protect_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
44304         LDKNodeFeatures this_arg_conv;
44305         this_arg_conv.inner = untag_ptr(this_arg);
44306         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44307         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44308         this_arg_conv.is_owned = false;
44309         NodeFeatures_set_data_loss_protect_required(&this_arg_conv);
44310 }
44311
44312 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1data_1loss_1protect(JNIEnv *env, jclass clz, int64_t this_arg) {
44313         LDKNodeFeatures this_arg_conv;
44314         this_arg_conv.inner = untag_ptr(this_arg);
44315         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44316         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44317         this_arg_conv.is_owned = false;
44318         jboolean ret_conv = NodeFeatures_supports_data_loss_protect(&this_arg_conv);
44319         return ret_conv;
44320 }
44321
44322 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1data_1loss_1protect(JNIEnv *env, jclass clz, int64_t this_arg) {
44323         LDKInitFeatures this_arg_conv;
44324         this_arg_conv.inner = untag_ptr(this_arg);
44325         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44326         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44327         this_arg_conv.is_owned = false;
44328         jboolean ret_conv = InitFeatures_requires_data_loss_protect(&this_arg_conv);
44329         return ret_conv;
44330 }
44331
44332 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1data_1loss_1protect(JNIEnv *env, jclass clz, int64_t this_arg) {
44333         LDKNodeFeatures this_arg_conv;
44334         this_arg_conv.inner = untag_ptr(this_arg);
44335         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44336         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44337         this_arg_conv.is_owned = false;
44338         jboolean ret_conv = NodeFeatures_requires_data_loss_protect(&this_arg_conv);
44339         return ret_conv;
44340 }
44341
44342 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1initial_1routing_1sync_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
44343         LDKInitFeatures this_arg_conv;
44344         this_arg_conv.inner = untag_ptr(this_arg);
44345         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44346         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44347         this_arg_conv.is_owned = false;
44348         InitFeatures_set_initial_routing_sync_optional(&this_arg_conv);
44349 }
44350
44351 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1initial_1routing_1sync_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
44352         LDKInitFeatures this_arg_conv;
44353         this_arg_conv.inner = untag_ptr(this_arg);
44354         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44355         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44356         this_arg_conv.is_owned = false;
44357         InitFeatures_set_initial_routing_sync_required(&this_arg_conv);
44358 }
44359
44360 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1initial_1routing_1sync(JNIEnv *env, jclass clz, int64_t this_arg) {
44361         LDKInitFeatures 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.is_owned = false;
44366         jboolean ret_conv = InitFeatures_initial_routing_sync(&this_arg_conv);
44367         return ret_conv;
44368 }
44369
44370 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1upfront_1shutdown_1script_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
44371         LDKInitFeatures this_arg_conv;
44372         this_arg_conv.inner = untag_ptr(this_arg);
44373         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44374         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44375         this_arg_conv.is_owned = false;
44376         InitFeatures_set_upfront_shutdown_script_optional(&this_arg_conv);
44377 }
44378
44379 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1upfront_1shutdown_1script_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
44380         LDKInitFeatures this_arg_conv;
44381         this_arg_conv.inner = untag_ptr(this_arg);
44382         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44383         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44384         this_arg_conv.is_owned = false;
44385         InitFeatures_set_upfront_shutdown_script_required(&this_arg_conv);
44386 }
44387
44388 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1upfront_1shutdown_1script(JNIEnv *env, jclass clz, int64_t this_arg) {
44389         LDKInitFeatures this_arg_conv;
44390         this_arg_conv.inner = untag_ptr(this_arg);
44391         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44392         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44393         this_arg_conv.is_owned = false;
44394         jboolean ret_conv = InitFeatures_supports_upfront_shutdown_script(&this_arg_conv);
44395         return ret_conv;
44396 }
44397
44398 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1upfront_1shutdown_1script_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
44399         LDKNodeFeatures this_arg_conv;
44400         this_arg_conv.inner = untag_ptr(this_arg);
44401         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44402         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44403         this_arg_conv.is_owned = false;
44404         NodeFeatures_set_upfront_shutdown_script_optional(&this_arg_conv);
44405 }
44406
44407 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1upfront_1shutdown_1script_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
44408         LDKNodeFeatures this_arg_conv;
44409         this_arg_conv.inner = untag_ptr(this_arg);
44410         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44411         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44412         this_arg_conv.is_owned = false;
44413         NodeFeatures_set_upfront_shutdown_script_required(&this_arg_conv);
44414 }
44415
44416 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1upfront_1shutdown_1script(JNIEnv *env, jclass clz, int64_t this_arg) {
44417         LDKNodeFeatures this_arg_conv;
44418         this_arg_conv.inner = untag_ptr(this_arg);
44419         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44420         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44421         this_arg_conv.is_owned = false;
44422         jboolean ret_conv = NodeFeatures_supports_upfront_shutdown_script(&this_arg_conv);
44423         return ret_conv;
44424 }
44425
44426 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1upfront_1shutdown_1script(JNIEnv *env, jclass clz, int64_t this_arg) {
44427         LDKInitFeatures this_arg_conv;
44428         this_arg_conv.inner = untag_ptr(this_arg);
44429         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44430         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44431         this_arg_conv.is_owned = false;
44432         jboolean ret_conv = InitFeatures_requires_upfront_shutdown_script(&this_arg_conv);
44433         return ret_conv;
44434 }
44435
44436 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1upfront_1shutdown_1script(JNIEnv *env, jclass clz, int64_t this_arg) {
44437         LDKNodeFeatures this_arg_conv;
44438         this_arg_conv.inner = untag_ptr(this_arg);
44439         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44440         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44441         this_arg_conv.is_owned = false;
44442         jboolean ret_conv = NodeFeatures_requires_upfront_shutdown_script(&this_arg_conv);
44443         return ret_conv;
44444 }
44445
44446 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1gossip_1queries_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
44447         LDKInitFeatures this_arg_conv;
44448         this_arg_conv.inner = untag_ptr(this_arg);
44449         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44450         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44451         this_arg_conv.is_owned = false;
44452         InitFeatures_set_gossip_queries_optional(&this_arg_conv);
44453 }
44454
44455 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1gossip_1queries_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
44456         LDKInitFeatures this_arg_conv;
44457         this_arg_conv.inner = untag_ptr(this_arg);
44458         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44459         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44460         this_arg_conv.is_owned = false;
44461         InitFeatures_set_gossip_queries_required(&this_arg_conv);
44462 }
44463
44464 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1gossip_1queries(JNIEnv *env, jclass clz, int64_t this_arg) {
44465         LDKInitFeatures this_arg_conv;
44466         this_arg_conv.inner = untag_ptr(this_arg);
44467         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44468         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44469         this_arg_conv.is_owned = false;
44470         jboolean ret_conv = InitFeatures_supports_gossip_queries(&this_arg_conv);
44471         return ret_conv;
44472 }
44473
44474 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1gossip_1queries_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
44475         LDKNodeFeatures this_arg_conv;
44476         this_arg_conv.inner = untag_ptr(this_arg);
44477         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44478         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44479         this_arg_conv.is_owned = false;
44480         NodeFeatures_set_gossip_queries_optional(&this_arg_conv);
44481 }
44482
44483 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1gossip_1queries_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
44484         LDKNodeFeatures this_arg_conv;
44485         this_arg_conv.inner = untag_ptr(this_arg);
44486         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44487         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44488         this_arg_conv.is_owned = false;
44489         NodeFeatures_set_gossip_queries_required(&this_arg_conv);
44490 }
44491
44492 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1gossip_1queries(JNIEnv *env, jclass clz, int64_t this_arg) {
44493         LDKNodeFeatures this_arg_conv;
44494         this_arg_conv.inner = untag_ptr(this_arg);
44495         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44496         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44497         this_arg_conv.is_owned = false;
44498         jboolean ret_conv = NodeFeatures_supports_gossip_queries(&this_arg_conv);
44499         return ret_conv;
44500 }
44501
44502 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1gossip_1queries(JNIEnv *env, jclass clz, int64_t this_arg) {
44503         LDKInitFeatures this_arg_conv;
44504         this_arg_conv.inner = untag_ptr(this_arg);
44505         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44506         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44507         this_arg_conv.is_owned = false;
44508         jboolean ret_conv = InitFeatures_requires_gossip_queries(&this_arg_conv);
44509         return ret_conv;
44510 }
44511
44512 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1gossip_1queries(JNIEnv *env, jclass clz, int64_t this_arg) {
44513         LDKNodeFeatures this_arg_conv;
44514         this_arg_conv.inner = untag_ptr(this_arg);
44515         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44516         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44517         this_arg_conv.is_owned = false;
44518         jboolean ret_conv = NodeFeatures_requires_gossip_queries(&this_arg_conv);
44519         return ret_conv;
44520 }
44521
44522 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1variable_1length_1onion_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
44523         LDKInitFeatures this_arg_conv;
44524         this_arg_conv.inner = untag_ptr(this_arg);
44525         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44526         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44527         this_arg_conv.is_owned = false;
44528         InitFeatures_set_variable_length_onion_optional(&this_arg_conv);
44529 }
44530
44531 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1variable_1length_1onion_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
44532         LDKInitFeatures this_arg_conv;
44533         this_arg_conv.inner = untag_ptr(this_arg);
44534         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44535         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44536         this_arg_conv.is_owned = false;
44537         InitFeatures_set_variable_length_onion_required(&this_arg_conv);
44538 }
44539
44540 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1variable_1length_1onion(JNIEnv *env, jclass clz, int64_t this_arg) {
44541         LDKInitFeatures this_arg_conv;
44542         this_arg_conv.inner = untag_ptr(this_arg);
44543         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44544         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44545         this_arg_conv.is_owned = false;
44546         jboolean ret_conv = InitFeatures_supports_variable_length_onion(&this_arg_conv);
44547         return ret_conv;
44548 }
44549
44550 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1variable_1length_1onion_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
44551         LDKNodeFeatures this_arg_conv;
44552         this_arg_conv.inner = untag_ptr(this_arg);
44553         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44554         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44555         this_arg_conv.is_owned = false;
44556         NodeFeatures_set_variable_length_onion_optional(&this_arg_conv);
44557 }
44558
44559 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1variable_1length_1onion_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
44560         LDKNodeFeatures this_arg_conv;
44561         this_arg_conv.inner = untag_ptr(this_arg);
44562         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44563         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44564         this_arg_conv.is_owned = false;
44565         NodeFeatures_set_variable_length_onion_required(&this_arg_conv);
44566 }
44567
44568 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1variable_1length_1onion(JNIEnv *env, jclass clz, int64_t this_arg) {
44569         LDKNodeFeatures this_arg_conv;
44570         this_arg_conv.inner = untag_ptr(this_arg);
44571         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44572         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44573         this_arg_conv.is_owned = false;
44574         jboolean ret_conv = NodeFeatures_supports_variable_length_onion(&this_arg_conv);
44575         return ret_conv;
44576 }
44577
44578 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1set_1variable_1length_1onion_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
44579         LDKInvoiceFeatures this_arg_conv;
44580         this_arg_conv.inner = untag_ptr(this_arg);
44581         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44582         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44583         this_arg_conv.is_owned = false;
44584         InvoiceFeatures_set_variable_length_onion_optional(&this_arg_conv);
44585 }
44586
44587 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1set_1variable_1length_1onion_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
44588         LDKInvoiceFeatures this_arg_conv;
44589         this_arg_conv.inner = untag_ptr(this_arg);
44590         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44591         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44592         this_arg_conv.is_owned = false;
44593         InvoiceFeatures_set_variable_length_onion_required(&this_arg_conv);
44594 }
44595
44596 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1supports_1variable_1length_1onion(JNIEnv *env, jclass clz, int64_t this_arg) {
44597         LDKInvoiceFeatures this_arg_conv;
44598         this_arg_conv.inner = untag_ptr(this_arg);
44599         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44600         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44601         this_arg_conv.is_owned = false;
44602         jboolean ret_conv = InvoiceFeatures_supports_variable_length_onion(&this_arg_conv);
44603         return ret_conv;
44604 }
44605
44606 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1variable_1length_1onion(JNIEnv *env, jclass clz, int64_t this_arg) {
44607         LDKInitFeatures this_arg_conv;
44608         this_arg_conv.inner = untag_ptr(this_arg);
44609         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44610         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44611         this_arg_conv.is_owned = false;
44612         jboolean ret_conv = InitFeatures_requires_variable_length_onion(&this_arg_conv);
44613         return ret_conv;
44614 }
44615
44616 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1variable_1length_1onion(JNIEnv *env, jclass clz, int64_t this_arg) {
44617         LDKNodeFeatures this_arg_conv;
44618         this_arg_conv.inner = untag_ptr(this_arg);
44619         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44620         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44621         this_arg_conv.is_owned = false;
44622         jboolean ret_conv = NodeFeatures_requires_variable_length_onion(&this_arg_conv);
44623         return ret_conv;
44624 }
44625
44626 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1requires_1variable_1length_1onion(JNIEnv *env, jclass clz, int64_t this_arg) {
44627         LDKInvoiceFeatures this_arg_conv;
44628         this_arg_conv.inner = untag_ptr(this_arg);
44629         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44630         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44631         this_arg_conv.is_owned = false;
44632         jboolean ret_conv = InvoiceFeatures_requires_variable_length_onion(&this_arg_conv);
44633         return ret_conv;
44634 }
44635
44636 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1static_1remote_1key_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
44637         LDKInitFeatures this_arg_conv;
44638         this_arg_conv.inner = untag_ptr(this_arg);
44639         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44640         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44641         this_arg_conv.is_owned = false;
44642         InitFeatures_set_static_remote_key_optional(&this_arg_conv);
44643 }
44644
44645 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1static_1remote_1key_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
44646         LDKInitFeatures this_arg_conv;
44647         this_arg_conv.inner = untag_ptr(this_arg);
44648         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44649         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44650         this_arg_conv.is_owned = false;
44651         InitFeatures_set_static_remote_key_required(&this_arg_conv);
44652 }
44653
44654 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1static_1remote_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
44655         LDKInitFeatures this_arg_conv;
44656         this_arg_conv.inner = untag_ptr(this_arg);
44657         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44658         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44659         this_arg_conv.is_owned = false;
44660         jboolean ret_conv = InitFeatures_supports_static_remote_key(&this_arg_conv);
44661         return ret_conv;
44662 }
44663
44664 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1static_1remote_1key_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
44665         LDKNodeFeatures this_arg_conv;
44666         this_arg_conv.inner = untag_ptr(this_arg);
44667         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44668         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44669         this_arg_conv.is_owned = false;
44670         NodeFeatures_set_static_remote_key_optional(&this_arg_conv);
44671 }
44672
44673 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1static_1remote_1key_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
44674         LDKNodeFeatures this_arg_conv;
44675         this_arg_conv.inner = untag_ptr(this_arg);
44676         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44677         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44678         this_arg_conv.is_owned = false;
44679         NodeFeatures_set_static_remote_key_required(&this_arg_conv);
44680 }
44681
44682 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1static_1remote_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
44683         LDKNodeFeatures this_arg_conv;
44684         this_arg_conv.inner = untag_ptr(this_arg);
44685         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44686         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44687         this_arg_conv.is_owned = false;
44688         jboolean ret_conv = NodeFeatures_supports_static_remote_key(&this_arg_conv);
44689         return ret_conv;
44690 }
44691
44692 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1set_1static_1remote_1key_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
44693         LDKChannelTypeFeatures 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         ChannelTypeFeatures_set_static_remote_key_optional(&this_arg_conv);
44699 }
44700
44701 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1set_1static_1remote_1key_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
44702         LDKChannelTypeFeatures this_arg_conv;
44703         this_arg_conv.inner = untag_ptr(this_arg);
44704         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44705         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44706         this_arg_conv.is_owned = false;
44707         ChannelTypeFeatures_set_static_remote_key_required(&this_arg_conv);
44708 }
44709
44710 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1supports_1static_1remote_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
44711         LDKChannelTypeFeatures this_arg_conv;
44712         this_arg_conv.inner = untag_ptr(this_arg);
44713         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44714         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44715         this_arg_conv.is_owned = false;
44716         jboolean ret_conv = ChannelTypeFeatures_supports_static_remote_key(&this_arg_conv);
44717         return ret_conv;
44718 }
44719
44720 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1static_1remote_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
44721         LDKInitFeatures this_arg_conv;
44722         this_arg_conv.inner = untag_ptr(this_arg);
44723         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44724         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44725         this_arg_conv.is_owned = false;
44726         jboolean ret_conv = InitFeatures_requires_static_remote_key(&this_arg_conv);
44727         return ret_conv;
44728 }
44729
44730 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1static_1remote_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
44731         LDKNodeFeatures this_arg_conv;
44732         this_arg_conv.inner = untag_ptr(this_arg);
44733         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44734         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44735         this_arg_conv.is_owned = false;
44736         jboolean ret_conv = NodeFeatures_requires_static_remote_key(&this_arg_conv);
44737         return ret_conv;
44738 }
44739
44740 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1requires_1static_1remote_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
44741         LDKChannelTypeFeatures this_arg_conv;
44742         this_arg_conv.inner = untag_ptr(this_arg);
44743         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44744         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44745         this_arg_conv.is_owned = false;
44746         jboolean ret_conv = ChannelTypeFeatures_requires_static_remote_key(&this_arg_conv);
44747         return ret_conv;
44748 }
44749
44750 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1payment_1secret_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
44751         LDKInitFeatures this_arg_conv;
44752         this_arg_conv.inner = untag_ptr(this_arg);
44753         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44754         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44755         this_arg_conv.is_owned = false;
44756         InitFeatures_set_payment_secret_optional(&this_arg_conv);
44757 }
44758
44759 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1payment_1secret_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
44760         LDKInitFeatures this_arg_conv;
44761         this_arg_conv.inner = untag_ptr(this_arg);
44762         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44763         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44764         this_arg_conv.is_owned = false;
44765         InitFeatures_set_payment_secret_required(&this_arg_conv);
44766 }
44767
44768 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
44769         LDKInitFeatures this_arg_conv;
44770         this_arg_conv.inner = untag_ptr(this_arg);
44771         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44772         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44773         this_arg_conv.is_owned = false;
44774         jboolean ret_conv = InitFeatures_supports_payment_secret(&this_arg_conv);
44775         return ret_conv;
44776 }
44777
44778 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1payment_1secret_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
44779         LDKNodeFeatures this_arg_conv;
44780         this_arg_conv.inner = untag_ptr(this_arg);
44781         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44782         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44783         this_arg_conv.is_owned = false;
44784         NodeFeatures_set_payment_secret_optional(&this_arg_conv);
44785 }
44786
44787 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1payment_1secret_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
44788         LDKNodeFeatures this_arg_conv;
44789         this_arg_conv.inner = untag_ptr(this_arg);
44790         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44791         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44792         this_arg_conv.is_owned = false;
44793         NodeFeatures_set_payment_secret_required(&this_arg_conv);
44794 }
44795
44796 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
44797         LDKNodeFeatures this_arg_conv;
44798         this_arg_conv.inner = untag_ptr(this_arg);
44799         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44800         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44801         this_arg_conv.is_owned = false;
44802         jboolean ret_conv = NodeFeatures_supports_payment_secret(&this_arg_conv);
44803         return ret_conv;
44804 }
44805
44806 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1set_1payment_1secret_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
44807         LDKInvoiceFeatures this_arg_conv;
44808         this_arg_conv.inner = untag_ptr(this_arg);
44809         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44810         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44811         this_arg_conv.is_owned = false;
44812         InvoiceFeatures_set_payment_secret_optional(&this_arg_conv);
44813 }
44814
44815 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1set_1payment_1secret_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
44816         LDKInvoiceFeatures this_arg_conv;
44817         this_arg_conv.inner = untag_ptr(this_arg);
44818         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44819         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44820         this_arg_conv.is_owned = false;
44821         InvoiceFeatures_set_payment_secret_required(&this_arg_conv);
44822 }
44823
44824 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1supports_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
44825         LDKInvoiceFeatures this_arg_conv;
44826         this_arg_conv.inner = untag_ptr(this_arg);
44827         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44828         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44829         this_arg_conv.is_owned = false;
44830         jboolean ret_conv = InvoiceFeatures_supports_payment_secret(&this_arg_conv);
44831         return ret_conv;
44832 }
44833
44834 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
44835         LDKInitFeatures this_arg_conv;
44836         this_arg_conv.inner = untag_ptr(this_arg);
44837         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44838         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44839         this_arg_conv.is_owned = false;
44840         jboolean ret_conv = InitFeatures_requires_payment_secret(&this_arg_conv);
44841         return ret_conv;
44842 }
44843
44844 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
44845         LDKNodeFeatures this_arg_conv;
44846         this_arg_conv.inner = untag_ptr(this_arg);
44847         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44848         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44849         this_arg_conv.is_owned = false;
44850         jboolean ret_conv = NodeFeatures_requires_payment_secret(&this_arg_conv);
44851         return ret_conv;
44852 }
44853
44854 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1requires_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
44855         LDKInvoiceFeatures this_arg_conv;
44856         this_arg_conv.inner = untag_ptr(this_arg);
44857         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44858         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44859         this_arg_conv.is_owned = false;
44860         jboolean ret_conv = InvoiceFeatures_requires_payment_secret(&this_arg_conv);
44861         return ret_conv;
44862 }
44863
44864 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1basic_1mpp_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
44865         LDKInitFeatures this_arg_conv;
44866         this_arg_conv.inner = untag_ptr(this_arg);
44867         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44868         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44869         this_arg_conv.is_owned = false;
44870         InitFeatures_set_basic_mpp_optional(&this_arg_conv);
44871 }
44872
44873 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1basic_1mpp_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
44874         LDKInitFeatures this_arg_conv;
44875         this_arg_conv.inner = untag_ptr(this_arg);
44876         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44877         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44878         this_arg_conv.is_owned = false;
44879         InitFeatures_set_basic_mpp_required(&this_arg_conv);
44880 }
44881
44882 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1basic_1mpp(JNIEnv *env, jclass clz, int64_t this_arg) {
44883         LDKInitFeatures this_arg_conv;
44884         this_arg_conv.inner = untag_ptr(this_arg);
44885         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44886         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44887         this_arg_conv.is_owned = false;
44888         jboolean ret_conv = InitFeatures_supports_basic_mpp(&this_arg_conv);
44889         return ret_conv;
44890 }
44891
44892 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1basic_1mpp_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
44893         LDKNodeFeatures this_arg_conv;
44894         this_arg_conv.inner = untag_ptr(this_arg);
44895         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44896         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44897         this_arg_conv.is_owned = false;
44898         NodeFeatures_set_basic_mpp_optional(&this_arg_conv);
44899 }
44900
44901 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1basic_1mpp_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
44902         LDKNodeFeatures this_arg_conv;
44903         this_arg_conv.inner = untag_ptr(this_arg);
44904         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44905         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44906         this_arg_conv.is_owned = false;
44907         NodeFeatures_set_basic_mpp_required(&this_arg_conv);
44908 }
44909
44910 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1basic_1mpp(JNIEnv *env, jclass clz, int64_t this_arg) {
44911         LDKNodeFeatures this_arg_conv;
44912         this_arg_conv.inner = untag_ptr(this_arg);
44913         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44914         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44915         this_arg_conv.is_owned = false;
44916         jboolean ret_conv = NodeFeatures_supports_basic_mpp(&this_arg_conv);
44917         return ret_conv;
44918 }
44919
44920 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1set_1basic_1mpp_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
44921         LDKInvoiceFeatures this_arg_conv;
44922         this_arg_conv.inner = untag_ptr(this_arg);
44923         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44924         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44925         this_arg_conv.is_owned = false;
44926         InvoiceFeatures_set_basic_mpp_optional(&this_arg_conv);
44927 }
44928
44929 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1set_1basic_1mpp_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
44930         LDKInvoiceFeatures this_arg_conv;
44931         this_arg_conv.inner = untag_ptr(this_arg);
44932         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44933         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44934         this_arg_conv.is_owned = false;
44935         InvoiceFeatures_set_basic_mpp_required(&this_arg_conv);
44936 }
44937
44938 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1supports_1basic_1mpp(JNIEnv *env, jclass clz, int64_t this_arg) {
44939         LDKInvoiceFeatures this_arg_conv;
44940         this_arg_conv.inner = untag_ptr(this_arg);
44941         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44942         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44943         this_arg_conv.is_owned = false;
44944         jboolean ret_conv = InvoiceFeatures_supports_basic_mpp(&this_arg_conv);
44945         return ret_conv;
44946 }
44947
44948 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1basic_1mpp(JNIEnv *env, jclass clz, int64_t this_arg) {
44949         LDKInitFeatures this_arg_conv;
44950         this_arg_conv.inner = untag_ptr(this_arg);
44951         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44952         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44953         this_arg_conv.is_owned = false;
44954         jboolean ret_conv = InitFeatures_requires_basic_mpp(&this_arg_conv);
44955         return ret_conv;
44956 }
44957
44958 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1basic_1mpp(JNIEnv *env, jclass clz, int64_t this_arg) {
44959         LDKNodeFeatures this_arg_conv;
44960         this_arg_conv.inner = untag_ptr(this_arg);
44961         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44962         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44963         this_arg_conv.is_owned = false;
44964         jboolean ret_conv = NodeFeatures_requires_basic_mpp(&this_arg_conv);
44965         return ret_conv;
44966 }
44967
44968 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1requires_1basic_1mpp(JNIEnv *env, jclass clz, int64_t this_arg) {
44969         LDKInvoiceFeatures this_arg_conv;
44970         this_arg_conv.inner = untag_ptr(this_arg);
44971         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44972         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44973         this_arg_conv.is_owned = false;
44974         jboolean ret_conv = InvoiceFeatures_requires_basic_mpp(&this_arg_conv);
44975         return ret_conv;
44976 }
44977
44978 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1wumbo_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
44979         LDKInitFeatures this_arg_conv;
44980         this_arg_conv.inner = untag_ptr(this_arg);
44981         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44982         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44983         this_arg_conv.is_owned = false;
44984         InitFeatures_set_wumbo_optional(&this_arg_conv);
44985 }
44986
44987 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1wumbo_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
44988         LDKInitFeatures this_arg_conv;
44989         this_arg_conv.inner = untag_ptr(this_arg);
44990         this_arg_conv.is_owned = ptr_is_owned(this_arg);
44991         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
44992         this_arg_conv.is_owned = false;
44993         InitFeatures_set_wumbo_required(&this_arg_conv);
44994 }
44995
44996 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1wumbo(JNIEnv *env, jclass clz, int64_t this_arg) {
44997         LDKInitFeatures this_arg_conv;
44998         this_arg_conv.inner = untag_ptr(this_arg);
44999         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45000         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45001         this_arg_conv.is_owned = false;
45002         jboolean ret_conv = InitFeatures_supports_wumbo(&this_arg_conv);
45003         return ret_conv;
45004 }
45005
45006 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1wumbo_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
45007         LDKNodeFeatures this_arg_conv;
45008         this_arg_conv.inner = untag_ptr(this_arg);
45009         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45010         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45011         this_arg_conv.is_owned = false;
45012         NodeFeatures_set_wumbo_optional(&this_arg_conv);
45013 }
45014
45015 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1wumbo_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
45016         LDKNodeFeatures this_arg_conv;
45017         this_arg_conv.inner = untag_ptr(this_arg);
45018         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45019         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45020         this_arg_conv.is_owned = false;
45021         NodeFeatures_set_wumbo_required(&this_arg_conv);
45022 }
45023
45024 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1wumbo(JNIEnv *env, jclass clz, int64_t this_arg) {
45025         LDKNodeFeatures this_arg_conv;
45026         this_arg_conv.inner = untag_ptr(this_arg);
45027         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45028         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45029         this_arg_conv.is_owned = false;
45030         jboolean ret_conv = NodeFeatures_supports_wumbo(&this_arg_conv);
45031         return ret_conv;
45032 }
45033
45034 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1wumbo(JNIEnv *env, jclass clz, int64_t this_arg) {
45035         LDKInitFeatures this_arg_conv;
45036         this_arg_conv.inner = untag_ptr(this_arg);
45037         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45038         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45039         this_arg_conv.is_owned = false;
45040         jboolean ret_conv = InitFeatures_requires_wumbo(&this_arg_conv);
45041         return ret_conv;
45042 }
45043
45044 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1wumbo(JNIEnv *env, jclass clz, int64_t this_arg) {
45045         LDKNodeFeatures this_arg_conv;
45046         this_arg_conv.inner = untag_ptr(this_arg);
45047         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45048         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45049         this_arg_conv.is_owned = false;
45050         jboolean ret_conv = NodeFeatures_requires_wumbo(&this_arg_conv);
45051         return ret_conv;
45052 }
45053
45054 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1shutdown_1any_1segwit_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
45055         LDKInitFeatures this_arg_conv;
45056         this_arg_conv.inner = untag_ptr(this_arg);
45057         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45058         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45059         this_arg_conv.is_owned = false;
45060         InitFeatures_set_shutdown_any_segwit_optional(&this_arg_conv);
45061 }
45062
45063 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1shutdown_1any_1segwit_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
45064         LDKInitFeatures this_arg_conv;
45065         this_arg_conv.inner = untag_ptr(this_arg);
45066         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45067         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45068         this_arg_conv.is_owned = false;
45069         InitFeatures_set_shutdown_any_segwit_required(&this_arg_conv);
45070 }
45071
45072 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1shutdown_1anysegwit(JNIEnv *env, jclass clz, int64_t this_arg) {
45073         LDKInitFeatures this_arg_conv;
45074         this_arg_conv.inner = untag_ptr(this_arg);
45075         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45076         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45077         this_arg_conv.is_owned = false;
45078         jboolean ret_conv = InitFeatures_supports_shutdown_anysegwit(&this_arg_conv);
45079         return ret_conv;
45080 }
45081
45082 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1shutdown_1any_1segwit_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
45083         LDKNodeFeatures this_arg_conv;
45084         this_arg_conv.inner = untag_ptr(this_arg);
45085         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45086         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45087         this_arg_conv.is_owned = false;
45088         NodeFeatures_set_shutdown_any_segwit_optional(&this_arg_conv);
45089 }
45090
45091 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1shutdown_1any_1segwit_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
45092         LDKNodeFeatures this_arg_conv;
45093         this_arg_conv.inner = untag_ptr(this_arg);
45094         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45095         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45096         this_arg_conv.is_owned = false;
45097         NodeFeatures_set_shutdown_any_segwit_required(&this_arg_conv);
45098 }
45099
45100 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1shutdown_1anysegwit(JNIEnv *env, jclass clz, int64_t this_arg) {
45101         LDKNodeFeatures this_arg_conv;
45102         this_arg_conv.inner = untag_ptr(this_arg);
45103         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45104         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45105         this_arg_conv.is_owned = false;
45106         jboolean ret_conv = NodeFeatures_supports_shutdown_anysegwit(&this_arg_conv);
45107         return ret_conv;
45108 }
45109
45110 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1shutdown_1anysegwit(JNIEnv *env, jclass clz, int64_t this_arg) {
45111         LDKInitFeatures this_arg_conv;
45112         this_arg_conv.inner = untag_ptr(this_arg);
45113         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45114         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45115         this_arg_conv.is_owned = false;
45116         jboolean ret_conv = InitFeatures_requires_shutdown_anysegwit(&this_arg_conv);
45117         return ret_conv;
45118 }
45119
45120 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1shutdown_1anysegwit(JNIEnv *env, jclass clz, int64_t this_arg) {
45121         LDKNodeFeatures this_arg_conv;
45122         this_arg_conv.inner = untag_ptr(this_arg);
45123         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45124         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45125         this_arg_conv.is_owned = false;
45126         jboolean ret_conv = NodeFeatures_requires_shutdown_anysegwit(&this_arg_conv);
45127         return ret_conv;
45128 }
45129
45130 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1onion_1messages_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
45131         LDKInitFeatures this_arg_conv;
45132         this_arg_conv.inner = untag_ptr(this_arg);
45133         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45134         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45135         this_arg_conv.is_owned = false;
45136         InitFeatures_set_onion_messages_optional(&this_arg_conv);
45137 }
45138
45139 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1onion_1messages_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
45140         LDKInitFeatures this_arg_conv;
45141         this_arg_conv.inner = untag_ptr(this_arg);
45142         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45143         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45144         this_arg_conv.is_owned = false;
45145         InitFeatures_set_onion_messages_required(&this_arg_conv);
45146 }
45147
45148 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1onion_1messages(JNIEnv *env, jclass clz, int64_t this_arg) {
45149         LDKInitFeatures this_arg_conv;
45150         this_arg_conv.inner = untag_ptr(this_arg);
45151         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45152         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45153         this_arg_conv.is_owned = false;
45154         jboolean ret_conv = InitFeatures_supports_onion_messages(&this_arg_conv);
45155         return ret_conv;
45156 }
45157
45158 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1onion_1messages_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
45159         LDKNodeFeatures this_arg_conv;
45160         this_arg_conv.inner = untag_ptr(this_arg);
45161         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45162         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45163         this_arg_conv.is_owned = false;
45164         NodeFeatures_set_onion_messages_optional(&this_arg_conv);
45165 }
45166
45167 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1onion_1messages_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
45168         LDKNodeFeatures this_arg_conv;
45169         this_arg_conv.inner = untag_ptr(this_arg);
45170         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45171         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45172         this_arg_conv.is_owned = false;
45173         NodeFeatures_set_onion_messages_required(&this_arg_conv);
45174 }
45175
45176 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1onion_1messages(JNIEnv *env, jclass clz, int64_t this_arg) {
45177         LDKNodeFeatures this_arg_conv;
45178         this_arg_conv.inner = untag_ptr(this_arg);
45179         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45180         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45181         this_arg_conv.is_owned = false;
45182         jboolean ret_conv = NodeFeatures_supports_onion_messages(&this_arg_conv);
45183         return ret_conv;
45184 }
45185
45186 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1onion_1messages(JNIEnv *env, jclass clz, int64_t this_arg) {
45187         LDKInitFeatures this_arg_conv;
45188         this_arg_conv.inner = untag_ptr(this_arg);
45189         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45190         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45191         this_arg_conv.is_owned = false;
45192         jboolean ret_conv = InitFeatures_requires_onion_messages(&this_arg_conv);
45193         return ret_conv;
45194 }
45195
45196 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1onion_1messages(JNIEnv *env, jclass clz, int64_t this_arg) {
45197         LDKNodeFeatures this_arg_conv;
45198         this_arg_conv.inner = untag_ptr(this_arg);
45199         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45200         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45201         this_arg_conv.is_owned = false;
45202         jboolean ret_conv = NodeFeatures_requires_onion_messages(&this_arg_conv);
45203         return ret_conv;
45204 }
45205
45206 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1channel_1type_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
45207         LDKInitFeatures this_arg_conv;
45208         this_arg_conv.inner = untag_ptr(this_arg);
45209         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45210         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45211         this_arg_conv.is_owned = false;
45212         InitFeatures_set_channel_type_optional(&this_arg_conv);
45213 }
45214
45215 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1channel_1type_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
45216         LDKInitFeatures this_arg_conv;
45217         this_arg_conv.inner = untag_ptr(this_arg);
45218         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45219         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45220         this_arg_conv.is_owned = false;
45221         InitFeatures_set_channel_type_required(&this_arg_conv);
45222 }
45223
45224 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1channel_1type(JNIEnv *env, jclass clz, int64_t this_arg) {
45225         LDKInitFeatures this_arg_conv;
45226         this_arg_conv.inner = untag_ptr(this_arg);
45227         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45228         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45229         this_arg_conv.is_owned = false;
45230         jboolean ret_conv = InitFeatures_supports_channel_type(&this_arg_conv);
45231         return ret_conv;
45232 }
45233
45234 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1channel_1type_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
45235         LDKNodeFeatures this_arg_conv;
45236         this_arg_conv.inner = untag_ptr(this_arg);
45237         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45238         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45239         this_arg_conv.is_owned = false;
45240         NodeFeatures_set_channel_type_optional(&this_arg_conv);
45241 }
45242
45243 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1channel_1type_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
45244         LDKNodeFeatures this_arg_conv;
45245         this_arg_conv.inner = untag_ptr(this_arg);
45246         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45247         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45248         this_arg_conv.is_owned = false;
45249         NodeFeatures_set_channel_type_required(&this_arg_conv);
45250 }
45251
45252 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1channel_1type(JNIEnv *env, jclass clz, int64_t this_arg) {
45253         LDKNodeFeatures this_arg_conv;
45254         this_arg_conv.inner = untag_ptr(this_arg);
45255         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45256         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45257         this_arg_conv.is_owned = false;
45258         jboolean ret_conv = NodeFeatures_supports_channel_type(&this_arg_conv);
45259         return ret_conv;
45260 }
45261
45262 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1channel_1type(JNIEnv *env, jclass clz, int64_t this_arg) {
45263         LDKInitFeatures this_arg_conv;
45264         this_arg_conv.inner = untag_ptr(this_arg);
45265         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45266         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45267         this_arg_conv.is_owned = false;
45268         jboolean ret_conv = InitFeatures_requires_channel_type(&this_arg_conv);
45269         return ret_conv;
45270 }
45271
45272 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1channel_1type(JNIEnv *env, jclass clz, int64_t this_arg) {
45273         LDKNodeFeatures this_arg_conv;
45274         this_arg_conv.inner = untag_ptr(this_arg);
45275         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45276         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45277         this_arg_conv.is_owned = false;
45278         jboolean ret_conv = NodeFeatures_requires_channel_type(&this_arg_conv);
45279         return ret_conv;
45280 }
45281
45282 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1scid_1privacy_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
45283         LDKInitFeatures 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         InitFeatures_set_scid_privacy_optional(&this_arg_conv);
45289 }
45290
45291 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1scid_1privacy_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
45292         LDKInitFeatures this_arg_conv;
45293         this_arg_conv.inner = untag_ptr(this_arg);
45294         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45295         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45296         this_arg_conv.is_owned = false;
45297         InitFeatures_set_scid_privacy_required(&this_arg_conv);
45298 }
45299
45300 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1scid_1privacy(JNIEnv *env, jclass clz, int64_t this_arg) {
45301         LDKInitFeatures this_arg_conv;
45302         this_arg_conv.inner = untag_ptr(this_arg);
45303         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45304         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45305         this_arg_conv.is_owned = false;
45306         jboolean ret_conv = InitFeatures_supports_scid_privacy(&this_arg_conv);
45307         return ret_conv;
45308 }
45309
45310 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1scid_1privacy_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
45311         LDKNodeFeatures this_arg_conv;
45312         this_arg_conv.inner = untag_ptr(this_arg);
45313         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45314         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45315         this_arg_conv.is_owned = false;
45316         NodeFeatures_set_scid_privacy_optional(&this_arg_conv);
45317 }
45318
45319 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1scid_1privacy_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
45320         LDKNodeFeatures this_arg_conv;
45321         this_arg_conv.inner = untag_ptr(this_arg);
45322         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45323         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45324         this_arg_conv.is_owned = false;
45325         NodeFeatures_set_scid_privacy_required(&this_arg_conv);
45326 }
45327
45328 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1scid_1privacy(JNIEnv *env, jclass clz, int64_t this_arg) {
45329         LDKNodeFeatures this_arg_conv;
45330         this_arg_conv.inner = untag_ptr(this_arg);
45331         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45332         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45333         this_arg_conv.is_owned = false;
45334         jboolean ret_conv = NodeFeatures_supports_scid_privacy(&this_arg_conv);
45335         return ret_conv;
45336 }
45337
45338 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1set_1scid_1privacy_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
45339         LDKChannelTypeFeatures this_arg_conv;
45340         this_arg_conv.inner = untag_ptr(this_arg);
45341         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45342         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45343         this_arg_conv.is_owned = false;
45344         ChannelTypeFeatures_set_scid_privacy_optional(&this_arg_conv);
45345 }
45346
45347 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1set_1scid_1privacy_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
45348         LDKChannelTypeFeatures this_arg_conv;
45349         this_arg_conv.inner = untag_ptr(this_arg);
45350         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45351         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45352         this_arg_conv.is_owned = false;
45353         ChannelTypeFeatures_set_scid_privacy_required(&this_arg_conv);
45354 }
45355
45356 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1supports_1scid_1privacy(JNIEnv *env, jclass clz, int64_t this_arg) {
45357         LDKChannelTypeFeatures this_arg_conv;
45358         this_arg_conv.inner = untag_ptr(this_arg);
45359         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45360         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45361         this_arg_conv.is_owned = false;
45362         jboolean ret_conv = ChannelTypeFeatures_supports_scid_privacy(&this_arg_conv);
45363         return ret_conv;
45364 }
45365
45366 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1scid_1privacy(JNIEnv *env, jclass clz, int64_t this_arg) {
45367         LDKInitFeatures this_arg_conv;
45368         this_arg_conv.inner = untag_ptr(this_arg);
45369         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45370         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45371         this_arg_conv.is_owned = false;
45372         jboolean ret_conv = InitFeatures_requires_scid_privacy(&this_arg_conv);
45373         return ret_conv;
45374 }
45375
45376 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1scid_1privacy(JNIEnv *env, jclass clz, int64_t this_arg) {
45377         LDKNodeFeatures this_arg_conv;
45378         this_arg_conv.inner = untag_ptr(this_arg);
45379         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45380         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45381         this_arg_conv.is_owned = false;
45382         jboolean ret_conv = NodeFeatures_requires_scid_privacy(&this_arg_conv);
45383         return ret_conv;
45384 }
45385
45386 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1requires_1scid_1privacy(JNIEnv *env, jclass clz, int64_t this_arg) {
45387         LDKChannelTypeFeatures this_arg_conv;
45388         this_arg_conv.inner = untag_ptr(this_arg);
45389         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45390         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45391         this_arg_conv.is_owned = false;
45392         jboolean ret_conv = ChannelTypeFeatures_requires_scid_privacy(&this_arg_conv);
45393         return ret_conv;
45394 }
45395
45396 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1zero_1conf_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
45397         LDKInitFeatures this_arg_conv;
45398         this_arg_conv.inner = untag_ptr(this_arg);
45399         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45400         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45401         this_arg_conv.is_owned = false;
45402         InitFeatures_set_zero_conf_optional(&this_arg_conv);
45403 }
45404
45405 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1set_1zero_1conf_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
45406         LDKInitFeatures this_arg_conv;
45407         this_arg_conv.inner = untag_ptr(this_arg);
45408         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45409         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45410         this_arg_conv.is_owned = false;
45411         InitFeatures_set_zero_conf_required(&this_arg_conv);
45412 }
45413
45414 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1zero_1conf(JNIEnv *env, jclass clz, int64_t this_arg) {
45415         LDKInitFeatures this_arg_conv;
45416         this_arg_conv.inner = untag_ptr(this_arg);
45417         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45418         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45419         this_arg_conv.is_owned = false;
45420         jboolean ret_conv = InitFeatures_supports_zero_conf(&this_arg_conv);
45421         return ret_conv;
45422 }
45423
45424 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1zero_1conf_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
45425         LDKNodeFeatures this_arg_conv;
45426         this_arg_conv.inner = untag_ptr(this_arg);
45427         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45428         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45429         this_arg_conv.is_owned = false;
45430         NodeFeatures_set_zero_conf_optional(&this_arg_conv);
45431 }
45432
45433 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1zero_1conf_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
45434         LDKNodeFeatures this_arg_conv;
45435         this_arg_conv.inner = untag_ptr(this_arg);
45436         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45437         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45438         this_arg_conv.is_owned = false;
45439         NodeFeatures_set_zero_conf_required(&this_arg_conv);
45440 }
45441
45442 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1zero_1conf(JNIEnv *env, jclass clz, int64_t this_arg) {
45443         LDKNodeFeatures this_arg_conv;
45444         this_arg_conv.inner = untag_ptr(this_arg);
45445         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45446         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45447         this_arg_conv.is_owned = false;
45448         jboolean ret_conv = NodeFeatures_supports_zero_conf(&this_arg_conv);
45449         return ret_conv;
45450 }
45451
45452 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1set_1zero_1conf_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
45453         LDKChannelTypeFeatures this_arg_conv;
45454         this_arg_conv.inner = untag_ptr(this_arg);
45455         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45456         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45457         this_arg_conv.is_owned = false;
45458         ChannelTypeFeatures_set_zero_conf_optional(&this_arg_conv);
45459 }
45460
45461 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1set_1zero_1conf_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
45462         LDKChannelTypeFeatures this_arg_conv;
45463         this_arg_conv.inner = untag_ptr(this_arg);
45464         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45465         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45466         this_arg_conv.is_owned = false;
45467         ChannelTypeFeatures_set_zero_conf_required(&this_arg_conv);
45468 }
45469
45470 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1supports_1zero_1conf(JNIEnv *env, jclass clz, int64_t this_arg) {
45471         LDKChannelTypeFeatures this_arg_conv;
45472         this_arg_conv.inner = untag_ptr(this_arg);
45473         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45474         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45475         this_arg_conv.is_owned = false;
45476         jboolean ret_conv = ChannelTypeFeatures_supports_zero_conf(&this_arg_conv);
45477         return ret_conv;
45478 }
45479
45480 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1zero_1conf(JNIEnv *env, jclass clz, int64_t this_arg) {
45481         LDKInitFeatures this_arg_conv;
45482         this_arg_conv.inner = untag_ptr(this_arg);
45483         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45484         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45485         this_arg_conv.is_owned = false;
45486         jboolean ret_conv = InitFeatures_requires_zero_conf(&this_arg_conv);
45487         return ret_conv;
45488 }
45489
45490 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1zero_1conf(JNIEnv *env, jclass clz, int64_t this_arg) {
45491         LDKNodeFeatures this_arg_conv;
45492         this_arg_conv.inner = untag_ptr(this_arg);
45493         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45494         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45495         this_arg_conv.is_owned = false;
45496         jboolean ret_conv = NodeFeatures_requires_zero_conf(&this_arg_conv);
45497         return ret_conv;
45498 }
45499
45500 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTypeFeatures_1requires_1zero_1conf(JNIEnv *env, jclass clz, int64_t this_arg) {
45501         LDKChannelTypeFeatures this_arg_conv;
45502         this_arg_conv.inner = untag_ptr(this_arg);
45503         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45504         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45505         this_arg_conv.is_owned = false;
45506         jboolean ret_conv = ChannelTypeFeatures_requires_zero_conf(&this_arg_conv);
45507         return ret_conv;
45508 }
45509
45510 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1keysend_1optional(JNIEnv *env, jclass clz, int64_t this_arg) {
45511         LDKNodeFeatures this_arg_conv;
45512         this_arg_conv.inner = untag_ptr(this_arg);
45513         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45514         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45515         this_arg_conv.is_owned = false;
45516         NodeFeatures_set_keysend_optional(&this_arg_conv);
45517 }
45518
45519 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1set_1keysend_1required(JNIEnv *env, jclass clz, int64_t this_arg) {
45520         LDKNodeFeatures this_arg_conv;
45521         this_arg_conv.inner = untag_ptr(this_arg);
45522         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45523         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45524         this_arg_conv.is_owned = false;
45525         NodeFeatures_set_keysend_required(&this_arg_conv);
45526 }
45527
45528 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1keysend(JNIEnv *env, jclass clz, int64_t this_arg) {
45529         LDKNodeFeatures this_arg_conv;
45530         this_arg_conv.inner = untag_ptr(this_arg);
45531         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45532         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45533         this_arg_conv.is_owned = false;
45534         jboolean ret_conv = NodeFeatures_supports_keysend(&this_arg_conv);
45535         return ret_conv;
45536 }
45537
45538 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1keysend(JNIEnv *env, jclass clz, int64_t this_arg) {
45539         LDKNodeFeatures this_arg_conv;
45540         this_arg_conv.inner = untag_ptr(this_arg);
45541         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45542         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45543         this_arg_conv.is_owned = false;
45544         jboolean ret_conv = NodeFeatures_requires_keysend(&this_arg_conv);
45545         return ret_conv;
45546 }
45547
45548 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
45549         LDKShutdownScript this_obj_conv;
45550         this_obj_conv.inner = untag_ptr(this_obj);
45551         this_obj_conv.is_owned = ptr_is_owned(this_obj);
45552         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
45553         ShutdownScript_free(this_obj_conv);
45554 }
45555
45556 static inline uint64_t ShutdownScript_clone_ptr(LDKShutdownScript *NONNULL_PTR arg) {
45557         LDKShutdownScript ret_var = ShutdownScript_clone(arg);
45558         int64_t ret_ref = 0;
45559         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45560         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
45561         return ret_ref;
45562 }
45563 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
45564         LDKShutdownScript arg_conv;
45565         arg_conv.inner = untag_ptr(arg);
45566         arg_conv.is_owned = ptr_is_owned(arg);
45567         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
45568         arg_conv.is_owned = false;
45569         int64_t ret_conv = ShutdownScript_clone_ptr(&arg_conv);
45570         return ret_conv;
45571 }
45572
45573 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1clone(JNIEnv *env, jclass clz, int64_t orig) {
45574         LDKShutdownScript orig_conv;
45575         orig_conv.inner = untag_ptr(orig);
45576         orig_conv.is_owned = ptr_is_owned(orig);
45577         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
45578         orig_conv.is_owned = false;
45579         LDKShutdownScript ret_var = ShutdownScript_clone(&orig_conv);
45580         int64_t ret_ref = 0;
45581         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45582         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
45583         return ret_ref;
45584 }
45585
45586 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
45587         LDKShutdownScript a_conv;
45588         a_conv.inner = untag_ptr(a);
45589         a_conv.is_owned = ptr_is_owned(a);
45590         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
45591         a_conv.is_owned = false;
45592         LDKShutdownScript b_conv;
45593         b_conv.inner = untag_ptr(b);
45594         b_conv.is_owned = ptr_is_owned(b);
45595         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
45596         b_conv.is_owned = false;
45597         jboolean ret_conv = ShutdownScript_eq(&a_conv, &b_conv);
45598         return ret_conv;
45599 }
45600
45601 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvalidShutdownScript_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
45602         LDKInvalidShutdownScript this_obj_conv;
45603         this_obj_conv.inner = untag_ptr(this_obj);
45604         this_obj_conv.is_owned = ptr_is_owned(this_obj);
45605         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
45606         InvalidShutdownScript_free(this_obj_conv);
45607 }
45608
45609 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InvalidShutdownScript_1get_1script(JNIEnv *env, jclass clz, int64_t this_ptr) {
45610         LDKInvalidShutdownScript this_ptr_conv;
45611         this_ptr_conv.inner = untag_ptr(this_ptr);
45612         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
45613         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45614         this_ptr_conv.is_owned = false;
45615         LDKu8slice ret_var = InvalidShutdownScript_get_script(&this_ptr_conv);
45616         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
45617         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
45618         return ret_arr;
45619 }
45620
45621 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvalidShutdownScript_1set_1script(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
45622         LDKInvalidShutdownScript this_ptr_conv;
45623         this_ptr_conv.inner = untag_ptr(this_ptr);
45624         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
45625         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
45626         this_ptr_conv.is_owned = false;
45627         LDKCVec_u8Z val_ref;
45628         val_ref.datalen = (*env)->GetArrayLength(env, val);
45629         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
45630         (*env)->GetByteArrayRegion(env, val, 0, val_ref.datalen, val_ref.data);
45631         InvalidShutdownScript_set_script(&this_ptr_conv, val_ref);
45632 }
45633
45634 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvalidShutdownScript_1new(JNIEnv *env, jclass clz, int8_tArray script_arg) {
45635         LDKCVec_u8Z script_arg_ref;
45636         script_arg_ref.datalen = (*env)->GetArrayLength(env, script_arg);
45637         script_arg_ref.data = MALLOC(script_arg_ref.datalen, "LDKCVec_u8Z Bytes");
45638         (*env)->GetByteArrayRegion(env, script_arg, 0, script_arg_ref.datalen, script_arg_ref.data);
45639         LDKInvalidShutdownScript ret_var = InvalidShutdownScript_new(script_arg_ref);
45640         int64_t ret_ref = 0;
45641         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45642         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
45643         return ret_ref;
45644 }
45645
45646 static inline uint64_t InvalidShutdownScript_clone_ptr(LDKInvalidShutdownScript *NONNULL_PTR arg) {
45647         LDKInvalidShutdownScript ret_var = InvalidShutdownScript_clone(arg);
45648         int64_t ret_ref = 0;
45649         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45650         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
45651         return ret_ref;
45652 }
45653 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvalidShutdownScript_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
45654         LDKInvalidShutdownScript arg_conv;
45655         arg_conv.inner = untag_ptr(arg);
45656         arg_conv.is_owned = ptr_is_owned(arg);
45657         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
45658         arg_conv.is_owned = false;
45659         int64_t ret_conv = InvalidShutdownScript_clone_ptr(&arg_conv);
45660         return ret_conv;
45661 }
45662
45663 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvalidShutdownScript_1clone(JNIEnv *env, jclass clz, int64_t orig) {
45664         LDKInvalidShutdownScript orig_conv;
45665         orig_conv.inner = untag_ptr(orig);
45666         orig_conv.is_owned = ptr_is_owned(orig);
45667         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
45668         orig_conv.is_owned = false;
45669         LDKInvalidShutdownScript ret_var = InvalidShutdownScript_clone(&orig_conv);
45670         int64_t ret_ref = 0;
45671         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45672         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
45673         return ret_ref;
45674 }
45675
45676 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1write(JNIEnv *env, jclass clz, int64_t obj) {
45677         LDKShutdownScript obj_conv;
45678         obj_conv.inner = untag_ptr(obj);
45679         obj_conv.is_owned = ptr_is_owned(obj);
45680         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
45681         obj_conv.is_owned = false;
45682         LDKCVec_u8Z ret_var = ShutdownScript_write(&obj_conv);
45683         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
45684         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
45685         CVec_u8Z_free(ret_var);
45686         return ret_arr;
45687 }
45688
45689 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
45690         LDKu8slice ser_ref;
45691         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
45692         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
45693         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
45694         *ret_conv = ShutdownScript_read(ser_ref);
45695         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
45696         return tag_ptr(ret_conv, true);
45697 }
45698
45699 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1new_1p2wpkh(JNIEnv *env, jclass clz, int8_tArray pubkey_hash) {
45700         unsigned char pubkey_hash_arr[20];
45701         CHECK((*env)->GetArrayLength(env, pubkey_hash) == 20);
45702         (*env)->GetByteArrayRegion(env, pubkey_hash, 0, 20, pubkey_hash_arr);
45703         unsigned char (*pubkey_hash_ref)[20] = &pubkey_hash_arr;
45704         LDKShutdownScript ret_var = ShutdownScript_new_p2wpkh(pubkey_hash_ref);
45705         int64_t ret_ref = 0;
45706         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45707         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
45708         return ret_ref;
45709 }
45710
45711 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1new_1p2wsh(JNIEnv *env, jclass clz, int8_tArray script_hash) {
45712         unsigned char script_hash_arr[32];
45713         CHECK((*env)->GetArrayLength(env, script_hash) == 32);
45714         (*env)->GetByteArrayRegion(env, script_hash, 0, 32, script_hash_arr);
45715         unsigned char (*script_hash_ref)[32] = &script_hash_arr;
45716         LDKShutdownScript ret_var = ShutdownScript_new_p2wsh(script_hash_ref);
45717         int64_t ret_ref = 0;
45718         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45719         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
45720         return ret_ref;
45721 }
45722
45723 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1new_1witness_1program(JNIEnv *env, jclass clz, int8_t version, int8_tArray program) {
45724         
45725         LDKu8slice program_ref;
45726         program_ref.datalen = (*env)->GetArrayLength(env, program);
45727         program_ref.data = (*env)->GetByteArrayElements (env, program, NULL);
45728         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
45729         *ret_conv = ShutdownScript_new_witness_program((LDKWitnessVersion){ ._0 = version }, program_ref);
45730         (*env)->ReleaseByteArrayElements(env, program, (int8_t*)program_ref.data, 0);
45731         return tag_ptr(ret_conv, true);
45732 }
45733
45734 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1into_1inner(JNIEnv *env, jclass clz, int64_t this_arg) {
45735         LDKShutdownScript this_arg_conv;
45736         this_arg_conv.inner = untag_ptr(this_arg);
45737         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45738         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45739         this_arg_conv = ShutdownScript_clone(&this_arg_conv);
45740         LDKCVec_u8Z ret_var = ShutdownScript_into_inner(this_arg_conv);
45741         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
45742         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
45743         CVec_u8Z_free(ret_var);
45744         return ret_arr;
45745 }
45746
45747 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1as_1legacy_1pubkey(JNIEnv *env, jclass clz, int64_t this_arg) {
45748         LDKShutdownScript this_arg_conv;
45749         this_arg_conv.inner = untag_ptr(this_arg);
45750         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45751         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45752         this_arg_conv.is_owned = false;
45753         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
45754         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ShutdownScript_as_legacy_pubkey(&this_arg_conv).compressed_form);
45755         return ret_arr;
45756 }
45757
45758 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1is_1compatible(JNIEnv *env, jclass clz, int64_t this_arg, int64_t features) {
45759         LDKShutdownScript this_arg_conv;
45760         this_arg_conv.inner = untag_ptr(this_arg);
45761         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45762         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45763         this_arg_conv.is_owned = false;
45764         LDKInitFeatures features_conv;
45765         features_conv.inner = untag_ptr(features);
45766         features_conv.is_owned = ptr_is_owned(features);
45767         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_conv);
45768         features_conv.is_owned = false;
45769         jboolean ret_conv = ShutdownScript_is_compatible(&this_arg_conv, &features_conv);
45770         return ret_conv;
45771 }
45772
45773 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CustomMessageReader_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
45774         if (!ptr_is_owned(this_ptr)) return;
45775         void* this_ptr_ptr = untag_ptr(this_ptr);
45776         CHECK_ACCESS(this_ptr_ptr);
45777         LDKCustomMessageReader this_ptr_conv = *(LDKCustomMessageReader*)(this_ptr_ptr);
45778         FREE(untag_ptr(this_ptr));
45779         CustomMessageReader_free(this_ptr_conv);
45780 }
45781
45782 static inline uint64_t Type_clone_ptr(LDKType *NONNULL_PTR arg) {
45783         LDKType* ret_ret = MALLOC(sizeof(LDKType), "LDKType");
45784         *ret_ret = Type_clone(arg);
45785         return tag_ptr(ret_ret, true);
45786 }
45787 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Type_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
45788         void* arg_ptr = untag_ptr(arg);
45789         if (ptr_is_owned(arg)) { CHECK_ACCESS(arg_ptr); }
45790         LDKType* arg_conv = (LDKType*)arg_ptr;
45791         int64_t ret_conv = Type_clone_ptr(arg_conv);
45792         return ret_conv;
45793 }
45794
45795 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Type_1clone(JNIEnv *env, jclass clz, int64_t orig) {
45796         void* orig_ptr = untag_ptr(orig);
45797         if (ptr_is_owned(orig)) { CHECK_ACCESS(orig_ptr); }
45798         LDKType* orig_conv = (LDKType*)orig_ptr;
45799         LDKType* ret_ret = MALLOC(sizeof(LDKType), "LDKType");
45800         *ret_ret = Type_clone(orig_conv);
45801         return tag_ptr(ret_ret, true);
45802 }
45803
45804 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Type_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
45805         if (!ptr_is_owned(this_ptr)) return;
45806         void* this_ptr_ptr = untag_ptr(this_ptr);
45807         CHECK_ACCESS(this_ptr_ptr);
45808         LDKType this_ptr_conv = *(LDKType*)(this_ptr_ptr);
45809         FREE(untag_ptr(this_ptr));
45810         Type_free(this_ptr_conv);
45811 }
45812
45813 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeId_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
45814         LDKNodeId this_obj_conv;
45815         this_obj_conv.inner = untag_ptr(this_obj);
45816         this_obj_conv.is_owned = ptr_is_owned(this_obj);
45817         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
45818         NodeId_free(this_obj_conv);
45819 }
45820
45821 static inline uint64_t NodeId_clone_ptr(LDKNodeId *NONNULL_PTR arg) {
45822         LDKNodeId ret_var = NodeId_clone(arg);
45823         int64_t ret_ref = 0;
45824         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45825         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
45826         return ret_ref;
45827 }
45828 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeId_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
45829         LDKNodeId arg_conv;
45830         arg_conv.inner = untag_ptr(arg);
45831         arg_conv.is_owned = ptr_is_owned(arg);
45832         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
45833         arg_conv.is_owned = false;
45834         int64_t ret_conv = NodeId_clone_ptr(&arg_conv);
45835         return ret_conv;
45836 }
45837
45838 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeId_1clone(JNIEnv *env, jclass clz, int64_t orig) {
45839         LDKNodeId orig_conv;
45840         orig_conv.inner = untag_ptr(orig);
45841         orig_conv.is_owned = ptr_is_owned(orig);
45842         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
45843         orig_conv.is_owned = false;
45844         LDKNodeId ret_var = NodeId_clone(&orig_conv);
45845         int64_t ret_ref = 0;
45846         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45847         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
45848         return ret_ref;
45849 }
45850
45851 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeId_1from_1pubkey(JNIEnv *env, jclass clz, int8_tArray pubkey) {
45852         LDKPublicKey pubkey_ref;
45853         CHECK((*env)->GetArrayLength(env, pubkey) == 33);
45854         (*env)->GetByteArrayRegion(env, pubkey, 0, 33, pubkey_ref.compressed_form);
45855         LDKNodeId ret_var = NodeId_from_pubkey(pubkey_ref);
45856         int64_t ret_ref = 0;
45857         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
45858         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
45859         return ret_ref;
45860 }
45861
45862 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeId_1as_1slice(JNIEnv *env, jclass clz, int64_t this_arg) {
45863         LDKNodeId this_arg_conv;
45864         this_arg_conv.inner = untag_ptr(this_arg);
45865         this_arg_conv.is_owned = ptr_is_owned(this_arg);
45866         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
45867         this_arg_conv.is_owned = false;
45868         LDKu8slice ret_var = NodeId_as_slice(&this_arg_conv);
45869         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
45870         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
45871         return ret_arr;
45872 }
45873
45874 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeId_1hash(JNIEnv *env, jclass clz, int64_t o) {
45875         LDKNodeId o_conv;
45876         o_conv.inner = untag_ptr(o);
45877         o_conv.is_owned = ptr_is_owned(o);
45878         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
45879         o_conv.is_owned = false;
45880         int64_t ret_conv = NodeId_hash(&o_conv);
45881         return ret_conv;
45882 }
45883
45884 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeId_1write(JNIEnv *env, jclass clz, int64_t obj) {
45885         LDKNodeId obj_conv;
45886         obj_conv.inner = untag_ptr(obj);
45887         obj_conv.is_owned = ptr_is_owned(obj);
45888         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
45889         obj_conv.is_owned = false;
45890         LDKCVec_u8Z ret_var = NodeId_write(&obj_conv);
45891         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
45892         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
45893         CVec_u8Z_free(ret_var);
45894         return ret_arr;
45895 }
45896
45897 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeId_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
45898         LDKu8slice ser_ref;
45899         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
45900         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
45901         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
45902         *ret_conv = NodeId_read(ser_ref);
45903         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
45904         return tag_ptr(ret_conv, true);
45905 }
45906
45907 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
45908         LDKNetworkGraph this_obj_conv;
45909         this_obj_conv.inner = untag_ptr(this_obj);
45910         this_obj_conv.is_owned = ptr_is_owned(this_obj);
45911         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
45912         NetworkGraph_free(this_obj_conv);
45913 }
45914
45915 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReadOnlyNetworkGraph_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
45916         LDKReadOnlyNetworkGraph this_obj_conv;
45917         this_obj_conv.inner = untag_ptr(this_obj);
45918         this_obj_conv.is_owned = ptr_is_owned(this_obj);
45919         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
45920         ReadOnlyNetworkGraph_free(this_obj_conv);
45921 }
45922
45923 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
45924         if (!ptr_is_owned(this_ptr)) return;
45925         void* this_ptr_ptr = untag_ptr(this_ptr);
45926         CHECK_ACCESS(this_ptr_ptr);
45927         LDKNetworkUpdate this_ptr_conv = *(LDKNetworkUpdate*)(this_ptr_ptr);
45928         FREE(untag_ptr(this_ptr));
45929         NetworkUpdate_free(this_ptr_conv);
45930 }
45931
45932 static inline uint64_t NetworkUpdate_clone_ptr(LDKNetworkUpdate *NONNULL_PTR arg) {
45933         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
45934         *ret_copy = NetworkUpdate_clone(arg);
45935         int64_t ret_ref = tag_ptr(ret_copy, true);
45936         return ret_ref;
45937 }
45938 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
45939         LDKNetworkUpdate* arg_conv = (LDKNetworkUpdate*)untag_ptr(arg);
45940         int64_t ret_conv = NetworkUpdate_clone_ptr(arg_conv);
45941         return ret_conv;
45942 }
45943
45944 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
45945         LDKNetworkUpdate* orig_conv = (LDKNetworkUpdate*)untag_ptr(orig);
45946         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
45947         *ret_copy = NetworkUpdate_clone(orig_conv);
45948         int64_t ret_ref = tag_ptr(ret_copy, true);
45949         return ret_ref;
45950 }
45951
45952 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1channel_1update_1message(JNIEnv *env, jclass clz, int64_t msg) {
45953         LDKChannelUpdate msg_conv;
45954         msg_conv.inner = untag_ptr(msg);
45955         msg_conv.is_owned = ptr_is_owned(msg);
45956         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
45957         msg_conv = ChannelUpdate_clone(&msg_conv);
45958         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
45959         *ret_copy = NetworkUpdate_channel_update_message(msg_conv);
45960         int64_t ret_ref = tag_ptr(ret_copy, true);
45961         return ret_ref;
45962 }
45963
45964 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1channel_1failure(JNIEnv *env, jclass clz, int64_t short_channel_id, jboolean is_permanent) {
45965         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
45966         *ret_copy = NetworkUpdate_channel_failure(short_channel_id, is_permanent);
45967         int64_t ret_ref = tag_ptr(ret_copy, true);
45968         return ret_ref;
45969 }
45970
45971 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1node_1failure(JNIEnv *env, jclass clz, int8_tArray node_id, jboolean is_permanent) {
45972         LDKPublicKey node_id_ref;
45973         CHECK((*env)->GetArrayLength(env, node_id) == 33);
45974         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
45975         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
45976         *ret_copy = NetworkUpdate_node_failure(node_id_ref, is_permanent);
45977         int64_t ret_ref = tag_ptr(ret_copy, true);
45978         return ret_ref;
45979 }
45980
45981 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
45982         LDKNetworkUpdate* a_conv = (LDKNetworkUpdate*)untag_ptr(a);
45983         LDKNetworkUpdate* b_conv = (LDKNetworkUpdate*)untag_ptr(b);
45984         jboolean ret_conv = NetworkUpdate_eq(a_conv, b_conv);
45985         return ret_conv;
45986 }
45987
45988 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) {
45989         LDKNetworkUpdate* obj_conv = (LDKNetworkUpdate*)untag_ptr(obj);
45990         LDKCVec_u8Z ret_var = NetworkUpdate_write(obj_conv);
45991         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
45992         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
45993         CVec_u8Z_free(ret_var);
45994         return ret_arr;
45995 }
45996
45997 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
45998         LDKu8slice ser_ref;
45999         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
46000         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
46001         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
46002         *ret_conv = NetworkUpdate_read(ser_ref);
46003         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
46004         return tag_ptr(ret_conv, true);
46005 }
46006
46007 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_P2PGossipSync_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
46008         LDKP2PGossipSync this_obj_conv;
46009         this_obj_conv.inner = untag_ptr(this_obj);
46010         this_obj_conv.is_owned = ptr_is_owned(this_obj);
46011         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
46012         P2PGossipSync_free(this_obj_conv);
46013 }
46014
46015 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) {
46016         LDKNetworkGraph network_graph_conv;
46017         network_graph_conv.inner = untag_ptr(network_graph);
46018         network_graph_conv.is_owned = ptr_is_owned(network_graph);
46019         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
46020         network_graph_conv.is_owned = false;
46021         void* chain_access_ptr = untag_ptr(chain_access);
46022         CHECK_ACCESS(chain_access_ptr);
46023         LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(chain_access_ptr);
46024         // WARNING: we may need a move here but no clone is available for LDKCOption_AccessZ
46025         if (chain_access_conv.tag == LDKCOption_AccessZ_Some) {
46026                 // Manually implement clone for Java trait instances
46027                 if (chain_access_conv.some.free == LDKAccess_JCalls_free) {
46028                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
46029                         LDKAccess_JCalls_cloned(&chain_access_conv.some);
46030                 }
46031         }
46032         void* logger_ptr = untag_ptr(logger);
46033         CHECK_ACCESS(logger_ptr);
46034         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
46035         if (logger_conv.free == LDKLogger_JCalls_free) {
46036                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
46037                 LDKLogger_JCalls_cloned(&logger_conv);
46038         }
46039         LDKP2PGossipSync ret_var = P2PGossipSync_new(&network_graph_conv, chain_access_conv, logger_conv);
46040         int64_t ret_ref = 0;
46041         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46042         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
46043         return ret_ref;
46044 }
46045
46046 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_P2PGossipSync_1add_1chain_1access(JNIEnv *env, jclass clz, int64_t this_arg, int64_t chain_access) {
46047         LDKP2PGossipSync this_arg_conv;
46048         this_arg_conv.inner = untag_ptr(this_arg);
46049         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46050         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46051         this_arg_conv.is_owned = false;
46052         void* chain_access_ptr = untag_ptr(chain_access);
46053         CHECK_ACCESS(chain_access_ptr);
46054         LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(chain_access_ptr);
46055         // WARNING: we may need a move here but no clone is available for LDKCOption_AccessZ
46056         if (chain_access_conv.tag == LDKCOption_AccessZ_Some) {
46057                 // Manually implement clone for Java trait instances
46058                 if (chain_access_conv.some.free == LDKAccess_JCalls_free) {
46059                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
46060                         LDKAccess_JCalls_cloned(&chain_access_conv.some);
46061                 }
46062         }
46063         P2PGossipSync_add_chain_access(&this_arg_conv, chain_access_conv);
46064 }
46065
46066 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1handle_1network_1update(JNIEnv *env, jclass clz, int64_t this_arg, int64_t network_update) {
46067         LDKNetworkGraph this_arg_conv;
46068         this_arg_conv.inner = untag_ptr(this_arg);
46069         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46070         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46071         this_arg_conv.is_owned = false;
46072         LDKNetworkUpdate* network_update_conv = (LDKNetworkUpdate*)untag_ptr(network_update);
46073         NetworkGraph_handle_network_update(&this_arg_conv, network_update_conv);
46074 }
46075
46076 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_P2PGossipSync_1as_1RoutingMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
46077         LDKP2PGossipSync this_arg_conv;
46078         this_arg_conv.inner = untag_ptr(this_arg);
46079         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46080         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46081         this_arg_conv.is_owned = false;
46082         LDKRoutingMessageHandler* ret_ret = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
46083         *ret_ret = P2PGossipSync_as_RoutingMessageHandler(&this_arg_conv);
46084         return tag_ptr(ret_ret, true);
46085 }
46086
46087 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_P2PGossipSync_1as_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
46088         LDKP2PGossipSync this_arg_conv;
46089         this_arg_conv.inner = untag_ptr(this_arg);
46090         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46091         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46092         this_arg_conv.is_owned = false;
46093         LDKMessageSendEventsProvider* ret_ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
46094         *ret_ret = P2PGossipSync_as_MessageSendEventsProvider(&this_arg_conv);
46095         return tag_ptr(ret_ret, true);
46096 }
46097
46098 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
46099         LDKChannelUpdateInfo this_obj_conv;
46100         this_obj_conv.inner = untag_ptr(this_obj);
46101         this_obj_conv.is_owned = ptr_is_owned(this_obj);
46102         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
46103         ChannelUpdateInfo_free(this_obj_conv);
46104 }
46105
46106 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1get_1last_1update(JNIEnv *env, jclass clz, int64_t this_ptr) {
46107         LDKChannelUpdateInfo this_ptr_conv;
46108         this_ptr_conv.inner = untag_ptr(this_ptr);
46109         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
46110         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46111         this_ptr_conv.is_owned = false;
46112         int32_t ret_conv = ChannelUpdateInfo_get_last_update(&this_ptr_conv);
46113         return ret_conv;
46114 }
46115
46116 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1set_1last_1update(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
46117         LDKChannelUpdateInfo this_ptr_conv;
46118         this_ptr_conv.inner = untag_ptr(this_ptr);
46119         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
46120         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46121         this_ptr_conv.is_owned = false;
46122         ChannelUpdateInfo_set_last_update(&this_ptr_conv, val);
46123 }
46124
46125 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1get_1enabled(JNIEnv *env, jclass clz, int64_t this_ptr) {
46126         LDKChannelUpdateInfo this_ptr_conv;
46127         this_ptr_conv.inner = untag_ptr(this_ptr);
46128         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
46129         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46130         this_ptr_conv.is_owned = false;
46131         jboolean ret_conv = ChannelUpdateInfo_get_enabled(&this_ptr_conv);
46132         return ret_conv;
46133 }
46134
46135 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1set_1enabled(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
46136         LDKChannelUpdateInfo this_ptr_conv;
46137         this_ptr_conv.inner = untag_ptr(this_ptr);
46138         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
46139         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46140         this_ptr_conv.is_owned = false;
46141         ChannelUpdateInfo_set_enabled(&this_ptr_conv, val);
46142 }
46143
46144 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
46145         LDKChannelUpdateInfo this_ptr_conv;
46146         this_ptr_conv.inner = untag_ptr(this_ptr);
46147         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
46148         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46149         this_ptr_conv.is_owned = false;
46150         int16_t ret_conv = ChannelUpdateInfo_get_cltv_expiry_delta(&this_ptr_conv);
46151         return ret_conv;
46152 }
46153
46154 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
46155         LDKChannelUpdateInfo this_ptr_conv;
46156         this_ptr_conv.inner = untag_ptr(this_ptr);
46157         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
46158         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46159         this_ptr_conv.is_owned = false;
46160         ChannelUpdateInfo_set_cltv_expiry_delta(&this_ptr_conv, val);
46161 }
46162
46163 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
46164         LDKChannelUpdateInfo this_ptr_conv;
46165         this_ptr_conv.inner = untag_ptr(this_ptr);
46166         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
46167         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46168         this_ptr_conv.is_owned = false;
46169         int64_t ret_conv = ChannelUpdateInfo_get_htlc_minimum_msat(&this_ptr_conv);
46170         return ret_conv;
46171 }
46172
46173 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
46174         LDKChannelUpdateInfo this_ptr_conv;
46175         this_ptr_conv.inner = untag_ptr(this_ptr);
46176         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
46177         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46178         this_ptr_conv.is_owned = false;
46179         ChannelUpdateInfo_set_htlc_minimum_msat(&this_ptr_conv, val);
46180 }
46181
46182 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1get_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
46183         LDKChannelUpdateInfo this_ptr_conv;
46184         this_ptr_conv.inner = untag_ptr(this_ptr);
46185         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
46186         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46187         this_ptr_conv.is_owned = false;
46188         int64_t ret_conv = ChannelUpdateInfo_get_htlc_maximum_msat(&this_ptr_conv);
46189         return ret_conv;
46190 }
46191
46192 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1set_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
46193         LDKChannelUpdateInfo this_ptr_conv;
46194         this_ptr_conv.inner = untag_ptr(this_ptr);
46195         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
46196         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46197         this_ptr_conv.is_owned = false;
46198         ChannelUpdateInfo_set_htlc_maximum_msat(&this_ptr_conv, val);
46199 }
46200
46201 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1get_1fees(JNIEnv *env, jclass clz, int64_t this_ptr) {
46202         LDKChannelUpdateInfo this_ptr_conv;
46203         this_ptr_conv.inner = untag_ptr(this_ptr);
46204         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
46205         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46206         this_ptr_conv.is_owned = false;
46207         LDKRoutingFees ret_var = ChannelUpdateInfo_get_fees(&this_ptr_conv);
46208         int64_t ret_ref = 0;
46209         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46210         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
46211         return ret_ref;
46212 }
46213
46214 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1set_1fees(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
46215         LDKChannelUpdateInfo this_ptr_conv;
46216         this_ptr_conv.inner = untag_ptr(this_ptr);
46217         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
46218         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46219         this_ptr_conv.is_owned = false;
46220         LDKRoutingFees val_conv;
46221         val_conv.inner = untag_ptr(val);
46222         val_conv.is_owned = ptr_is_owned(val);
46223         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
46224         val_conv = RoutingFees_clone(&val_conv);
46225         ChannelUpdateInfo_set_fees(&this_ptr_conv, val_conv);
46226 }
46227
46228 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1get_1last_1update_1message(JNIEnv *env, jclass clz, int64_t this_ptr) {
46229         LDKChannelUpdateInfo this_ptr_conv;
46230         this_ptr_conv.inner = untag_ptr(this_ptr);
46231         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
46232         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46233         this_ptr_conv.is_owned = false;
46234         LDKChannelUpdate ret_var = ChannelUpdateInfo_get_last_update_message(&this_ptr_conv);
46235         int64_t ret_ref = 0;
46236         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46237         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
46238         return ret_ref;
46239 }
46240
46241 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1set_1last_1update_1message(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
46242         LDKChannelUpdateInfo this_ptr_conv;
46243         this_ptr_conv.inner = untag_ptr(this_ptr);
46244         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
46245         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46246         this_ptr_conv.is_owned = false;
46247         LDKChannelUpdate val_conv;
46248         val_conv.inner = untag_ptr(val);
46249         val_conv.is_owned = ptr_is_owned(val);
46250         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
46251         val_conv = ChannelUpdate_clone(&val_conv);
46252         ChannelUpdateInfo_set_last_update_message(&this_ptr_conv, val_conv);
46253 }
46254
46255 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) {
46256         LDKRoutingFees fees_arg_conv;
46257         fees_arg_conv.inner = untag_ptr(fees_arg);
46258         fees_arg_conv.is_owned = ptr_is_owned(fees_arg);
46259         CHECK_INNER_FIELD_ACCESS_OR_NULL(fees_arg_conv);
46260         fees_arg_conv = RoutingFees_clone(&fees_arg_conv);
46261         LDKChannelUpdate last_update_message_arg_conv;
46262         last_update_message_arg_conv.inner = untag_ptr(last_update_message_arg);
46263         last_update_message_arg_conv.is_owned = ptr_is_owned(last_update_message_arg);
46264         CHECK_INNER_FIELD_ACCESS_OR_NULL(last_update_message_arg_conv);
46265         last_update_message_arg_conv = ChannelUpdate_clone(&last_update_message_arg_conv);
46266         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);
46267         int64_t ret_ref = 0;
46268         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46269         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
46270         return ret_ref;
46271 }
46272
46273 static inline uint64_t ChannelUpdateInfo_clone_ptr(LDKChannelUpdateInfo *NONNULL_PTR arg) {
46274         LDKChannelUpdateInfo ret_var = ChannelUpdateInfo_clone(arg);
46275         int64_t ret_ref = 0;
46276         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46277         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
46278         return ret_ref;
46279 }
46280 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
46281         LDKChannelUpdateInfo arg_conv;
46282         arg_conv.inner = untag_ptr(arg);
46283         arg_conv.is_owned = ptr_is_owned(arg);
46284         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
46285         arg_conv.is_owned = false;
46286         int64_t ret_conv = ChannelUpdateInfo_clone_ptr(&arg_conv);
46287         return ret_conv;
46288 }
46289
46290 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
46291         LDKChannelUpdateInfo orig_conv;
46292         orig_conv.inner = untag_ptr(orig);
46293         orig_conv.is_owned = ptr_is_owned(orig);
46294         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
46295         orig_conv.is_owned = false;
46296         LDKChannelUpdateInfo ret_var = ChannelUpdateInfo_clone(&orig_conv);
46297         int64_t ret_ref = 0;
46298         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46299         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
46300         return ret_ref;
46301 }
46302
46303 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
46304         LDKChannelUpdateInfo a_conv;
46305         a_conv.inner = untag_ptr(a);
46306         a_conv.is_owned = ptr_is_owned(a);
46307         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
46308         a_conv.is_owned = false;
46309         LDKChannelUpdateInfo b_conv;
46310         b_conv.inner = untag_ptr(b);
46311         b_conv.is_owned = ptr_is_owned(b);
46312         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
46313         b_conv.is_owned = false;
46314         jboolean ret_conv = ChannelUpdateInfo_eq(&a_conv, &b_conv);
46315         return ret_conv;
46316 }
46317
46318 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1write(JNIEnv *env, jclass clz, int64_t obj) {
46319         LDKChannelUpdateInfo obj_conv;
46320         obj_conv.inner = untag_ptr(obj);
46321         obj_conv.is_owned = ptr_is_owned(obj);
46322         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
46323         obj_conv.is_owned = false;
46324         LDKCVec_u8Z ret_var = ChannelUpdateInfo_write(&obj_conv);
46325         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
46326         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
46327         CVec_u8Z_free(ret_var);
46328         return ret_arr;
46329 }
46330
46331 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdateInfo_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
46332         LDKu8slice ser_ref;
46333         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
46334         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
46335         LDKCResult_ChannelUpdateInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateInfoDecodeErrorZ), "LDKCResult_ChannelUpdateInfoDecodeErrorZ");
46336         *ret_conv = ChannelUpdateInfo_read(ser_ref);
46337         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
46338         return tag_ptr(ret_conv, true);
46339 }
46340
46341 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
46342         LDKChannelInfo this_obj_conv;
46343         this_obj_conv.inner = untag_ptr(this_obj);
46344         this_obj_conv.is_owned = ptr_is_owned(this_obj);
46345         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
46346         ChannelInfo_free(this_obj_conv);
46347 }
46348
46349 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
46350         LDKChannelInfo this_ptr_conv;
46351         this_ptr_conv.inner = untag_ptr(this_ptr);
46352         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
46353         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46354         this_ptr_conv.is_owned = false;
46355         LDKChannelFeatures ret_var = ChannelInfo_get_features(&this_ptr_conv);
46356         int64_t ret_ref = 0;
46357         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46358         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
46359         return ret_ref;
46360 }
46361
46362 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
46363         LDKChannelInfo this_ptr_conv;
46364         this_ptr_conv.inner = untag_ptr(this_ptr);
46365         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
46366         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46367         this_ptr_conv.is_owned = false;
46368         LDKChannelFeatures val_conv;
46369         val_conv.inner = untag_ptr(val);
46370         val_conv.is_owned = ptr_is_owned(val);
46371         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
46372         val_conv = ChannelFeatures_clone(&val_conv);
46373         ChannelInfo_set_features(&this_ptr_conv, val_conv);
46374 }
46375
46376 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1node_1one(JNIEnv *env, jclass clz, int64_t this_ptr) {
46377         LDKChannelInfo this_ptr_conv;
46378         this_ptr_conv.inner = untag_ptr(this_ptr);
46379         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
46380         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46381         this_ptr_conv.is_owned = false;
46382         LDKNodeId ret_var = ChannelInfo_get_node_one(&this_ptr_conv);
46383         int64_t ret_ref = 0;
46384         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46385         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
46386         return ret_ref;
46387 }
46388
46389 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1node_1one(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
46390         LDKChannelInfo this_ptr_conv;
46391         this_ptr_conv.inner = untag_ptr(this_ptr);
46392         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
46393         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46394         this_ptr_conv.is_owned = false;
46395         LDKNodeId val_conv;
46396         val_conv.inner = untag_ptr(val);
46397         val_conv.is_owned = ptr_is_owned(val);
46398         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
46399         val_conv = NodeId_clone(&val_conv);
46400         ChannelInfo_set_node_one(&this_ptr_conv, val_conv);
46401 }
46402
46403 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1one_1to_1two(JNIEnv *env, jclass clz, int64_t this_ptr) {
46404         LDKChannelInfo this_ptr_conv;
46405         this_ptr_conv.inner = untag_ptr(this_ptr);
46406         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
46407         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46408         this_ptr_conv.is_owned = false;
46409         LDKChannelUpdateInfo ret_var = ChannelInfo_get_one_to_two(&this_ptr_conv);
46410         int64_t ret_ref = 0;
46411         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46412         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
46413         return ret_ref;
46414 }
46415
46416 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1one_1to_1two(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
46417         LDKChannelInfo this_ptr_conv;
46418         this_ptr_conv.inner = untag_ptr(this_ptr);
46419         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
46420         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46421         this_ptr_conv.is_owned = false;
46422         LDKChannelUpdateInfo val_conv;
46423         val_conv.inner = untag_ptr(val);
46424         val_conv.is_owned = ptr_is_owned(val);
46425         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
46426         val_conv = ChannelUpdateInfo_clone(&val_conv);
46427         ChannelInfo_set_one_to_two(&this_ptr_conv, val_conv);
46428 }
46429
46430 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1node_1two(JNIEnv *env, jclass clz, int64_t this_ptr) {
46431         LDKChannelInfo this_ptr_conv;
46432         this_ptr_conv.inner = untag_ptr(this_ptr);
46433         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
46434         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46435         this_ptr_conv.is_owned = false;
46436         LDKNodeId ret_var = ChannelInfo_get_node_two(&this_ptr_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 void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1node_1two(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
46444         LDKChannelInfo this_ptr_conv;
46445         this_ptr_conv.inner = untag_ptr(this_ptr);
46446         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
46447         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46448         this_ptr_conv.is_owned = false;
46449         LDKNodeId val_conv;
46450         val_conv.inner = untag_ptr(val);
46451         val_conv.is_owned = ptr_is_owned(val);
46452         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
46453         val_conv = NodeId_clone(&val_conv);
46454         ChannelInfo_set_node_two(&this_ptr_conv, val_conv);
46455 }
46456
46457 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1two_1to_1one(JNIEnv *env, jclass clz, int64_t this_ptr) {
46458         LDKChannelInfo this_ptr_conv;
46459         this_ptr_conv.inner = untag_ptr(this_ptr);
46460         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
46461         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46462         this_ptr_conv.is_owned = false;
46463         LDKChannelUpdateInfo ret_var = ChannelInfo_get_two_to_one(&this_ptr_conv);
46464         int64_t ret_ref = 0;
46465         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46466         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
46467         return ret_ref;
46468 }
46469
46470 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1two_1to_1one(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
46471         LDKChannelInfo this_ptr_conv;
46472         this_ptr_conv.inner = untag_ptr(this_ptr);
46473         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
46474         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46475         this_ptr_conv.is_owned = false;
46476         LDKChannelUpdateInfo val_conv;
46477         val_conv.inner = untag_ptr(val);
46478         val_conv.is_owned = ptr_is_owned(val);
46479         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
46480         val_conv = ChannelUpdateInfo_clone(&val_conv);
46481         ChannelInfo_set_two_to_one(&this_ptr_conv, val_conv);
46482 }
46483
46484 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1capacity_1sats(JNIEnv *env, jclass clz, int64_t this_ptr) {
46485         LDKChannelInfo this_ptr_conv;
46486         this_ptr_conv.inner = untag_ptr(this_ptr);
46487         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
46488         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46489         this_ptr_conv.is_owned = false;
46490         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
46491         *ret_copy = ChannelInfo_get_capacity_sats(&this_ptr_conv);
46492         int64_t ret_ref = tag_ptr(ret_copy, true);
46493         return ret_ref;
46494 }
46495
46496 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1capacity_1sats(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
46497         LDKChannelInfo this_ptr_conv;
46498         this_ptr_conv.inner = untag_ptr(this_ptr);
46499         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
46500         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46501         this_ptr_conv.is_owned = false;
46502         void* val_ptr = untag_ptr(val);
46503         CHECK_ACCESS(val_ptr);
46504         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
46505         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(val));
46506         ChannelInfo_set_capacity_sats(&this_ptr_conv, val_conv);
46507 }
46508
46509 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1announcement_1message(JNIEnv *env, jclass clz, int64_t this_ptr) {
46510         LDKChannelInfo this_ptr_conv;
46511         this_ptr_conv.inner = untag_ptr(this_ptr);
46512         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
46513         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46514         this_ptr_conv.is_owned = false;
46515         LDKChannelAnnouncement ret_var = ChannelInfo_get_announcement_message(&this_ptr_conv);
46516         int64_t ret_ref = 0;
46517         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46518         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
46519         return ret_ref;
46520 }
46521
46522 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1announcement_1message(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
46523         LDKChannelInfo this_ptr_conv;
46524         this_ptr_conv.inner = untag_ptr(this_ptr);
46525         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
46526         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46527         this_ptr_conv.is_owned = false;
46528         LDKChannelAnnouncement val_conv;
46529         val_conv.inner = untag_ptr(val);
46530         val_conv.is_owned = ptr_is_owned(val);
46531         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
46532         val_conv = ChannelAnnouncement_clone(&val_conv);
46533         ChannelInfo_set_announcement_message(&this_ptr_conv, val_conv);
46534 }
46535
46536 static inline uint64_t ChannelInfo_clone_ptr(LDKChannelInfo *NONNULL_PTR arg) {
46537         LDKChannelInfo ret_var = ChannelInfo_clone(arg);
46538         int64_t ret_ref = 0;
46539         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46540         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
46541         return ret_ref;
46542 }
46543 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
46544         LDKChannelInfo arg_conv;
46545         arg_conv.inner = untag_ptr(arg);
46546         arg_conv.is_owned = ptr_is_owned(arg);
46547         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
46548         arg_conv.is_owned = false;
46549         int64_t ret_conv = ChannelInfo_clone_ptr(&arg_conv);
46550         return ret_conv;
46551 }
46552
46553 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
46554         LDKChannelInfo orig_conv;
46555         orig_conv.inner = untag_ptr(orig);
46556         orig_conv.is_owned = ptr_is_owned(orig);
46557         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
46558         orig_conv.is_owned = false;
46559         LDKChannelInfo ret_var = ChannelInfo_clone(&orig_conv);
46560         int64_t ret_ref = 0;
46561         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46562         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
46563         return ret_ref;
46564 }
46565
46566 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
46567         LDKChannelInfo a_conv;
46568         a_conv.inner = untag_ptr(a);
46569         a_conv.is_owned = ptr_is_owned(a);
46570         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
46571         a_conv.is_owned = false;
46572         LDKChannelInfo b_conv;
46573         b_conv.inner = untag_ptr(b);
46574         b_conv.is_owned = ptr_is_owned(b);
46575         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
46576         b_conv.is_owned = false;
46577         jboolean ret_conv = ChannelInfo_eq(&a_conv, &b_conv);
46578         return ret_conv;
46579 }
46580
46581 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) {
46582         LDKChannelInfo this_arg_conv;
46583         this_arg_conv.inner = untag_ptr(this_arg);
46584         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46585         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46586         this_arg_conv.is_owned = false;
46587         LDKChannelUpdateInfo ret_var = ChannelInfo_get_directional_info(&this_arg_conv, channel_flags);
46588         int64_t ret_ref = 0;
46589         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46590         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
46591         return ret_ref;
46592 }
46593
46594 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1write(JNIEnv *env, jclass clz, int64_t obj) {
46595         LDKChannelInfo obj_conv;
46596         obj_conv.inner = untag_ptr(obj);
46597         obj_conv.is_owned = ptr_is_owned(obj);
46598         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
46599         obj_conv.is_owned = false;
46600         LDKCVec_u8Z ret_var = ChannelInfo_write(&obj_conv);
46601         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
46602         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
46603         CVec_u8Z_free(ret_var);
46604         return ret_arr;
46605 }
46606
46607 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
46608         LDKu8slice ser_ref;
46609         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
46610         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
46611         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
46612         *ret_conv = ChannelInfo_read(ser_ref);
46613         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
46614         return tag_ptr(ret_conv, true);
46615 }
46616
46617 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectedChannelInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
46618         LDKDirectedChannelInfo this_obj_conv;
46619         this_obj_conv.inner = untag_ptr(this_obj);
46620         this_obj_conv.is_owned = ptr_is_owned(this_obj);
46621         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
46622         DirectedChannelInfo_free(this_obj_conv);
46623 }
46624
46625 static inline uint64_t DirectedChannelInfo_clone_ptr(LDKDirectedChannelInfo *NONNULL_PTR arg) {
46626         LDKDirectedChannelInfo ret_var = DirectedChannelInfo_clone(arg);
46627         int64_t ret_ref = 0;
46628         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46629         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
46630         return ret_ref;
46631 }
46632 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelInfo_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
46633         LDKDirectedChannelInfo arg_conv;
46634         arg_conv.inner = untag_ptr(arg);
46635         arg_conv.is_owned = ptr_is_owned(arg);
46636         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
46637         arg_conv.is_owned = false;
46638         int64_t ret_conv = DirectedChannelInfo_clone_ptr(&arg_conv);
46639         return ret_conv;
46640 }
46641
46642 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
46643         LDKDirectedChannelInfo orig_conv;
46644         orig_conv.inner = untag_ptr(orig);
46645         orig_conv.is_owned = ptr_is_owned(orig);
46646         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
46647         orig_conv.is_owned = false;
46648         LDKDirectedChannelInfo ret_var = DirectedChannelInfo_clone(&orig_conv);
46649         int64_t ret_ref = 0;
46650         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46651         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
46652         return ret_ref;
46653 }
46654
46655 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelInfo_1channel(JNIEnv *env, jclass clz, int64_t this_arg) {
46656         LDKDirectedChannelInfo this_arg_conv;
46657         this_arg_conv.inner = untag_ptr(this_arg);
46658         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46659         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46660         this_arg_conv.is_owned = false;
46661         LDKChannelInfo ret_var = DirectedChannelInfo_channel(&this_arg_conv);
46662         int64_t ret_ref = 0;
46663         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46664         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
46665         return ret_ref;
46666 }
46667
46668 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelInfo_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_arg) {
46669         LDKDirectedChannelInfo this_arg_conv;
46670         this_arg_conv.inner = untag_ptr(this_arg);
46671         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46672         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46673         this_arg_conv.is_owned = false;
46674         int64_t ret_conv = DirectedChannelInfo_htlc_maximum_msat(&this_arg_conv);
46675         return ret_conv;
46676 }
46677
46678 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelInfo_1effective_1capacity(JNIEnv *env, jclass clz, int64_t this_arg) {
46679         LDKDirectedChannelInfo this_arg_conv;
46680         this_arg_conv.inner = untag_ptr(this_arg);
46681         this_arg_conv.is_owned = ptr_is_owned(this_arg);
46682         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
46683         this_arg_conv.is_owned = false;
46684         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
46685         *ret_copy = DirectedChannelInfo_effective_capacity(&this_arg_conv);
46686         int64_t ret_ref = tag_ptr(ret_copy, true);
46687         return ret_ref;
46688 }
46689
46690 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_EffectiveCapacity_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
46691         if (!ptr_is_owned(this_ptr)) return;
46692         void* this_ptr_ptr = untag_ptr(this_ptr);
46693         CHECK_ACCESS(this_ptr_ptr);
46694         LDKEffectiveCapacity this_ptr_conv = *(LDKEffectiveCapacity*)(this_ptr_ptr);
46695         FREE(untag_ptr(this_ptr));
46696         EffectiveCapacity_free(this_ptr_conv);
46697 }
46698
46699 static inline uint64_t EffectiveCapacity_clone_ptr(LDKEffectiveCapacity *NONNULL_PTR arg) {
46700         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
46701         *ret_copy = EffectiveCapacity_clone(arg);
46702         int64_t ret_ref = tag_ptr(ret_copy, true);
46703         return ret_ref;
46704 }
46705 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_EffectiveCapacity_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
46706         LDKEffectiveCapacity* arg_conv = (LDKEffectiveCapacity*)untag_ptr(arg);
46707         int64_t ret_conv = EffectiveCapacity_clone_ptr(arg_conv);
46708         return ret_conv;
46709 }
46710
46711 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_EffectiveCapacity_1clone(JNIEnv *env, jclass clz, int64_t orig) {
46712         LDKEffectiveCapacity* orig_conv = (LDKEffectiveCapacity*)untag_ptr(orig);
46713         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
46714         *ret_copy = EffectiveCapacity_clone(orig_conv);
46715         int64_t ret_ref = tag_ptr(ret_copy, true);
46716         return ret_ref;
46717 }
46718
46719 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_EffectiveCapacity_1exact_1liquidity(JNIEnv *env, jclass clz, int64_t liquidity_msat) {
46720         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
46721         *ret_copy = EffectiveCapacity_exact_liquidity(liquidity_msat);
46722         int64_t ret_ref = tag_ptr(ret_copy, true);
46723         return ret_ref;
46724 }
46725
46726 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_EffectiveCapacity_1maximum_1htlc(JNIEnv *env, jclass clz, int64_t amount_msat) {
46727         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
46728         *ret_copy = EffectiveCapacity_maximum_htlc(amount_msat);
46729         int64_t ret_ref = tag_ptr(ret_copy, true);
46730         return ret_ref;
46731 }
46732
46733 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_EffectiveCapacity_1total(JNIEnv *env, jclass clz, int64_t capacity_msat, int64_t htlc_maximum_msat) {
46734         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
46735         *ret_copy = EffectiveCapacity_total(capacity_msat, htlc_maximum_msat);
46736         int64_t ret_ref = tag_ptr(ret_copy, true);
46737         return ret_ref;
46738 }
46739
46740 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_EffectiveCapacity_1infinite(JNIEnv *env, jclass clz) {
46741         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
46742         *ret_copy = EffectiveCapacity_infinite();
46743         int64_t ret_ref = tag_ptr(ret_copy, true);
46744         return ret_ref;
46745 }
46746
46747 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_EffectiveCapacity_1unknown(JNIEnv *env, jclass clz) {
46748         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
46749         *ret_copy = EffectiveCapacity_unknown();
46750         int64_t ret_ref = tag_ptr(ret_copy, true);
46751         return ret_ref;
46752 }
46753
46754 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_EffectiveCapacity_1as_1msat(JNIEnv *env, jclass clz, int64_t this_arg) {
46755         LDKEffectiveCapacity* this_arg_conv = (LDKEffectiveCapacity*)untag_ptr(this_arg);
46756         int64_t ret_conv = EffectiveCapacity_as_msat(this_arg_conv);
46757         return ret_conv;
46758 }
46759
46760 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingFees_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
46761         LDKRoutingFees this_obj_conv;
46762         this_obj_conv.inner = untag_ptr(this_obj);
46763         this_obj_conv.is_owned = ptr_is_owned(this_obj);
46764         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
46765         RoutingFees_free(this_obj_conv);
46766 }
46767
46768 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1get_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
46769         LDKRoutingFees this_ptr_conv;
46770         this_ptr_conv.inner = untag_ptr(this_ptr);
46771         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
46772         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46773         this_ptr_conv.is_owned = false;
46774         int32_t ret_conv = RoutingFees_get_base_msat(&this_ptr_conv);
46775         return ret_conv;
46776 }
46777
46778 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingFees_1set_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
46779         LDKRoutingFees this_ptr_conv;
46780         this_ptr_conv.inner = untag_ptr(this_ptr);
46781         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
46782         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46783         this_ptr_conv.is_owned = false;
46784         RoutingFees_set_base_msat(&this_ptr_conv, val);
46785 }
46786
46787 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1get_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr) {
46788         LDKRoutingFees this_ptr_conv;
46789         this_ptr_conv.inner = untag_ptr(this_ptr);
46790         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
46791         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46792         this_ptr_conv.is_owned = false;
46793         int32_t ret_conv = RoutingFees_get_proportional_millionths(&this_ptr_conv);
46794         return ret_conv;
46795 }
46796
46797 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingFees_1set_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
46798         LDKRoutingFees this_ptr_conv;
46799         this_ptr_conv.inner = untag_ptr(this_ptr);
46800         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
46801         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46802         this_ptr_conv.is_owned = false;
46803         RoutingFees_set_proportional_millionths(&this_ptr_conv, val);
46804 }
46805
46806 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) {
46807         LDKRoutingFees ret_var = RoutingFees_new(base_msat_arg, proportional_millionths_arg);
46808         int64_t ret_ref = 0;
46809         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46810         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
46811         return ret_ref;
46812 }
46813
46814 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RoutingFees_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
46815         LDKRoutingFees a_conv;
46816         a_conv.inner = untag_ptr(a);
46817         a_conv.is_owned = ptr_is_owned(a);
46818         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
46819         a_conv.is_owned = false;
46820         LDKRoutingFees b_conv;
46821         b_conv.inner = untag_ptr(b);
46822         b_conv.is_owned = ptr_is_owned(b);
46823         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
46824         b_conv.is_owned = false;
46825         jboolean ret_conv = RoutingFees_eq(&a_conv, &b_conv);
46826         return ret_conv;
46827 }
46828
46829 static inline uint64_t RoutingFees_clone_ptr(LDKRoutingFees *NONNULL_PTR arg) {
46830         LDKRoutingFees ret_var = RoutingFees_clone(arg);
46831         int64_t ret_ref = 0;
46832         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46833         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
46834         return ret_ref;
46835 }
46836 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
46837         LDKRoutingFees arg_conv;
46838         arg_conv.inner = untag_ptr(arg);
46839         arg_conv.is_owned = ptr_is_owned(arg);
46840         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
46841         arg_conv.is_owned = false;
46842         int64_t ret_conv = RoutingFees_clone_ptr(&arg_conv);
46843         return ret_conv;
46844 }
46845
46846 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1clone(JNIEnv *env, jclass clz, int64_t orig) {
46847         LDKRoutingFees orig_conv;
46848         orig_conv.inner = untag_ptr(orig);
46849         orig_conv.is_owned = ptr_is_owned(orig);
46850         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
46851         orig_conv.is_owned = false;
46852         LDKRoutingFees ret_var = RoutingFees_clone(&orig_conv);
46853         int64_t ret_ref = 0;
46854         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46855         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
46856         return ret_ref;
46857 }
46858
46859 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1hash(JNIEnv *env, jclass clz, int64_t o) {
46860         LDKRoutingFees o_conv;
46861         o_conv.inner = untag_ptr(o);
46862         o_conv.is_owned = ptr_is_owned(o);
46863         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
46864         o_conv.is_owned = false;
46865         int64_t ret_conv = RoutingFees_hash(&o_conv);
46866         return ret_conv;
46867 }
46868
46869 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RoutingFees_1write(JNIEnv *env, jclass clz, int64_t obj) {
46870         LDKRoutingFees obj_conv;
46871         obj_conv.inner = untag_ptr(obj);
46872         obj_conv.is_owned = ptr_is_owned(obj);
46873         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
46874         obj_conv.is_owned = false;
46875         LDKCVec_u8Z ret_var = RoutingFees_write(&obj_conv);
46876         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
46877         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
46878         CVec_u8Z_free(ret_var);
46879         return ret_arr;
46880 }
46881
46882 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
46883         LDKu8slice ser_ref;
46884         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
46885         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
46886         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
46887         *ret_conv = RoutingFees_read(ser_ref);
46888         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
46889         return tag_ptr(ret_conv, true);
46890 }
46891
46892 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
46893         LDKNodeAnnouncementInfo this_obj_conv;
46894         this_obj_conv.inner = untag_ptr(this_obj);
46895         this_obj_conv.is_owned = ptr_is_owned(this_obj);
46896         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
46897         NodeAnnouncementInfo_free(this_obj_conv);
46898 }
46899
46900 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
46901         LDKNodeAnnouncementInfo this_ptr_conv;
46902         this_ptr_conv.inner = untag_ptr(this_ptr);
46903         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
46904         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46905         this_ptr_conv.is_owned = false;
46906         LDKNodeFeatures ret_var = NodeAnnouncementInfo_get_features(&this_ptr_conv);
46907         int64_t ret_ref = 0;
46908         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
46909         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
46910         return ret_ref;
46911 }
46912
46913 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
46914         LDKNodeAnnouncementInfo this_ptr_conv;
46915         this_ptr_conv.inner = untag_ptr(this_ptr);
46916         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
46917         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46918         this_ptr_conv.is_owned = false;
46919         LDKNodeFeatures val_conv;
46920         val_conv.inner = untag_ptr(val);
46921         val_conv.is_owned = ptr_is_owned(val);
46922         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
46923         val_conv = NodeFeatures_clone(&val_conv);
46924         NodeAnnouncementInfo_set_features(&this_ptr_conv, val_conv);
46925 }
46926
46927 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1last_1update(JNIEnv *env, jclass clz, int64_t this_ptr) {
46928         LDKNodeAnnouncementInfo this_ptr_conv;
46929         this_ptr_conv.inner = untag_ptr(this_ptr);
46930         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
46931         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46932         this_ptr_conv.is_owned = false;
46933         int32_t ret_conv = NodeAnnouncementInfo_get_last_update(&this_ptr_conv);
46934         return ret_conv;
46935 }
46936
46937 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1last_1update(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
46938         LDKNodeAnnouncementInfo this_ptr_conv;
46939         this_ptr_conv.inner = untag_ptr(this_ptr);
46940         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
46941         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46942         this_ptr_conv.is_owned = false;
46943         NodeAnnouncementInfo_set_last_update(&this_ptr_conv, val);
46944 }
46945
46946 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1rgb(JNIEnv *env, jclass clz, int64_t this_ptr) {
46947         LDKNodeAnnouncementInfo this_ptr_conv;
46948         this_ptr_conv.inner = untag_ptr(this_ptr);
46949         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
46950         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46951         this_ptr_conv.is_owned = false;
46952         int8_tArray ret_arr = (*env)->NewByteArray(env, 3);
46953         (*env)->SetByteArrayRegion(env, ret_arr, 0, 3, *NodeAnnouncementInfo_get_rgb(&this_ptr_conv));
46954         return ret_arr;
46955 }
46956
46957 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1rgb(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
46958         LDKNodeAnnouncementInfo this_ptr_conv;
46959         this_ptr_conv.inner = untag_ptr(this_ptr);
46960         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
46961         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
46962         this_ptr_conv.is_owned = false;
46963         LDKThreeBytes val_ref;
46964         CHECK((*env)->GetArrayLength(env, val) == 3);
46965         (*env)->GetByteArrayRegion(env, val, 0, 3, val_ref.data);
46966         NodeAnnouncementInfo_set_rgb(&this_ptr_conv, val_ref);
46967 }
46968
46969 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1alias(JNIEnv *env, jclass clz, int64_t this_ptr) {
46970         LDKNodeAnnouncementInfo 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         LDKNodeAlias ret_var = NodeAnnouncementInfo_get_alias(&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_NodeAnnouncementInfo_1set_1alias(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
46983         LDKNodeAnnouncementInfo 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         LDKNodeAlias 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 = NodeAlias_clone(&val_conv);
46993         NodeAnnouncementInfo_set_alias(&this_ptr_conv, val_conv);
46994 }
46995
46996 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1addresses(JNIEnv *env, jclass clz, int64_t this_ptr) {
46997         LDKNodeAnnouncementInfo 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         LDKCVec_NetAddressZ ret_var = NodeAnnouncementInfo_get_addresses(&this_ptr_conv);
47003         int64_tArray ret_arr = NULL;
47004         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
47005         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
47006         for (size_t m = 0; m < ret_var.datalen; m++) {
47007                 LDKNetAddress *ret_conv_12_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
47008                 *ret_conv_12_copy = ret_var.data[m];
47009                 int64_t ret_conv_12_ref = tag_ptr(ret_conv_12_copy, true);
47010                 ret_arr_ptr[m] = ret_conv_12_ref;
47011         }
47012         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
47013         FREE(ret_var.data);
47014         return ret_arr;
47015 }
47016
47017 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1addresses(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
47018         LDKNodeAnnouncementInfo this_ptr_conv;
47019         this_ptr_conv.inner = untag_ptr(this_ptr);
47020         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47021         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47022         this_ptr_conv.is_owned = false;
47023         LDKCVec_NetAddressZ val_constr;
47024         val_constr.datalen = (*env)->GetArrayLength(env, val);
47025         if (val_constr.datalen > 0)
47026                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
47027         else
47028                 val_constr.data = NULL;
47029         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
47030         for (size_t m = 0; m < val_constr.datalen; m++) {
47031                 int64_t val_conv_12 = val_vals[m];
47032                 void* val_conv_12_ptr = untag_ptr(val_conv_12);
47033                 CHECK_ACCESS(val_conv_12_ptr);
47034                 LDKNetAddress val_conv_12_conv = *(LDKNetAddress*)(val_conv_12_ptr);
47035                 val_conv_12_conv = NetAddress_clone((LDKNetAddress*)untag_ptr(val_conv_12));
47036                 val_constr.data[m] = val_conv_12_conv;
47037         }
47038         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
47039         NodeAnnouncementInfo_set_addresses(&this_ptr_conv, val_constr);
47040 }
47041
47042 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1announcement_1message(JNIEnv *env, jclass clz, int64_t this_ptr) {
47043         LDKNodeAnnouncementInfo this_ptr_conv;
47044         this_ptr_conv.inner = untag_ptr(this_ptr);
47045         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47046         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47047         this_ptr_conv.is_owned = false;
47048         LDKNodeAnnouncement ret_var = NodeAnnouncementInfo_get_announcement_message(&this_ptr_conv);
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
47055 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1announcement_1message(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
47056         LDKNodeAnnouncementInfo this_ptr_conv;
47057         this_ptr_conv.inner = untag_ptr(this_ptr);
47058         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47059         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47060         this_ptr_conv.is_owned = false;
47061         LDKNodeAnnouncement val_conv;
47062         val_conv.inner = untag_ptr(val);
47063         val_conv.is_owned = ptr_is_owned(val);
47064         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
47065         val_conv = NodeAnnouncement_clone(&val_conv);
47066         NodeAnnouncementInfo_set_announcement_message(&this_ptr_conv, val_conv);
47067 }
47068
47069 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) {
47070         LDKNodeFeatures features_arg_conv;
47071         features_arg_conv.inner = untag_ptr(features_arg);
47072         features_arg_conv.is_owned = ptr_is_owned(features_arg);
47073         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_arg_conv);
47074         features_arg_conv = NodeFeatures_clone(&features_arg_conv);
47075         LDKThreeBytes rgb_arg_ref;
47076         CHECK((*env)->GetArrayLength(env, rgb_arg) == 3);
47077         (*env)->GetByteArrayRegion(env, rgb_arg, 0, 3, rgb_arg_ref.data);
47078         LDKNodeAlias alias_arg_conv;
47079         alias_arg_conv.inner = untag_ptr(alias_arg);
47080         alias_arg_conv.is_owned = ptr_is_owned(alias_arg);
47081         CHECK_INNER_FIELD_ACCESS_OR_NULL(alias_arg_conv);
47082         alias_arg_conv = NodeAlias_clone(&alias_arg_conv);
47083         LDKCVec_NetAddressZ addresses_arg_constr;
47084         addresses_arg_constr.datalen = (*env)->GetArrayLength(env, addresses_arg);
47085         if (addresses_arg_constr.datalen > 0)
47086                 addresses_arg_constr.data = MALLOC(addresses_arg_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
47087         else
47088                 addresses_arg_constr.data = NULL;
47089         int64_t* addresses_arg_vals = (*env)->GetLongArrayElements (env, addresses_arg, NULL);
47090         for (size_t m = 0; m < addresses_arg_constr.datalen; m++) {
47091                 int64_t addresses_arg_conv_12 = addresses_arg_vals[m];
47092                 void* addresses_arg_conv_12_ptr = untag_ptr(addresses_arg_conv_12);
47093                 CHECK_ACCESS(addresses_arg_conv_12_ptr);
47094                 LDKNetAddress addresses_arg_conv_12_conv = *(LDKNetAddress*)(addresses_arg_conv_12_ptr);
47095                 addresses_arg_constr.data[m] = addresses_arg_conv_12_conv;
47096         }
47097         (*env)->ReleaseLongArrayElements(env, addresses_arg, addresses_arg_vals, 0);
47098         LDKNodeAnnouncement announcement_message_arg_conv;
47099         announcement_message_arg_conv.inner = untag_ptr(announcement_message_arg);
47100         announcement_message_arg_conv.is_owned = ptr_is_owned(announcement_message_arg);
47101         CHECK_INNER_FIELD_ACCESS_OR_NULL(announcement_message_arg_conv);
47102         announcement_message_arg_conv = NodeAnnouncement_clone(&announcement_message_arg_conv);
47103         LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_new(features_arg_conv, last_update_arg, rgb_arg_ref, alias_arg_conv, addresses_arg_constr, announcement_message_arg_conv);
47104         int64_t ret_ref = 0;
47105         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47106         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
47107         return ret_ref;
47108 }
47109
47110 static inline uint64_t NodeAnnouncementInfo_clone_ptr(LDKNodeAnnouncementInfo *NONNULL_PTR arg) {
47111         LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_clone(arg);
47112         int64_t ret_ref = 0;
47113         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47114         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
47115         return ret_ref;
47116 }
47117 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
47118         LDKNodeAnnouncementInfo arg_conv;
47119         arg_conv.inner = untag_ptr(arg);
47120         arg_conv.is_owned = ptr_is_owned(arg);
47121         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
47122         arg_conv.is_owned = false;
47123         int64_t ret_conv = NodeAnnouncementInfo_clone_ptr(&arg_conv);
47124         return ret_conv;
47125 }
47126
47127 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
47128         LDKNodeAnnouncementInfo orig_conv;
47129         orig_conv.inner = untag_ptr(orig);
47130         orig_conv.is_owned = ptr_is_owned(orig);
47131         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
47132         orig_conv.is_owned = false;
47133         LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_clone(&orig_conv);
47134         int64_t ret_ref = 0;
47135         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47136         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
47137         return ret_ref;
47138 }
47139
47140 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
47141         LDKNodeAnnouncementInfo a_conv;
47142         a_conv.inner = untag_ptr(a);
47143         a_conv.is_owned = ptr_is_owned(a);
47144         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
47145         a_conv.is_owned = false;
47146         LDKNodeAnnouncementInfo b_conv;
47147         b_conv.inner = untag_ptr(b);
47148         b_conv.is_owned = ptr_is_owned(b);
47149         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
47150         b_conv.is_owned = false;
47151         jboolean ret_conv = NodeAnnouncementInfo_eq(&a_conv, &b_conv);
47152         return ret_conv;
47153 }
47154
47155 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1write(JNIEnv *env, jclass clz, int64_t obj) {
47156         LDKNodeAnnouncementInfo obj_conv;
47157         obj_conv.inner = untag_ptr(obj);
47158         obj_conv.is_owned = ptr_is_owned(obj);
47159         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
47160         obj_conv.is_owned = false;
47161         LDKCVec_u8Z ret_var = NodeAnnouncementInfo_write(&obj_conv);
47162         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
47163         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
47164         CVec_u8Z_free(ret_var);
47165         return ret_arr;
47166 }
47167
47168 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
47169         LDKu8slice ser_ref;
47170         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
47171         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
47172         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
47173         *ret_conv = NodeAnnouncementInfo_read(ser_ref);
47174         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
47175         return tag_ptr(ret_conv, true);
47176 }
47177
47178 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAlias_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
47179         LDKNodeAlias this_obj_conv;
47180         this_obj_conv.inner = untag_ptr(this_obj);
47181         this_obj_conv.is_owned = ptr_is_owned(this_obj);
47182         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
47183         NodeAlias_free(this_obj_conv);
47184 }
47185
47186 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAlias_1get_1a(JNIEnv *env, jclass clz, int64_t this_ptr) {
47187         LDKNodeAlias this_ptr_conv;
47188         this_ptr_conv.inner = untag_ptr(this_ptr);
47189         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47190         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47191         this_ptr_conv.is_owned = false;
47192         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
47193         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *NodeAlias_get_a(&this_ptr_conv));
47194         return ret_arr;
47195 }
47196
47197 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAlias_1set_1a(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
47198         LDKNodeAlias this_ptr_conv;
47199         this_ptr_conv.inner = untag_ptr(this_ptr);
47200         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47201         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47202         this_ptr_conv.is_owned = false;
47203         LDKThirtyTwoBytes val_ref;
47204         CHECK((*env)->GetArrayLength(env, val) == 32);
47205         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
47206         NodeAlias_set_a(&this_ptr_conv, val_ref);
47207 }
47208
47209 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAlias_1new(JNIEnv *env, jclass clz, int8_tArray a_arg) {
47210         LDKThirtyTwoBytes a_arg_ref;
47211         CHECK((*env)->GetArrayLength(env, a_arg) == 32);
47212         (*env)->GetByteArrayRegion(env, a_arg, 0, 32, a_arg_ref.data);
47213         LDKNodeAlias ret_var = NodeAlias_new(a_arg_ref);
47214         int64_t ret_ref = 0;
47215         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47216         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
47217         return ret_ref;
47218 }
47219
47220 static inline uint64_t NodeAlias_clone_ptr(LDKNodeAlias *NONNULL_PTR arg) {
47221         LDKNodeAlias ret_var = NodeAlias_clone(arg);
47222         int64_t ret_ref = 0;
47223         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47224         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
47225         return ret_ref;
47226 }
47227 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAlias_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
47228         LDKNodeAlias arg_conv;
47229         arg_conv.inner = untag_ptr(arg);
47230         arg_conv.is_owned = ptr_is_owned(arg);
47231         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
47232         arg_conv.is_owned = false;
47233         int64_t ret_conv = NodeAlias_clone_ptr(&arg_conv);
47234         return ret_conv;
47235 }
47236
47237 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAlias_1clone(JNIEnv *env, jclass clz, int64_t orig) {
47238         LDKNodeAlias orig_conv;
47239         orig_conv.inner = untag_ptr(orig);
47240         orig_conv.is_owned = ptr_is_owned(orig);
47241         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
47242         orig_conv.is_owned = false;
47243         LDKNodeAlias ret_var = NodeAlias_clone(&orig_conv);
47244         int64_t ret_ref = 0;
47245         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47246         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
47247         return ret_ref;
47248 }
47249
47250 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeAlias_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
47251         LDKNodeAlias a_conv;
47252         a_conv.inner = untag_ptr(a);
47253         a_conv.is_owned = ptr_is_owned(a);
47254         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
47255         a_conv.is_owned = false;
47256         LDKNodeAlias b_conv;
47257         b_conv.inner = untag_ptr(b);
47258         b_conv.is_owned = ptr_is_owned(b);
47259         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
47260         b_conv.is_owned = false;
47261         jboolean ret_conv = NodeAlias_eq(&a_conv, &b_conv);
47262         return ret_conv;
47263 }
47264
47265 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAlias_1write(JNIEnv *env, jclass clz, int64_t obj) {
47266         LDKNodeAlias obj_conv;
47267         obj_conv.inner = untag_ptr(obj);
47268         obj_conv.is_owned = ptr_is_owned(obj);
47269         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
47270         obj_conv.is_owned = false;
47271         LDKCVec_u8Z ret_var = NodeAlias_write(&obj_conv);
47272         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
47273         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
47274         CVec_u8Z_free(ret_var);
47275         return ret_arr;
47276 }
47277
47278 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAlias_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
47279         LDKu8slice ser_ref;
47280         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
47281         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
47282         LDKCResult_NodeAliasDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAliasDecodeErrorZ), "LDKCResult_NodeAliasDecodeErrorZ");
47283         *ret_conv = NodeAlias_read(ser_ref);
47284         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
47285         return tag_ptr(ret_conv, true);
47286 }
47287
47288 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
47289         LDKNodeInfo this_obj_conv;
47290         this_obj_conv.inner = untag_ptr(this_obj);
47291         this_obj_conv.is_owned = ptr_is_owned(this_obj);
47292         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
47293         NodeInfo_free(this_obj_conv);
47294 }
47295
47296 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_NodeInfo_1get_1channels(JNIEnv *env, jclass clz, int64_t this_ptr) {
47297         LDKNodeInfo this_ptr_conv;
47298         this_ptr_conv.inner = untag_ptr(this_ptr);
47299         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47300         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47301         this_ptr_conv.is_owned = false;
47302         LDKCVec_u64Z ret_var = NodeInfo_get_channels(&this_ptr_conv);
47303         int64_tArray ret_arr = NULL;
47304         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
47305         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
47306         for (size_t g = 0; g < ret_var.datalen; g++) {
47307                 int64_t ret_conv_6_conv = ret_var.data[g];
47308                 ret_arr_ptr[g] = ret_conv_6_conv;
47309         }
47310         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
47311         FREE(ret_var.data);
47312         return ret_arr;
47313 }
47314
47315 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeInfo_1set_1channels(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
47316         LDKNodeInfo this_ptr_conv;
47317         this_ptr_conv.inner = untag_ptr(this_ptr);
47318         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47319         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47320         this_ptr_conv.is_owned = false;
47321         LDKCVec_u64Z val_constr;
47322         val_constr.datalen = (*env)->GetArrayLength(env, val);
47323         if (val_constr.datalen > 0)
47324                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
47325         else
47326                 val_constr.data = NULL;
47327         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
47328         for (size_t g = 0; g < val_constr.datalen; g++) {
47329                 int64_t val_conv_6 = val_vals[g];
47330                 val_constr.data[g] = val_conv_6;
47331         }
47332         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
47333         NodeInfo_set_channels(&this_ptr_conv, val_constr);
47334 }
47335
47336 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1get_1lowest_1inbound_1channel_1fees(JNIEnv *env, jclass clz, int64_t this_ptr) {
47337         LDKNodeInfo this_ptr_conv;
47338         this_ptr_conv.inner = untag_ptr(this_ptr);
47339         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47340         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47341         this_ptr_conv.is_owned = false;
47342         LDKRoutingFees ret_var = NodeInfo_get_lowest_inbound_channel_fees(&this_ptr_conv);
47343         int64_t ret_ref = 0;
47344         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47345         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
47346         return ret_ref;
47347 }
47348
47349 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) {
47350         LDKNodeInfo this_ptr_conv;
47351         this_ptr_conv.inner = untag_ptr(this_ptr);
47352         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47353         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47354         this_ptr_conv.is_owned = false;
47355         LDKRoutingFees val_conv;
47356         val_conv.inner = untag_ptr(val);
47357         val_conv.is_owned = ptr_is_owned(val);
47358         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
47359         val_conv = RoutingFees_clone(&val_conv);
47360         NodeInfo_set_lowest_inbound_channel_fees(&this_ptr_conv, val_conv);
47361 }
47362
47363 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1get_1announcement_1info(JNIEnv *env, jclass clz, int64_t this_ptr) {
47364         LDKNodeInfo this_ptr_conv;
47365         this_ptr_conv.inner = untag_ptr(this_ptr);
47366         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47367         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47368         this_ptr_conv.is_owned = false;
47369         LDKNodeAnnouncementInfo ret_var = NodeInfo_get_announcement_info(&this_ptr_conv);
47370         int64_t ret_ref = 0;
47371         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47372         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
47373         return ret_ref;
47374 }
47375
47376 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeInfo_1set_1announcement_1info(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
47377         LDKNodeInfo this_ptr_conv;
47378         this_ptr_conv.inner = untag_ptr(this_ptr);
47379         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
47380         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
47381         this_ptr_conv.is_owned = false;
47382         LDKNodeAnnouncementInfo val_conv;
47383         val_conv.inner = untag_ptr(val);
47384         val_conv.is_owned = ptr_is_owned(val);
47385         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
47386         val_conv = NodeAnnouncementInfo_clone(&val_conv);
47387         NodeInfo_set_announcement_info(&this_ptr_conv, val_conv);
47388 }
47389
47390 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) {
47391         LDKCVec_u64Z channels_arg_constr;
47392         channels_arg_constr.datalen = (*env)->GetArrayLength(env, channels_arg);
47393         if (channels_arg_constr.datalen > 0)
47394                 channels_arg_constr.data = MALLOC(channels_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
47395         else
47396                 channels_arg_constr.data = NULL;
47397         int64_t* channels_arg_vals = (*env)->GetLongArrayElements (env, channels_arg, NULL);
47398         for (size_t g = 0; g < channels_arg_constr.datalen; g++) {
47399                 int64_t channels_arg_conv_6 = channels_arg_vals[g];
47400                 channels_arg_constr.data[g] = channels_arg_conv_6;
47401         }
47402         (*env)->ReleaseLongArrayElements(env, channels_arg, channels_arg_vals, 0);
47403         LDKRoutingFees lowest_inbound_channel_fees_arg_conv;
47404         lowest_inbound_channel_fees_arg_conv.inner = untag_ptr(lowest_inbound_channel_fees_arg);
47405         lowest_inbound_channel_fees_arg_conv.is_owned = ptr_is_owned(lowest_inbound_channel_fees_arg);
47406         CHECK_INNER_FIELD_ACCESS_OR_NULL(lowest_inbound_channel_fees_arg_conv);
47407         lowest_inbound_channel_fees_arg_conv = RoutingFees_clone(&lowest_inbound_channel_fees_arg_conv);
47408         LDKNodeAnnouncementInfo announcement_info_arg_conv;
47409         announcement_info_arg_conv.inner = untag_ptr(announcement_info_arg);
47410         announcement_info_arg_conv.is_owned = ptr_is_owned(announcement_info_arg);
47411         CHECK_INNER_FIELD_ACCESS_OR_NULL(announcement_info_arg_conv);
47412         announcement_info_arg_conv = NodeAnnouncementInfo_clone(&announcement_info_arg_conv);
47413         LDKNodeInfo ret_var = NodeInfo_new(channels_arg_constr, lowest_inbound_channel_fees_arg_conv, announcement_info_arg_conv);
47414         int64_t ret_ref = 0;
47415         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47416         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
47417         return ret_ref;
47418 }
47419
47420 static inline uint64_t NodeInfo_clone_ptr(LDKNodeInfo *NONNULL_PTR arg) {
47421         LDKNodeInfo ret_var = NodeInfo_clone(arg);
47422         int64_t ret_ref = 0;
47423         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47424         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
47425         return ret_ref;
47426 }
47427 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
47428         LDKNodeInfo arg_conv;
47429         arg_conv.inner = untag_ptr(arg);
47430         arg_conv.is_owned = ptr_is_owned(arg);
47431         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
47432         arg_conv.is_owned = false;
47433         int64_t ret_conv = NodeInfo_clone_ptr(&arg_conv);
47434         return ret_conv;
47435 }
47436
47437 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
47438         LDKNodeInfo orig_conv;
47439         orig_conv.inner = untag_ptr(orig);
47440         orig_conv.is_owned = ptr_is_owned(orig);
47441         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
47442         orig_conv.is_owned = false;
47443         LDKNodeInfo ret_var = NodeInfo_clone(&orig_conv);
47444         int64_t ret_ref = 0;
47445         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47446         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
47447         return ret_ref;
47448 }
47449
47450 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeInfo_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
47451         LDKNodeInfo a_conv;
47452         a_conv.inner = untag_ptr(a);
47453         a_conv.is_owned = ptr_is_owned(a);
47454         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
47455         a_conv.is_owned = false;
47456         LDKNodeInfo b_conv;
47457         b_conv.inner = untag_ptr(b);
47458         b_conv.is_owned = ptr_is_owned(b);
47459         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
47460         b_conv.is_owned = false;
47461         jboolean ret_conv = NodeInfo_eq(&a_conv, &b_conv);
47462         return ret_conv;
47463 }
47464
47465 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeInfo_1write(JNIEnv *env, jclass clz, int64_t obj) {
47466         LDKNodeInfo obj_conv;
47467         obj_conv.inner = untag_ptr(obj);
47468         obj_conv.is_owned = ptr_is_owned(obj);
47469         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
47470         obj_conv.is_owned = false;
47471         LDKCVec_u8Z ret_var = NodeInfo_write(&obj_conv);
47472         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
47473         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
47474         CVec_u8Z_free(ret_var);
47475         return ret_arr;
47476 }
47477
47478 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
47479         LDKu8slice ser_ref;
47480         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
47481         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
47482         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
47483         *ret_conv = NodeInfo_read(ser_ref);
47484         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
47485         return tag_ptr(ret_conv, true);
47486 }
47487
47488 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1write(JNIEnv *env, jclass clz, int64_t obj) {
47489         LDKNetworkGraph obj_conv;
47490         obj_conv.inner = untag_ptr(obj);
47491         obj_conv.is_owned = ptr_is_owned(obj);
47492         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
47493         obj_conv.is_owned = false;
47494         LDKCVec_u8Z ret_var = NetworkGraph_write(&obj_conv);
47495         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
47496         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
47497         CVec_u8Z_free(ret_var);
47498         return ret_arr;
47499 }
47500
47501 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1read(JNIEnv *env, jclass clz, int8_tArray ser, int64_t arg) {
47502         LDKu8slice ser_ref;
47503         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
47504         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
47505         void* arg_ptr = untag_ptr(arg);
47506         CHECK_ACCESS(arg_ptr);
47507         LDKLogger arg_conv = *(LDKLogger*)(arg_ptr);
47508         if (arg_conv.free == LDKLogger_JCalls_free) {
47509                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
47510                 LDKLogger_JCalls_cloned(&arg_conv);
47511         }
47512         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
47513         *ret_conv = NetworkGraph_read(ser_ref, arg_conv);
47514         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
47515         return tag_ptr(ret_conv, true);
47516 }
47517
47518 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1new(JNIEnv *env, jclass clz, int8_tArray genesis_hash, int64_t logger) {
47519         LDKThirtyTwoBytes genesis_hash_ref;
47520         CHECK((*env)->GetArrayLength(env, genesis_hash) == 32);
47521         (*env)->GetByteArrayRegion(env, genesis_hash, 0, 32, genesis_hash_ref.data);
47522         void* logger_ptr = untag_ptr(logger);
47523         CHECK_ACCESS(logger_ptr);
47524         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
47525         if (logger_conv.free == LDKLogger_JCalls_free) {
47526                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
47527                 LDKLogger_JCalls_cloned(&logger_conv);
47528         }
47529         LDKNetworkGraph ret_var = NetworkGraph_new(genesis_hash_ref, logger_conv);
47530         int64_t ret_ref = 0;
47531         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47532         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
47533         return ret_ref;
47534 }
47535
47536 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1read_1only(JNIEnv *env, jclass clz, int64_t this_arg) {
47537         LDKNetworkGraph this_arg_conv;
47538         this_arg_conv.inner = untag_ptr(this_arg);
47539         this_arg_conv.is_owned = ptr_is_owned(this_arg);
47540         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47541         this_arg_conv.is_owned = false;
47542         LDKReadOnlyNetworkGraph ret_var = NetworkGraph_read_only(&this_arg_conv);
47543         int64_t ret_ref = 0;
47544         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47545         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
47546         return ret_ref;
47547 }
47548
47549 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1get_1last_1rapid_1gossip_1sync_1timestamp(JNIEnv *env, jclass clz, int64_t this_arg) {
47550         LDKNetworkGraph this_arg_conv;
47551         this_arg_conv.inner = untag_ptr(this_arg);
47552         this_arg_conv.is_owned = ptr_is_owned(this_arg);
47553         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47554         this_arg_conv.is_owned = false;
47555         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
47556         *ret_copy = NetworkGraph_get_last_rapid_gossip_sync_timestamp(&this_arg_conv);
47557         int64_t ret_ref = tag_ptr(ret_copy, true);
47558         return ret_ref;
47559 }
47560
47561 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) {
47562         LDKNetworkGraph this_arg_conv;
47563         this_arg_conv.inner = untag_ptr(this_arg);
47564         this_arg_conv.is_owned = ptr_is_owned(this_arg);
47565         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47566         this_arg_conv.is_owned = false;
47567         NetworkGraph_set_last_rapid_gossip_sync_timestamp(&this_arg_conv, last_rapid_gossip_sync_timestamp);
47568 }
47569
47570 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) {
47571         LDKNetworkGraph this_arg_conv;
47572         this_arg_conv.inner = untag_ptr(this_arg);
47573         this_arg_conv.is_owned = ptr_is_owned(this_arg);
47574         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47575         this_arg_conv.is_owned = false;
47576         LDKNodeAnnouncement msg_conv;
47577         msg_conv.inner = untag_ptr(msg);
47578         msg_conv.is_owned = ptr_is_owned(msg);
47579         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
47580         msg_conv.is_owned = false;
47581         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
47582         *ret_conv = NetworkGraph_update_node_from_announcement(&this_arg_conv, &msg_conv);
47583         return tag_ptr(ret_conv, true);
47584 }
47585
47586 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) {
47587         LDKNetworkGraph this_arg_conv;
47588         this_arg_conv.inner = untag_ptr(this_arg);
47589         this_arg_conv.is_owned = ptr_is_owned(this_arg);
47590         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47591         this_arg_conv.is_owned = false;
47592         LDKUnsignedNodeAnnouncement msg_conv;
47593         msg_conv.inner = untag_ptr(msg);
47594         msg_conv.is_owned = ptr_is_owned(msg);
47595         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
47596         msg_conv.is_owned = false;
47597         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
47598         *ret_conv = NetworkGraph_update_node_from_unsigned_announcement(&this_arg_conv, &msg_conv);
47599         return tag_ptr(ret_conv, true);
47600 }
47601
47602 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) {
47603         LDKNetworkGraph this_arg_conv;
47604         this_arg_conv.inner = untag_ptr(this_arg);
47605         this_arg_conv.is_owned = ptr_is_owned(this_arg);
47606         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47607         this_arg_conv.is_owned = false;
47608         LDKChannelAnnouncement msg_conv;
47609         msg_conv.inner = untag_ptr(msg);
47610         msg_conv.is_owned = ptr_is_owned(msg);
47611         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
47612         msg_conv.is_owned = false;
47613         void* chain_access_ptr = untag_ptr(chain_access);
47614         CHECK_ACCESS(chain_access_ptr);
47615         LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(chain_access_ptr);
47616         // WARNING: we may need a move here but no clone is available for LDKCOption_AccessZ
47617         if (chain_access_conv.tag == LDKCOption_AccessZ_Some) {
47618                 // Manually implement clone for Java trait instances
47619                 if (chain_access_conv.some.free == LDKAccess_JCalls_free) {
47620                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
47621                         LDKAccess_JCalls_cloned(&chain_access_conv.some);
47622                 }
47623         }
47624         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
47625         *ret_conv = NetworkGraph_update_channel_from_announcement(&this_arg_conv, &msg_conv, chain_access_conv);
47626         return tag_ptr(ret_conv, true);
47627 }
47628
47629 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) {
47630         LDKNetworkGraph this_arg_conv;
47631         this_arg_conv.inner = untag_ptr(this_arg);
47632         this_arg_conv.is_owned = ptr_is_owned(this_arg);
47633         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47634         this_arg_conv.is_owned = false;
47635         LDKUnsignedChannelAnnouncement msg_conv;
47636         msg_conv.inner = untag_ptr(msg);
47637         msg_conv.is_owned = ptr_is_owned(msg);
47638         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
47639         msg_conv.is_owned = false;
47640         void* chain_access_ptr = untag_ptr(chain_access);
47641         CHECK_ACCESS(chain_access_ptr);
47642         LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(chain_access_ptr);
47643         // WARNING: we may need a move here but no clone is available for LDKCOption_AccessZ
47644         if (chain_access_conv.tag == LDKCOption_AccessZ_Some) {
47645                 // Manually implement clone for Java trait instances
47646                 if (chain_access_conv.some.free == LDKAccess_JCalls_free) {
47647                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
47648                         LDKAccess_JCalls_cloned(&chain_access_conv.some);
47649                 }
47650         }
47651         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
47652         *ret_conv = NetworkGraph_update_channel_from_unsigned_announcement(&this_arg_conv, &msg_conv, chain_access_conv);
47653         return tag_ptr(ret_conv, true);
47654 }
47655
47656 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) {
47657         LDKNetworkGraph this_arg_conv;
47658         this_arg_conv.inner = untag_ptr(this_arg);
47659         this_arg_conv.is_owned = ptr_is_owned(this_arg);
47660         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47661         this_arg_conv.is_owned = false;
47662         LDKChannelFeatures features_conv;
47663         features_conv.inner = untag_ptr(features);
47664         features_conv.is_owned = ptr_is_owned(features);
47665         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_conv);
47666         features_conv = ChannelFeatures_clone(&features_conv);
47667         LDKPublicKey node_id_1_ref;
47668         CHECK((*env)->GetArrayLength(env, node_id_1) == 33);
47669         (*env)->GetByteArrayRegion(env, node_id_1, 0, 33, node_id_1_ref.compressed_form);
47670         LDKPublicKey node_id_2_ref;
47671         CHECK((*env)->GetArrayLength(env, node_id_2) == 33);
47672         (*env)->GetByteArrayRegion(env, node_id_2, 0, 33, node_id_2_ref.compressed_form);
47673         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
47674         *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);
47675         return tag_ptr(ret_conv, true);
47676 }
47677
47678 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) {
47679         LDKNetworkGraph this_arg_conv;
47680         this_arg_conv.inner = untag_ptr(this_arg);
47681         this_arg_conv.is_owned = ptr_is_owned(this_arg);
47682         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47683         this_arg_conv.is_owned = false;
47684         NetworkGraph_channel_failed(&this_arg_conv, short_channel_id, is_permanent);
47685 }
47686
47687 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1node_1failed_1permanent(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray node_id) {
47688         LDKNetworkGraph this_arg_conv;
47689         this_arg_conv.inner = untag_ptr(this_arg);
47690         this_arg_conv.is_owned = ptr_is_owned(this_arg);
47691         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47692         this_arg_conv.is_owned = false;
47693         LDKPublicKey node_id_ref;
47694         CHECK((*env)->GetArrayLength(env, node_id) == 33);
47695         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
47696         NetworkGraph_node_failed_permanent(&this_arg_conv, node_id_ref);
47697 }
47698
47699 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1remove_1stale_1channels_1and_1tracking(JNIEnv *env, jclass clz, int64_t this_arg) {
47700         LDKNetworkGraph this_arg_conv;
47701         this_arg_conv.inner = untag_ptr(this_arg);
47702         this_arg_conv.is_owned = ptr_is_owned(this_arg);
47703         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47704         this_arg_conv.is_owned = false;
47705         NetworkGraph_remove_stale_channels_and_tracking(&this_arg_conv);
47706 }
47707
47708 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) {
47709         LDKNetworkGraph this_arg_conv;
47710         this_arg_conv.inner = untag_ptr(this_arg);
47711         this_arg_conv.is_owned = ptr_is_owned(this_arg);
47712         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47713         this_arg_conv.is_owned = false;
47714         NetworkGraph_remove_stale_channels_and_tracking_with_time(&this_arg_conv, current_time_unix);
47715 }
47716
47717 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1update_1channel(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
47718         LDKNetworkGraph this_arg_conv;
47719         this_arg_conv.inner = untag_ptr(this_arg);
47720         this_arg_conv.is_owned = ptr_is_owned(this_arg);
47721         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47722         this_arg_conv.is_owned = false;
47723         LDKChannelUpdate msg_conv;
47724         msg_conv.inner = untag_ptr(msg);
47725         msg_conv.is_owned = ptr_is_owned(msg);
47726         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
47727         msg_conv.is_owned = false;
47728         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
47729         *ret_conv = NetworkGraph_update_channel(&this_arg_conv, &msg_conv);
47730         return tag_ptr(ret_conv, true);
47731 }
47732
47733 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1update_1channel_1unsigned(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
47734         LDKNetworkGraph this_arg_conv;
47735         this_arg_conv.inner = untag_ptr(this_arg);
47736         this_arg_conv.is_owned = ptr_is_owned(this_arg);
47737         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47738         this_arg_conv.is_owned = false;
47739         LDKUnsignedChannelUpdate msg_conv;
47740         msg_conv.inner = untag_ptr(msg);
47741         msg_conv.is_owned = ptr_is_owned(msg);
47742         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
47743         msg_conv.is_owned = false;
47744         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
47745         *ret_conv = NetworkGraph_update_channel_unsigned(&this_arg_conv, &msg_conv);
47746         return tag_ptr(ret_conv, true);
47747 }
47748
47749 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReadOnlyNetworkGraph_1channel(JNIEnv *env, jclass clz, int64_t this_arg, int64_t short_channel_id) {
47750         LDKReadOnlyNetworkGraph this_arg_conv;
47751         this_arg_conv.inner = untag_ptr(this_arg);
47752         this_arg_conv.is_owned = ptr_is_owned(this_arg);
47753         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47754         this_arg_conv.is_owned = false;
47755         LDKChannelInfo ret_var = ReadOnlyNetworkGraph_channel(&this_arg_conv, short_channel_id);
47756         int64_t ret_ref = 0;
47757         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47758         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
47759         return ret_ref;
47760 }
47761
47762 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ReadOnlyNetworkGraph_1list_1channels(JNIEnv *env, jclass clz, int64_t this_arg) {
47763         LDKReadOnlyNetworkGraph this_arg_conv;
47764         this_arg_conv.inner = untag_ptr(this_arg);
47765         this_arg_conv.is_owned = ptr_is_owned(this_arg);
47766         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47767         this_arg_conv.is_owned = false;
47768         LDKCVec_u64Z ret_var = ReadOnlyNetworkGraph_list_channels(&this_arg_conv);
47769         int64_tArray ret_arr = NULL;
47770         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
47771         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
47772         for (size_t g = 0; g < ret_var.datalen; g++) {
47773                 int64_t ret_conv_6_conv = ret_var.data[g];
47774                 ret_arr_ptr[g] = ret_conv_6_conv;
47775         }
47776         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
47777         FREE(ret_var.data);
47778         return ret_arr;
47779 }
47780
47781 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReadOnlyNetworkGraph_1node(JNIEnv *env, jclass clz, int64_t this_arg, int64_t node_id) {
47782         LDKReadOnlyNetworkGraph this_arg_conv;
47783         this_arg_conv.inner = untag_ptr(this_arg);
47784         this_arg_conv.is_owned = ptr_is_owned(this_arg);
47785         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47786         this_arg_conv.is_owned = false;
47787         LDKNodeId node_id_conv;
47788         node_id_conv.inner = untag_ptr(node_id);
47789         node_id_conv.is_owned = ptr_is_owned(node_id);
47790         CHECK_INNER_FIELD_ACCESS_OR_NULL(node_id_conv);
47791         node_id_conv.is_owned = false;
47792         LDKNodeInfo ret_var = ReadOnlyNetworkGraph_node(&this_arg_conv, &node_id_conv);
47793         int64_t ret_ref = 0;
47794         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47795         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
47796         return ret_ref;
47797 }
47798
47799 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ReadOnlyNetworkGraph_1list_1nodes(JNIEnv *env, jclass clz, int64_t this_arg) {
47800         LDKReadOnlyNetworkGraph this_arg_conv;
47801         this_arg_conv.inner = untag_ptr(this_arg);
47802         this_arg_conv.is_owned = ptr_is_owned(this_arg);
47803         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47804         this_arg_conv.is_owned = false;
47805         LDKCVec_NodeIdZ ret_var = ReadOnlyNetworkGraph_list_nodes(&this_arg_conv);
47806         int64_tArray ret_arr = NULL;
47807         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
47808         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
47809         for (size_t i = 0; i < ret_var.datalen; i++) {
47810                 LDKNodeId ret_conv_8_var = ret_var.data[i];
47811                 int64_t ret_conv_8_ref = 0;
47812                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_8_var);
47813                 ret_conv_8_ref = tag_ptr(ret_conv_8_var.inner, ret_conv_8_var.is_owned);
47814                 ret_arr_ptr[i] = ret_conv_8_ref;
47815         }
47816         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
47817         FREE(ret_var.data);
47818         return ret_arr;
47819 }
47820
47821 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReadOnlyNetworkGraph_1get_1addresses(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray pubkey) {
47822         LDKReadOnlyNetworkGraph this_arg_conv;
47823         this_arg_conv.inner = untag_ptr(this_arg);
47824         this_arg_conv.is_owned = ptr_is_owned(this_arg);
47825         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47826         this_arg_conv.is_owned = false;
47827         LDKPublicKey pubkey_ref;
47828         CHECK((*env)->GetArrayLength(env, pubkey) == 33);
47829         (*env)->GetByteArrayRegion(env, pubkey, 0, 33, pubkey_ref.compressed_form);
47830         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
47831         *ret_copy = ReadOnlyNetworkGraph_get_addresses(&this_arg_conv, pubkey_ref);
47832         int64_t ret_ref = tag_ptr(ret_copy, true);
47833         return ret_ref;
47834 }
47835
47836 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DefaultRouter_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
47837         LDKDefaultRouter this_obj_conv;
47838         this_obj_conv.inner = untag_ptr(this_obj);
47839         this_obj_conv.is_owned = ptr_is_owned(this_obj);
47840         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
47841         DefaultRouter_free(this_obj_conv);
47842 }
47843
47844 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) {
47845         LDKNetworkGraph network_graph_conv;
47846         network_graph_conv.inner = untag_ptr(network_graph);
47847         network_graph_conv.is_owned = ptr_is_owned(network_graph);
47848         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
47849         network_graph_conv.is_owned = false;
47850         void* logger_ptr = untag_ptr(logger);
47851         CHECK_ACCESS(logger_ptr);
47852         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
47853         if (logger_conv.free == LDKLogger_JCalls_free) {
47854                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
47855                 LDKLogger_JCalls_cloned(&logger_conv);
47856         }
47857         LDKThirtyTwoBytes random_seed_bytes_ref;
47858         CHECK((*env)->GetArrayLength(env, random_seed_bytes) == 32);
47859         (*env)->GetByteArrayRegion(env, random_seed_bytes, 0, 32, random_seed_bytes_ref.data);
47860         void* scorer_ptr = untag_ptr(scorer);
47861         CHECK_ACCESS(scorer_ptr);
47862         LDKLockableScore scorer_conv = *(LDKLockableScore*)(scorer_ptr);
47863         if (scorer_conv.free == LDKLockableScore_JCalls_free) {
47864                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
47865                 LDKLockableScore_JCalls_cloned(&scorer_conv);
47866         }
47867         LDKDefaultRouter ret_var = DefaultRouter_new(&network_graph_conv, logger_conv, random_seed_bytes_ref, scorer_conv);
47868         int64_t ret_ref = 0;
47869         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47870         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
47871         return ret_ref;
47872 }
47873
47874 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DefaultRouter_1as_1Router(JNIEnv *env, jclass clz, int64_t this_arg) {
47875         LDKDefaultRouter this_arg_conv;
47876         this_arg_conv.inner = untag_ptr(this_arg);
47877         this_arg_conv.is_owned = ptr_is_owned(this_arg);
47878         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47879         this_arg_conv.is_owned = false;
47880         LDKRouter* ret_ret = MALLOC(sizeof(LDKRouter), "LDKRouter");
47881         *ret_ret = DefaultRouter_as_Router(&this_arg_conv);
47882         return tag_ptr(ret_ret, true);
47883 }
47884
47885 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Router_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
47886         if (!ptr_is_owned(this_ptr)) return;
47887         void* this_ptr_ptr = untag_ptr(this_ptr);
47888         CHECK_ACCESS(this_ptr_ptr);
47889         LDKRouter this_ptr_conv = *(LDKRouter*)(this_ptr_ptr);
47890         FREE(untag_ptr(this_ptr));
47891         Router_free(this_ptr_conv);
47892 }
47893
47894 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ScorerAccountingForInFlightHtlcs_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
47895         LDKScorerAccountingForInFlightHtlcs this_obj_conv;
47896         this_obj_conv.inner = untag_ptr(this_obj);
47897         this_obj_conv.is_owned = ptr_is_owned(this_obj);
47898         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
47899         ScorerAccountingForInFlightHtlcs_free(this_obj_conv);
47900 }
47901
47902 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ScorerAccountingForInFlightHtlcs_1new(JNIEnv *env, jclass clz, int64_t scorer, int64_t inflight_htlcs) {
47903         void* scorer_ptr = untag_ptr(scorer);
47904         CHECK_ACCESS(scorer_ptr);
47905         LDKScore scorer_conv = *(LDKScore*)(scorer_ptr);
47906         if (scorer_conv.free == LDKScore_JCalls_free) {
47907                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
47908                 LDKScore_JCalls_cloned(&scorer_conv);
47909         }
47910         LDKInFlightHtlcs inflight_htlcs_conv;
47911         inflight_htlcs_conv.inner = untag_ptr(inflight_htlcs);
47912         inflight_htlcs_conv.is_owned = ptr_is_owned(inflight_htlcs);
47913         CHECK_INNER_FIELD_ACCESS_OR_NULL(inflight_htlcs_conv);
47914         inflight_htlcs_conv = InFlightHtlcs_clone(&inflight_htlcs_conv);
47915         LDKScorerAccountingForInFlightHtlcs ret_var = ScorerAccountingForInFlightHtlcs_new(scorer_conv, inflight_htlcs_conv);
47916         int64_t ret_ref = 0;
47917         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47918         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
47919         return ret_ref;
47920 }
47921
47922 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ScorerAccountingForInFlightHtlcs_1write(JNIEnv *env, jclass clz, int64_t obj) {
47923         LDKScorerAccountingForInFlightHtlcs obj_conv;
47924         obj_conv.inner = untag_ptr(obj);
47925         obj_conv.is_owned = ptr_is_owned(obj);
47926         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
47927         obj_conv.is_owned = false;
47928         LDKCVec_u8Z ret_var = ScorerAccountingForInFlightHtlcs_write(&obj_conv);
47929         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
47930         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
47931         CVec_u8Z_free(ret_var);
47932         return ret_arr;
47933 }
47934
47935 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ScorerAccountingForInFlightHtlcs_1as_1Score(JNIEnv *env, jclass clz, int64_t this_arg) {
47936         LDKScorerAccountingForInFlightHtlcs this_arg_conv;
47937         this_arg_conv.inner = untag_ptr(this_arg);
47938         this_arg_conv.is_owned = ptr_is_owned(this_arg);
47939         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47940         this_arg_conv.is_owned = false;
47941         LDKScore* ret_ret = MALLOC(sizeof(LDKScore), "LDKScore");
47942         *ret_ret = ScorerAccountingForInFlightHtlcs_as_Score(&this_arg_conv);
47943         return tag_ptr(ret_ret, true);
47944 }
47945
47946 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InFlightHtlcs_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
47947         LDKInFlightHtlcs this_obj_conv;
47948         this_obj_conv.inner = untag_ptr(this_obj);
47949         this_obj_conv.is_owned = ptr_is_owned(this_obj);
47950         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
47951         InFlightHtlcs_free(this_obj_conv);
47952 }
47953
47954 static inline uint64_t InFlightHtlcs_clone_ptr(LDKInFlightHtlcs *NONNULL_PTR arg) {
47955         LDKInFlightHtlcs ret_var = InFlightHtlcs_clone(arg);
47956         int64_t ret_ref = 0;
47957         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47958         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
47959         return ret_ref;
47960 }
47961 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InFlightHtlcs_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
47962         LDKInFlightHtlcs arg_conv;
47963         arg_conv.inner = untag_ptr(arg);
47964         arg_conv.is_owned = ptr_is_owned(arg);
47965         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
47966         arg_conv.is_owned = false;
47967         int64_t ret_conv = InFlightHtlcs_clone_ptr(&arg_conv);
47968         return ret_conv;
47969 }
47970
47971 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InFlightHtlcs_1clone(JNIEnv *env, jclass clz, int64_t orig) {
47972         LDKInFlightHtlcs orig_conv;
47973         orig_conv.inner = untag_ptr(orig);
47974         orig_conv.is_owned = ptr_is_owned(orig);
47975         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
47976         orig_conv.is_owned = false;
47977         LDKInFlightHtlcs ret_var = InFlightHtlcs_clone(&orig_conv);
47978         int64_t ret_ref = 0;
47979         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47980         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
47981         return ret_ref;
47982 }
47983
47984 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InFlightHtlcs_1new(JNIEnv *env, jclass clz) {
47985         LDKInFlightHtlcs ret_var = InFlightHtlcs_new();
47986         int64_t ret_ref = 0;
47987         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
47988         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
47989         return ret_ref;
47990 }
47991
47992 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) {
47993         LDKInFlightHtlcs this_arg_conv;
47994         this_arg_conv.inner = untag_ptr(this_arg);
47995         this_arg_conv.is_owned = ptr_is_owned(this_arg);
47996         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
47997         this_arg_conv.is_owned = false;
47998         LDKNodeId source_conv;
47999         source_conv.inner = untag_ptr(source);
48000         source_conv.is_owned = ptr_is_owned(source);
48001         CHECK_INNER_FIELD_ACCESS_OR_NULL(source_conv);
48002         source_conv.is_owned = false;
48003         LDKNodeId target_conv;
48004         target_conv.inner = untag_ptr(target);
48005         target_conv.is_owned = ptr_is_owned(target);
48006         CHECK_INNER_FIELD_ACCESS_OR_NULL(target_conv);
48007         target_conv.is_owned = false;
48008         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
48009         *ret_copy = InFlightHtlcs_used_liquidity_msat(&this_arg_conv, &source_conv, &target_conv, channel_scid);
48010         int64_t ret_ref = tag_ptr(ret_copy, true);
48011         return ret_ref;
48012 }
48013
48014 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InFlightHtlcs_1write(JNIEnv *env, jclass clz, int64_t obj) {
48015         LDKInFlightHtlcs obj_conv;
48016         obj_conv.inner = untag_ptr(obj);
48017         obj_conv.is_owned = ptr_is_owned(obj);
48018         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
48019         obj_conv.is_owned = false;
48020         LDKCVec_u8Z ret_var = InFlightHtlcs_write(&obj_conv);
48021         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
48022         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
48023         CVec_u8Z_free(ret_var);
48024         return ret_arr;
48025 }
48026
48027 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InFlightHtlcs_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
48028         LDKu8slice ser_ref;
48029         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
48030         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
48031         LDKCResult_InFlightHtlcsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InFlightHtlcsDecodeErrorZ), "LDKCResult_InFlightHtlcsDecodeErrorZ");
48032         *ret_conv = InFlightHtlcs_read(ser_ref);
48033         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
48034         return tag_ptr(ret_conv, true);
48035 }
48036
48037 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
48038         LDKRouteHop this_obj_conv;
48039         this_obj_conv.inner = untag_ptr(this_obj);
48040         this_obj_conv.is_owned = ptr_is_owned(this_obj);
48041         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
48042         RouteHop_free(this_obj_conv);
48043 }
48044
48045 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
48046         LDKRouteHop this_ptr_conv;
48047         this_ptr_conv.inner = untag_ptr(this_ptr);
48048         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48049         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48050         this_ptr_conv.is_owned = false;
48051         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
48052         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, RouteHop_get_pubkey(&this_ptr_conv).compressed_form);
48053         return ret_arr;
48054 }
48055
48056 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
48057         LDKRouteHop this_ptr_conv;
48058         this_ptr_conv.inner = untag_ptr(this_ptr);
48059         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48060         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48061         this_ptr_conv.is_owned = false;
48062         LDKPublicKey val_ref;
48063         CHECK((*env)->GetArrayLength(env, val) == 33);
48064         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
48065         RouteHop_set_pubkey(&this_ptr_conv, val_ref);
48066 }
48067
48068 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1node_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
48069         LDKRouteHop this_ptr_conv;
48070         this_ptr_conv.inner = untag_ptr(this_ptr);
48071         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48072         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48073         this_ptr_conv.is_owned = false;
48074         LDKNodeFeatures ret_var = RouteHop_get_node_features(&this_ptr_conv);
48075         int64_t ret_ref = 0;
48076         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48077         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48078         return ret_ref;
48079 }
48080
48081 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1node_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
48082         LDKRouteHop this_ptr_conv;
48083         this_ptr_conv.inner = untag_ptr(this_ptr);
48084         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48085         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48086         this_ptr_conv.is_owned = false;
48087         LDKNodeFeatures val_conv;
48088         val_conv.inner = untag_ptr(val);
48089         val_conv.is_owned = ptr_is_owned(val);
48090         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
48091         val_conv = NodeFeatures_clone(&val_conv);
48092         RouteHop_set_node_features(&this_ptr_conv, val_conv);
48093 }
48094
48095 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
48096         LDKRouteHop this_ptr_conv;
48097         this_ptr_conv.inner = untag_ptr(this_ptr);
48098         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48099         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48100         this_ptr_conv.is_owned = false;
48101         int64_t ret_conv = RouteHop_get_short_channel_id(&this_ptr_conv);
48102         return ret_conv;
48103 }
48104
48105 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
48106         LDKRouteHop this_ptr_conv;
48107         this_ptr_conv.inner = untag_ptr(this_ptr);
48108         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48109         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48110         this_ptr_conv.is_owned = false;
48111         RouteHop_set_short_channel_id(&this_ptr_conv, val);
48112 }
48113
48114 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1channel_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
48115         LDKRouteHop this_ptr_conv;
48116         this_ptr_conv.inner = untag_ptr(this_ptr);
48117         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48118         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48119         this_ptr_conv.is_owned = false;
48120         LDKChannelFeatures ret_var = RouteHop_get_channel_features(&this_ptr_conv);
48121         int64_t ret_ref = 0;
48122         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48123         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48124         return ret_ref;
48125 }
48126
48127 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1channel_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
48128         LDKRouteHop this_ptr_conv;
48129         this_ptr_conv.inner = untag_ptr(this_ptr);
48130         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48131         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48132         this_ptr_conv.is_owned = false;
48133         LDKChannelFeatures val_conv;
48134         val_conv.inner = untag_ptr(val);
48135         val_conv.is_owned = ptr_is_owned(val);
48136         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
48137         val_conv = ChannelFeatures_clone(&val_conv);
48138         RouteHop_set_channel_features(&this_ptr_conv, val_conv);
48139 }
48140
48141 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1fee_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
48142         LDKRouteHop this_ptr_conv;
48143         this_ptr_conv.inner = untag_ptr(this_ptr);
48144         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48145         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48146         this_ptr_conv.is_owned = false;
48147         int64_t ret_conv = RouteHop_get_fee_msat(&this_ptr_conv);
48148         return ret_conv;
48149 }
48150
48151 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1fee_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
48152         LDKRouteHop this_ptr_conv;
48153         this_ptr_conv.inner = untag_ptr(this_ptr);
48154         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48155         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48156         this_ptr_conv.is_owned = false;
48157         RouteHop_set_fee_msat(&this_ptr_conv, val);
48158 }
48159
48160 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
48161         LDKRouteHop this_ptr_conv;
48162         this_ptr_conv.inner = untag_ptr(this_ptr);
48163         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48164         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48165         this_ptr_conv.is_owned = false;
48166         int32_t ret_conv = RouteHop_get_cltv_expiry_delta(&this_ptr_conv);
48167         return ret_conv;
48168 }
48169
48170 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
48171         LDKRouteHop this_ptr_conv;
48172         this_ptr_conv.inner = untag_ptr(this_ptr);
48173         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48174         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48175         this_ptr_conv.is_owned = false;
48176         RouteHop_set_cltv_expiry_delta(&this_ptr_conv, val);
48177 }
48178
48179 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) {
48180         LDKPublicKey pubkey_arg_ref;
48181         CHECK((*env)->GetArrayLength(env, pubkey_arg) == 33);
48182         (*env)->GetByteArrayRegion(env, pubkey_arg, 0, 33, pubkey_arg_ref.compressed_form);
48183         LDKNodeFeatures node_features_arg_conv;
48184         node_features_arg_conv.inner = untag_ptr(node_features_arg);
48185         node_features_arg_conv.is_owned = ptr_is_owned(node_features_arg);
48186         CHECK_INNER_FIELD_ACCESS_OR_NULL(node_features_arg_conv);
48187         node_features_arg_conv = NodeFeatures_clone(&node_features_arg_conv);
48188         LDKChannelFeatures channel_features_arg_conv;
48189         channel_features_arg_conv.inner = untag_ptr(channel_features_arg);
48190         channel_features_arg_conv.is_owned = ptr_is_owned(channel_features_arg);
48191         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_features_arg_conv);
48192         channel_features_arg_conv = ChannelFeatures_clone(&channel_features_arg_conv);
48193         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);
48194         int64_t ret_ref = 0;
48195         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48196         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48197         return ret_ref;
48198 }
48199
48200 static inline uint64_t RouteHop_clone_ptr(LDKRouteHop *NONNULL_PTR arg) {
48201         LDKRouteHop ret_var = RouteHop_clone(arg);
48202         int64_t ret_ref = 0;
48203         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48204         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48205         return ret_ref;
48206 }
48207 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
48208         LDKRouteHop arg_conv;
48209         arg_conv.inner = untag_ptr(arg);
48210         arg_conv.is_owned = ptr_is_owned(arg);
48211         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
48212         arg_conv.is_owned = false;
48213         int64_t ret_conv = RouteHop_clone_ptr(&arg_conv);
48214         return ret_conv;
48215 }
48216
48217 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1clone(JNIEnv *env, jclass clz, int64_t orig) {
48218         LDKRouteHop orig_conv;
48219         orig_conv.inner = untag_ptr(orig);
48220         orig_conv.is_owned = ptr_is_owned(orig);
48221         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
48222         orig_conv.is_owned = false;
48223         LDKRouteHop ret_var = RouteHop_clone(&orig_conv);
48224         int64_t ret_ref = 0;
48225         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48226         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48227         return ret_ref;
48228 }
48229
48230 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1hash(JNIEnv *env, jclass clz, int64_t o) {
48231         LDKRouteHop o_conv;
48232         o_conv.inner = untag_ptr(o);
48233         o_conv.is_owned = ptr_is_owned(o);
48234         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
48235         o_conv.is_owned = false;
48236         int64_t ret_conv = RouteHop_hash(&o_conv);
48237         return ret_conv;
48238 }
48239
48240 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RouteHop_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
48241         LDKRouteHop a_conv;
48242         a_conv.inner = untag_ptr(a);
48243         a_conv.is_owned = ptr_is_owned(a);
48244         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
48245         a_conv.is_owned = false;
48246         LDKRouteHop b_conv;
48247         b_conv.inner = untag_ptr(b);
48248         b_conv.is_owned = ptr_is_owned(b);
48249         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
48250         b_conv.is_owned = false;
48251         jboolean ret_conv = RouteHop_eq(&a_conv, &b_conv);
48252         return ret_conv;
48253 }
48254
48255 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteHop_1write(JNIEnv *env, jclass clz, int64_t obj) {
48256         LDKRouteHop obj_conv;
48257         obj_conv.inner = untag_ptr(obj);
48258         obj_conv.is_owned = ptr_is_owned(obj);
48259         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
48260         obj_conv.is_owned = false;
48261         LDKCVec_u8Z ret_var = RouteHop_write(&obj_conv);
48262         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
48263         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
48264         CVec_u8Z_free(ret_var);
48265         return ret_arr;
48266 }
48267
48268 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
48269         LDKu8slice ser_ref;
48270         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
48271         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
48272         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
48273         *ret_conv = RouteHop_read(ser_ref);
48274         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
48275         return tag_ptr(ret_conv, true);
48276 }
48277
48278 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Route_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
48279         LDKRoute this_obj_conv;
48280         this_obj_conv.inner = untag_ptr(this_obj);
48281         this_obj_conv.is_owned = ptr_is_owned(this_obj);
48282         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
48283         Route_free(this_obj_conv);
48284 }
48285
48286 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_Route_1get_1paths(JNIEnv *env, jclass clz, int64_t this_ptr) {
48287         LDKRoute this_ptr_conv;
48288         this_ptr_conv.inner = untag_ptr(this_ptr);
48289         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48290         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48291         this_ptr_conv.is_owned = false;
48292         LDKCVec_CVec_RouteHopZZ ret_var = Route_get_paths(&this_ptr_conv);
48293         jobjectArray ret_arr = NULL;
48294         ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_J_clz, NULL);
48295         ;
48296         for (size_t m = 0; m < ret_var.datalen; m++) {
48297                 LDKCVec_RouteHopZ ret_conv_12_var = ret_var.data[m];
48298                 int64_tArray ret_conv_12_arr = NULL;
48299                 ret_conv_12_arr = (*env)->NewLongArray(env, ret_conv_12_var.datalen);
48300                 int64_t *ret_conv_12_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_conv_12_arr, NULL);
48301                 for (size_t k = 0; k < ret_conv_12_var.datalen; k++) {
48302                         LDKRouteHop ret_conv_12_conv_10_var = ret_conv_12_var.data[k];
48303                         int64_t ret_conv_12_conv_10_ref = 0;
48304                         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_12_conv_10_var);
48305                         ret_conv_12_conv_10_ref = tag_ptr(ret_conv_12_conv_10_var.inner, ret_conv_12_conv_10_var.is_owned);
48306                         ret_conv_12_arr_ptr[k] = ret_conv_12_conv_10_ref;
48307                 }
48308                 (*env)->ReleasePrimitiveArrayCritical(env, ret_conv_12_arr, ret_conv_12_arr_ptr, 0);
48309                 FREE(ret_conv_12_var.data);
48310                 (*env)->SetObjectArrayElement(env, ret_arr, m, ret_conv_12_arr);
48311         }
48312         
48313         FREE(ret_var.data);
48314         return ret_arr;
48315 }
48316
48317 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Route_1set_1paths(JNIEnv *env, jclass clz, int64_t this_ptr, jobjectArray val) {
48318         LDKRoute this_ptr_conv;
48319         this_ptr_conv.inner = untag_ptr(this_ptr);
48320         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48321         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48322         this_ptr_conv.is_owned = false;
48323         LDKCVec_CVec_RouteHopZZ val_constr;
48324         val_constr.datalen = (*env)->GetArrayLength(env, val);
48325         if (val_constr.datalen > 0)
48326                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
48327         else
48328                 val_constr.data = NULL;
48329         for (size_t m = 0; m < val_constr.datalen; m++) {
48330                 int64_tArray val_conv_12 = (*env)->GetObjectArrayElement(env, val, m);
48331                 LDKCVec_RouteHopZ val_conv_12_constr;
48332                 val_conv_12_constr.datalen = (*env)->GetArrayLength(env, val_conv_12);
48333                 if (val_conv_12_constr.datalen > 0)
48334                         val_conv_12_constr.data = MALLOC(val_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
48335                 else
48336                         val_conv_12_constr.data = NULL;
48337                 int64_t* val_conv_12_vals = (*env)->GetLongArrayElements (env, val_conv_12, NULL);
48338                 for (size_t k = 0; k < val_conv_12_constr.datalen; k++) {
48339                         int64_t val_conv_12_conv_10 = val_conv_12_vals[k];
48340                         LDKRouteHop val_conv_12_conv_10_conv;
48341                         val_conv_12_conv_10_conv.inner = untag_ptr(val_conv_12_conv_10);
48342                         val_conv_12_conv_10_conv.is_owned = ptr_is_owned(val_conv_12_conv_10);
48343                         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_12_conv_10_conv);
48344                         val_conv_12_conv_10_conv = RouteHop_clone(&val_conv_12_conv_10_conv);
48345                         val_conv_12_constr.data[k] = val_conv_12_conv_10_conv;
48346                 }
48347                 (*env)->ReleaseLongArrayElements(env, val_conv_12, val_conv_12_vals, 0);
48348                 val_constr.data[m] = val_conv_12_constr;
48349         }
48350         Route_set_paths(&this_ptr_conv, val_constr);
48351 }
48352
48353 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1get_1payment_1params(JNIEnv *env, jclass clz, int64_t this_ptr) {
48354         LDKRoute this_ptr_conv;
48355         this_ptr_conv.inner = untag_ptr(this_ptr);
48356         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48357         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48358         this_ptr_conv.is_owned = false;
48359         LDKPaymentParameters ret_var = Route_get_payment_params(&this_ptr_conv);
48360         int64_t ret_ref = 0;
48361         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48362         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48363         return ret_ref;
48364 }
48365
48366 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Route_1set_1payment_1params(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
48367         LDKRoute this_ptr_conv;
48368         this_ptr_conv.inner = untag_ptr(this_ptr);
48369         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48370         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48371         this_ptr_conv.is_owned = false;
48372         LDKPaymentParameters val_conv;
48373         val_conv.inner = untag_ptr(val);
48374         val_conv.is_owned = ptr_is_owned(val);
48375         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
48376         val_conv = PaymentParameters_clone(&val_conv);
48377         Route_set_payment_params(&this_ptr_conv, val_conv);
48378 }
48379
48380 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1new(JNIEnv *env, jclass clz, jobjectArray paths_arg, int64_t payment_params_arg) {
48381         LDKCVec_CVec_RouteHopZZ paths_arg_constr;
48382         paths_arg_constr.datalen = (*env)->GetArrayLength(env, paths_arg);
48383         if (paths_arg_constr.datalen > 0)
48384                 paths_arg_constr.data = MALLOC(paths_arg_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
48385         else
48386                 paths_arg_constr.data = NULL;
48387         for (size_t m = 0; m < paths_arg_constr.datalen; m++) {
48388                 int64_tArray paths_arg_conv_12 = (*env)->GetObjectArrayElement(env, paths_arg, m);
48389                 LDKCVec_RouteHopZ paths_arg_conv_12_constr;
48390                 paths_arg_conv_12_constr.datalen = (*env)->GetArrayLength(env, paths_arg_conv_12);
48391                 if (paths_arg_conv_12_constr.datalen > 0)
48392                         paths_arg_conv_12_constr.data = MALLOC(paths_arg_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
48393                 else
48394                         paths_arg_conv_12_constr.data = NULL;
48395                 int64_t* paths_arg_conv_12_vals = (*env)->GetLongArrayElements (env, paths_arg_conv_12, NULL);
48396                 for (size_t k = 0; k < paths_arg_conv_12_constr.datalen; k++) {
48397                         int64_t paths_arg_conv_12_conv_10 = paths_arg_conv_12_vals[k];
48398                         LDKRouteHop paths_arg_conv_12_conv_10_conv;
48399                         paths_arg_conv_12_conv_10_conv.inner = untag_ptr(paths_arg_conv_12_conv_10);
48400                         paths_arg_conv_12_conv_10_conv.is_owned = ptr_is_owned(paths_arg_conv_12_conv_10);
48401                         CHECK_INNER_FIELD_ACCESS_OR_NULL(paths_arg_conv_12_conv_10_conv);
48402                         paths_arg_conv_12_conv_10_conv = RouteHop_clone(&paths_arg_conv_12_conv_10_conv);
48403                         paths_arg_conv_12_constr.data[k] = paths_arg_conv_12_conv_10_conv;
48404                 }
48405                 (*env)->ReleaseLongArrayElements(env, paths_arg_conv_12, paths_arg_conv_12_vals, 0);
48406                 paths_arg_constr.data[m] = paths_arg_conv_12_constr;
48407         }
48408         LDKPaymentParameters payment_params_arg_conv;
48409         payment_params_arg_conv.inner = untag_ptr(payment_params_arg);
48410         payment_params_arg_conv.is_owned = ptr_is_owned(payment_params_arg);
48411         CHECK_INNER_FIELD_ACCESS_OR_NULL(payment_params_arg_conv);
48412         payment_params_arg_conv = PaymentParameters_clone(&payment_params_arg_conv);
48413         LDKRoute ret_var = Route_new(paths_arg_constr, payment_params_arg_conv);
48414         int64_t ret_ref = 0;
48415         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48416         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48417         return ret_ref;
48418 }
48419
48420 static inline uint64_t Route_clone_ptr(LDKRoute *NONNULL_PTR arg) {
48421         LDKRoute ret_var = Route_clone(arg);
48422         int64_t ret_ref = 0;
48423         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48424         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48425         return ret_ref;
48426 }
48427 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
48428         LDKRoute arg_conv;
48429         arg_conv.inner = untag_ptr(arg);
48430         arg_conv.is_owned = ptr_is_owned(arg);
48431         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
48432         arg_conv.is_owned = false;
48433         int64_t ret_conv = Route_clone_ptr(&arg_conv);
48434         return ret_conv;
48435 }
48436
48437 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1clone(JNIEnv *env, jclass clz, int64_t orig) {
48438         LDKRoute orig_conv;
48439         orig_conv.inner = untag_ptr(orig);
48440         orig_conv.is_owned = ptr_is_owned(orig);
48441         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
48442         orig_conv.is_owned = false;
48443         LDKRoute ret_var = Route_clone(&orig_conv);
48444         int64_t ret_ref = 0;
48445         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48446         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48447         return ret_ref;
48448 }
48449
48450 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1hash(JNIEnv *env, jclass clz, int64_t o) {
48451         LDKRoute o_conv;
48452         o_conv.inner = untag_ptr(o);
48453         o_conv.is_owned = ptr_is_owned(o);
48454         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
48455         o_conv.is_owned = false;
48456         int64_t ret_conv = Route_hash(&o_conv);
48457         return ret_conv;
48458 }
48459
48460 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Route_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
48461         LDKRoute a_conv;
48462         a_conv.inner = untag_ptr(a);
48463         a_conv.is_owned = ptr_is_owned(a);
48464         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
48465         a_conv.is_owned = false;
48466         LDKRoute b_conv;
48467         b_conv.inner = untag_ptr(b);
48468         b_conv.is_owned = ptr_is_owned(b);
48469         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
48470         b_conv.is_owned = false;
48471         jboolean ret_conv = Route_eq(&a_conv, &b_conv);
48472         return ret_conv;
48473 }
48474
48475 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1get_1total_1fees(JNIEnv *env, jclass clz, int64_t this_arg) {
48476         LDKRoute this_arg_conv;
48477         this_arg_conv.inner = untag_ptr(this_arg);
48478         this_arg_conv.is_owned = ptr_is_owned(this_arg);
48479         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48480         this_arg_conv.is_owned = false;
48481         int64_t ret_conv = Route_get_total_fees(&this_arg_conv);
48482         return ret_conv;
48483 }
48484
48485 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1get_1total_1amount(JNIEnv *env, jclass clz, int64_t this_arg) {
48486         LDKRoute this_arg_conv;
48487         this_arg_conv.inner = untag_ptr(this_arg);
48488         this_arg_conv.is_owned = ptr_is_owned(this_arg);
48489         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
48490         this_arg_conv.is_owned = false;
48491         int64_t ret_conv = Route_get_total_amount(&this_arg_conv);
48492         return ret_conv;
48493 }
48494
48495 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Route_1write(JNIEnv *env, jclass clz, int64_t obj) {
48496         LDKRoute obj_conv;
48497         obj_conv.inner = untag_ptr(obj);
48498         obj_conv.is_owned = ptr_is_owned(obj);
48499         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
48500         obj_conv.is_owned = false;
48501         LDKCVec_u8Z ret_var = Route_write(&obj_conv);
48502         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
48503         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
48504         CVec_u8Z_free(ret_var);
48505         return ret_arr;
48506 }
48507
48508 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
48509         LDKu8slice ser_ref;
48510         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
48511         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
48512         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
48513         *ret_conv = Route_read(ser_ref);
48514         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
48515         return tag_ptr(ret_conv, true);
48516 }
48517
48518 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
48519         LDKRouteParameters this_obj_conv;
48520         this_obj_conv.inner = untag_ptr(this_obj);
48521         this_obj_conv.is_owned = ptr_is_owned(this_obj);
48522         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
48523         RouteParameters_free(this_obj_conv);
48524 }
48525
48526 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteParameters_1get_1payment_1params(JNIEnv *env, jclass clz, int64_t this_ptr) {
48527         LDKRouteParameters this_ptr_conv;
48528         this_ptr_conv.inner = untag_ptr(this_ptr);
48529         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48530         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48531         this_ptr_conv.is_owned = false;
48532         LDKPaymentParameters ret_var = RouteParameters_get_payment_params(&this_ptr_conv);
48533         int64_t ret_ref = 0;
48534         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48535         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48536         return ret_ref;
48537 }
48538
48539 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteParameters_1set_1payment_1params(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
48540         LDKRouteParameters this_ptr_conv;
48541         this_ptr_conv.inner = untag_ptr(this_ptr);
48542         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48543         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48544         this_ptr_conv.is_owned = false;
48545         LDKPaymentParameters val_conv;
48546         val_conv.inner = untag_ptr(val);
48547         val_conv.is_owned = ptr_is_owned(val);
48548         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
48549         val_conv = PaymentParameters_clone(&val_conv);
48550         RouteParameters_set_payment_params(&this_ptr_conv, val_conv);
48551 }
48552
48553 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteParameters_1get_1final_1value_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
48554         LDKRouteParameters this_ptr_conv;
48555         this_ptr_conv.inner = untag_ptr(this_ptr);
48556         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48557         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48558         this_ptr_conv.is_owned = false;
48559         int64_t ret_conv = RouteParameters_get_final_value_msat(&this_ptr_conv);
48560         return ret_conv;
48561 }
48562
48563 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteParameters_1set_1final_1value_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
48564         LDKRouteParameters this_ptr_conv;
48565         this_ptr_conv.inner = untag_ptr(this_ptr);
48566         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48567         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48568         this_ptr_conv.is_owned = false;
48569         RouteParameters_set_final_value_msat(&this_ptr_conv, val);
48570 }
48571
48572 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_RouteParameters_1get_1final_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
48573         LDKRouteParameters this_ptr_conv;
48574         this_ptr_conv.inner = untag_ptr(this_ptr);
48575         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48576         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48577         this_ptr_conv.is_owned = false;
48578         int32_t ret_conv = RouteParameters_get_final_cltv_expiry_delta(&this_ptr_conv);
48579         return ret_conv;
48580 }
48581
48582 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) {
48583         LDKRouteParameters this_ptr_conv;
48584         this_ptr_conv.inner = untag_ptr(this_ptr);
48585         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48586         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48587         this_ptr_conv.is_owned = false;
48588         RouteParameters_set_final_cltv_expiry_delta(&this_ptr_conv, val);
48589 }
48590
48591 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) {
48592         LDKPaymentParameters payment_params_arg_conv;
48593         payment_params_arg_conv.inner = untag_ptr(payment_params_arg);
48594         payment_params_arg_conv.is_owned = ptr_is_owned(payment_params_arg);
48595         CHECK_INNER_FIELD_ACCESS_OR_NULL(payment_params_arg_conv);
48596         payment_params_arg_conv = PaymentParameters_clone(&payment_params_arg_conv);
48597         LDKRouteParameters ret_var = RouteParameters_new(payment_params_arg_conv, final_value_msat_arg, final_cltv_expiry_delta_arg);
48598         int64_t ret_ref = 0;
48599         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48600         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48601         return ret_ref;
48602 }
48603
48604 static inline uint64_t RouteParameters_clone_ptr(LDKRouteParameters *NONNULL_PTR arg) {
48605         LDKRouteParameters ret_var = RouteParameters_clone(arg);
48606         int64_t ret_ref = 0;
48607         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48608         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48609         return ret_ref;
48610 }
48611 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteParameters_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
48612         LDKRouteParameters arg_conv;
48613         arg_conv.inner = untag_ptr(arg);
48614         arg_conv.is_owned = ptr_is_owned(arg);
48615         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
48616         arg_conv.is_owned = false;
48617         int64_t ret_conv = RouteParameters_clone_ptr(&arg_conv);
48618         return ret_conv;
48619 }
48620
48621 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteParameters_1clone(JNIEnv *env, jclass clz, int64_t orig) {
48622         LDKRouteParameters orig_conv;
48623         orig_conv.inner = untag_ptr(orig);
48624         orig_conv.is_owned = ptr_is_owned(orig);
48625         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
48626         orig_conv.is_owned = false;
48627         LDKRouteParameters ret_var = RouteParameters_clone(&orig_conv);
48628         int64_t ret_ref = 0;
48629         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48630         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48631         return ret_ref;
48632 }
48633
48634 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteParameters_1write(JNIEnv *env, jclass clz, int64_t obj) {
48635         LDKRouteParameters obj_conv;
48636         obj_conv.inner = untag_ptr(obj);
48637         obj_conv.is_owned = ptr_is_owned(obj);
48638         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
48639         obj_conv.is_owned = false;
48640         LDKCVec_u8Z ret_var = RouteParameters_write(&obj_conv);
48641         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
48642         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
48643         CVec_u8Z_free(ret_var);
48644         return ret_arr;
48645 }
48646
48647 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteParameters_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
48648         LDKu8slice ser_ref;
48649         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
48650         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
48651         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
48652         *ret_conv = RouteParameters_read(ser_ref);
48653         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
48654         return tag_ptr(ret_conv, true);
48655 }
48656
48657 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
48658         LDKPaymentParameters this_obj_conv;
48659         this_obj_conv.inner = untag_ptr(this_obj);
48660         this_obj_conv.is_owned = ptr_is_owned(this_obj);
48661         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
48662         PaymentParameters_free(this_obj_conv);
48663 }
48664
48665 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1get_1payee_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
48666         LDKPaymentParameters this_ptr_conv;
48667         this_ptr_conv.inner = untag_ptr(this_ptr);
48668         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48669         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48670         this_ptr_conv.is_owned = false;
48671         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
48672         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, PaymentParameters_get_payee_pubkey(&this_ptr_conv).compressed_form);
48673         return ret_arr;
48674 }
48675
48676 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1set_1payee_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
48677         LDKPaymentParameters this_ptr_conv;
48678         this_ptr_conv.inner = untag_ptr(this_ptr);
48679         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48680         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48681         this_ptr_conv.is_owned = false;
48682         LDKPublicKey val_ref;
48683         CHECK((*env)->GetArrayLength(env, val) == 33);
48684         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
48685         PaymentParameters_set_payee_pubkey(&this_ptr_conv, val_ref);
48686 }
48687
48688 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
48689         LDKPaymentParameters this_ptr_conv;
48690         this_ptr_conv.inner = untag_ptr(this_ptr);
48691         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48692         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48693         this_ptr_conv.is_owned = false;
48694         LDKInvoiceFeatures ret_var = PaymentParameters_get_features(&this_ptr_conv);
48695         int64_t ret_ref = 0;
48696         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48697         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48698         return ret_ref;
48699 }
48700
48701 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
48702         LDKPaymentParameters this_ptr_conv;
48703         this_ptr_conv.inner = untag_ptr(this_ptr);
48704         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48705         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48706         this_ptr_conv.is_owned = false;
48707         LDKInvoiceFeatures val_conv;
48708         val_conv.inner = untag_ptr(val);
48709         val_conv.is_owned = ptr_is_owned(val);
48710         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
48711         val_conv = InvoiceFeatures_clone(&val_conv);
48712         PaymentParameters_set_features(&this_ptr_conv, val_conv);
48713 }
48714
48715 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1get_1route_1hints(JNIEnv *env, jclass clz, int64_t this_ptr) {
48716         LDKPaymentParameters this_ptr_conv;
48717         this_ptr_conv.inner = untag_ptr(this_ptr);
48718         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48719         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48720         this_ptr_conv.is_owned = false;
48721         LDKCVec_RouteHintZ ret_var = PaymentParameters_get_route_hints(&this_ptr_conv);
48722         int64_tArray ret_arr = NULL;
48723         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
48724         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
48725         for (size_t l = 0; l < ret_var.datalen; l++) {
48726                 LDKRouteHint ret_conv_11_var = ret_var.data[l];
48727                 int64_t ret_conv_11_ref = 0;
48728                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_11_var);
48729                 ret_conv_11_ref = tag_ptr(ret_conv_11_var.inner, ret_conv_11_var.is_owned);
48730                 ret_arr_ptr[l] = ret_conv_11_ref;
48731         }
48732         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
48733         FREE(ret_var.data);
48734         return ret_arr;
48735 }
48736
48737 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1set_1route_1hints(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
48738         LDKPaymentParameters this_ptr_conv;
48739         this_ptr_conv.inner = untag_ptr(this_ptr);
48740         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48741         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48742         this_ptr_conv.is_owned = false;
48743         LDKCVec_RouteHintZ val_constr;
48744         val_constr.datalen = (*env)->GetArrayLength(env, val);
48745         if (val_constr.datalen > 0)
48746                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
48747         else
48748                 val_constr.data = NULL;
48749         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
48750         for (size_t l = 0; l < val_constr.datalen; l++) {
48751                 int64_t val_conv_11 = val_vals[l];
48752                 LDKRouteHint val_conv_11_conv;
48753                 val_conv_11_conv.inner = untag_ptr(val_conv_11);
48754                 val_conv_11_conv.is_owned = ptr_is_owned(val_conv_11);
48755                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_11_conv);
48756                 val_conv_11_conv = RouteHint_clone(&val_conv_11_conv);
48757                 val_constr.data[l] = val_conv_11_conv;
48758         }
48759         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
48760         PaymentParameters_set_route_hints(&this_ptr_conv, val_constr);
48761 }
48762
48763 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1get_1expiry_1time(JNIEnv *env, jclass clz, int64_t this_ptr) {
48764         LDKPaymentParameters this_ptr_conv;
48765         this_ptr_conv.inner = untag_ptr(this_ptr);
48766         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48767         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48768         this_ptr_conv.is_owned = false;
48769         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
48770         *ret_copy = PaymentParameters_get_expiry_time(&this_ptr_conv);
48771         int64_t ret_ref = tag_ptr(ret_copy, true);
48772         return ret_ref;
48773 }
48774
48775 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1set_1expiry_1time(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
48776         LDKPaymentParameters this_ptr_conv;
48777         this_ptr_conv.inner = untag_ptr(this_ptr);
48778         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48779         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48780         this_ptr_conv.is_owned = false;
48781         void* val_ptr = untag_ptr(val);
48782         CHECK_ACCESS(val_ptr);
48783         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
48784         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(val));
48785         PaymentParameters_set_expiry_time(&this_ptr_conv, val_conv);
48786 }
48787
48788 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1get_1max_1total_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
48789         LDKPaymentParameters this_ptr_conv;
48790         this_ptr_conv.inner = untag_ptr(this_ptr);
48791         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48792         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48793         this_ptr_conv.is_owned = false;
48794         int32_t ret_conv = PaymentParameters_get_max_total_cltv_expiry_delta(&this_ptr_conv);
48795         return ret_conv;
48796 }
48797
48798 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) {
48799         LDKPaymentParameters this_ptr_conv;
48800         this_ptr_conv.inner = untag_ptr(this_ptr);
48801         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48802         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48803         this_ptr_conv.is_owned = false;
48804         PaymentParameters_set_max_total_cltv_expiry_delta(&this_ptr_conv, val);
48805 }
48806
48807 JNIEXPORT int8_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1get_1max_1path_1count(JNIEnv *env, jclass clz, int64_t this_ptr) {
48808         LDKPaymentParameters this_ptr_conv;
48809         this_ptr_conv.inner = untag_ptr(this_ptr);
48810         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48811         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48812         this_ptr_conv.is_owned = false;
48813         int8_t ret_conv = PaymentParameters_get_max_path_count(&this_ptr_conv);
48814         return ret_conv;
48815 }
48816
48817 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1set_1max_1path_1count(JNIEnv *env, jclass clz, int64_t this_ptr, int8_t val) {
48818         LDKPaymentParameters this_ptr_conv;
48819         this_ptr_conv.inner = untag_ptr(this_ptr);
48820         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48821         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48822         this_ptr_conv.is_owned = false;
48823         PaymentParameters_set_max_path_count(&this_ptr_conv, val);
48824 }
48825
48826 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) {
48827         LDKPaymentParameters this_ptr_conv;
48828         this_ptr_conv.inner = untag_ptr(this_ptr);
48829         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48830         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48831         this_ptr_conv.is_owned = false;
48832         int8_t ret_conv = PaymentParameters_get_max_channel_saturation_power_of_half(&this_ptr_conv);
48833         return ret_conv;
48834 }
48835
48836 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) {
48837         LDKPaymentParameters this_ptr_conv;
48838         this_ptr_conv.inner = untag_ptr(this_ptr);
48839         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48840         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48841         this_ptr_conv.is_owned = false;
48842         PaymentParameters_set_max_channel_saturation_power_of_half(&this_ptr_conv, val);
48843 }
48844
48845 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1get_1previously_1failed_1channels(JNIEnv *env, jclass clz, int64_t this_ptr) {
48846         LDKPaymentParameters this_ptr_conv;
48847         this_ptr_conv.inner = untag_ptr(this_ptr);
48848         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48849         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48850         this_ptr_conv.is_owned = false;
48851         LDKCVec_u64Z ret_var = PaymentParameters_get_previously_failed_channels(&this_ptr_conv);
48852         int64_tArray ret_arr = NULL;
48853         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
48854         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
48855         for (size_t g = 0; g < ret_var.datalen; g++) {
48856                 int64_t ret_conv_6_conv = ret_var.data[g];
48857                 ret_arr_ptr[g] = ret_conv_6_conv;
48858         }
48859         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
48860         FREE(ret_var.data);
48861         return ret_arr;
48862 }
48863
48864 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1set_1previously_1failed_1channels(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
48865         LDKPaymentParameters this_ptr_conv;
48866         this_ptr_conv.inner = untag_ptr(this_ptr);
48867         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
48868         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
48869         this_ptr_conv.is_owned = false;
48870         LDKCVec_u64Z val_constr;
48871         val_constr.datalen = (*env)->GetArrayLength(env, val);
48872         if (val_constr.datalen > 0)
48873                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
48874         else
48875                 val_constr.data = NULL;
48876         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
48877         for (size_t g = 0; g < val_constr.datalen; g++) {
48878                 int64_t val_conv_6 = val_vals[g];
48879                 val_constr.data[g] = val_conv_6;
48880         }
48881         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
48882         PaymentParameters_set_previously_failed_channels(&this_ptr_conv, val_constr);
48883 }
48884
48885 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) {
48886         LDKPublicKey payee_pubkey_arg_ref;
48887         CHECK((*env)->GetArrayLength(env, payee_pubkey_arg) == 33);
48888         (*env)->GetByteArrayRegion(env, payee_pubkey_arg, 0, 33, payee_pubkey_arg_ref.compressed_form);
48889         LDKInvoiceFeatures features_arg_conv;
48890         features_arg_conv.inner = untag_ptr(features_arg);
48891         features_arg_conv.is_owned = ptr_is_owned(features_arg);
48892         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_arg_conv);
48893         features_arg_conv = InvoiceFeatures_clone(&features_arg_conv);
48894         LDKCVec_RouteHintZ route_hints_arg_constr;
48895         route_hints_arg_constr.datalen = (*env)->GetArrayLength(env, route_hints_arg);
48896         if (route_hints_arg_constr.datalen > 0)
48897                 route_hints_arg_constr.data = MALLOC(route_hints_arg_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
48898         else
48899                 route_hints_arg_constr.data = NULL;
48900         int64_t* route_hints_arg_vals = (*env)->GetLongArrayElements (env, route_hints_arg, NULL);
48901         for (size_t l = 0; l < route_hints_arg_constr.datalen; l++) {
48902                 int64_t route_hints_arg_conv_11 = route_hints_arg_vals[l];
48903                 LDKRouteHint route_hints_arg_conv_11_conv;
48904                 route_hints_arg_conv_11_conv.inner = untag_ptr(route_hints_arg_conv_11);
48905                 route_hints_arg_conv_11_conv.is_owned = ptr_is_owned(route_hints_arg_conv_11);
48906                 CHECK_INNER_FIELD_ACCESS_OR_NULL(route_hints_arg_conv_11_conv);
48907                 route_hints_arg_conv_11_conv = RouteHint_clone(&route_hints_arg_conv_11_conv);
48908                 route_hints_arg_constr.data[l] = route_hints_arg_conv_11_conv;
48909         }
48910         (*env)->ReleaseLongArrayElements(env, route_hints_arg, route_hints_arg_vals, 0);
48911         void* expiry_time_arg_ptr = untag_ptr(expiry_time_arg);
48912         CHECK_ACCESS(expiry_time_arg_ptr);
48913         LDKCOption_u64Z expiry_time_arg_conv = *(LDKCOption_u64Z*)(expiry_time_arg_ptr);
48914         expiry_time_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(expiry_time_arg));
48915         LDKCVec_u64Z previously_failed_channels_arg_constr;
48916         previously_failed_channels_arg_constr.datalen = (*env)->GetArrayLength(env, previously_failed_channels_arg);
48917         if (previously_failed_channels_arg_constr.datalen > 0)
48918                 previously_failed_channels_arg_constr.data = MALLOC(previously_failed_channels_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
48919         else
48920                 previously_failed_channels_arg_constr.data = NULL;
48921         int64_t* previously_failed_channels_arg_vals = (*env)->GetLongArrayElements (env, previously_failed_channels_arg, NULL);
48922         for (size_t g = 0; g < previously_failed_channels_arg_constr.datalen; g++) {
48923                 int64_t previously_failed_channels_arg_conv_6 = previously_failed_channels_arg_vals[g];
48924                 previously_failed_channels_arg_constr.data[g] = previously_failed_channels_arg_conv_6;
48925         }
48926         (*env)->ReleaseLongArrayElements(env, previously_failed_channels_arg, previously_failed_channels_arg_vals, 0);
48927         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);
48928         int64_t ret_ref = 0;
48929         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48930         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48931         return ret_ref;
48932 }
48933
48934 static inline uint64_t PaymentParameters_clone_ptr(LDKPaymentParameters *NONNULL_PTR arg) {
48935         LDKPaymentParameters ret_var = PaymentParameters_clone(arg);
48936         int64_t ret_ref = 0;
48937         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48938         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48939         return ret_ref;
48940 }
48941 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
48942         LDKPaymentParameters arg_conv;
48943         arg_conv.inner = untag_ptr(arg);
48944         arg_conv.is_owned = ptr_is_owned(arg);
48945         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
48946         arg_conv.is_owned = false;
48947         int64_t ret_conv = PaymentParameters_clone_ptr(&arg_conv);
48948         return ret_conv;
48949 }
48950
48951 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1clone(JNIEnv *env, jclass clz, int64_t orig) {
48952         LDKPaymentParameters orig_conv;
48953         orig_conv.inner = untag_ptr(orig);
48954         orig_conv.is_owned = ptr_is_owned(orig);
48955         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
48956         orig_conv.is_owned = false;
48957         LDKPaymentParameters ret_var = PaymentParameters_clone(&orig_conv);
48958         int64_t ret_ref = 0;
48959         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
48960         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
48961         return ret_ref;
48962 }
48963
48964 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1hash(JNIEnv *env, jclass clz, int64_t o) {
48965         LDKPaymentParameters o_conv;
48966         o_conv.inner = untag_ptr(o);
48967         o_conv.is_owned = ptr_is_owned(o);
48968         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
48969         o_conv.is_owned = false;
48970         int64_t ret_conv = PaymentParameters_hash(&o_conv);
48971         return ret_conv;
48972 }
48973
48974 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
48975         LDKPaymentParameters a_conv;
48976         a_conv.inner = untag_ptr(a);
48977         a_conv.is_owned = ptr_is_owned(a);
48978         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
48979         a_conv.is_owned = false;
48980         LDKPaymentParameters b_conv;
48981         b_conv.inner = untag_ptr(b);
48982         b_conv.is_owned = ptr_is_owned(b);
48983         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
48984         b_conv.is_owned = false;
48985         jboolean ret_conv = PaymentParameters_eq(&a_conv, &b_conv);
48986         return ret_conv;
48987 }
48988
48989 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1write(JNIEnv *env, jclass clz, int64_t obj) {
48990         LDKPaymentParameters obj_conv;
48991         obj_conv.inner = untag_ptr(obj);
48992         obj_conv.is_owned = ptr_is_owned(obj);
48993         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
48994         obj_conv.is_owned = false;
48995         LDKCVec_u8Z ret_var = PaymentParameters_write(&obj_conv);
48996         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
48997         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
48998         CVec_u8Z_free(ret_var);
48999         return ret_arr;
49000 }
49001
49002 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
49003         LDKu8slice ser_ref;
49004         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
49005         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
49006         LDKCResult_PaymentParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentParametersDecodeErrorZ), "LDKCResult_PaymentParametersDecodeErrorZ");
49007         *ret_conv = PaymentParameters_read(ser_ref);
49008         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
49009         return tag_ptr(ret_conv, true);
49010 }
49011
49012 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1from_1node_1id(JNIEnv *env, jclass clz, int8_tArray payee_pubkey) {
49013         LDKPublicKey payee_pubkey_ref;
49014         CHECK((*env)->GetArrayLength(env, payee_pubkey) == 33);
49015         (*env)->GetByteArrayRegion(env, payee_pubkey, 0, 33, payee_pubkey_ref.compressed_form);
49016         LDKPaymentParameters ret_var = PaymentParameters_from_node_id(payee_pubkey_ref);
49017         int64_t ret_ref = 0;
49018         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49019         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49020         return ret_ref;
49021 }
49022
49023 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentParameters_1for_1keysend(JNIEnv *env, jclass clz, int8_tArray payee_pubkey) {
49024         LDKPublicKey payee_pubkey_ref;
49025         CHECK((*env)->GetArrayLength(env, payee_pubkey) == 33);
49026         (*env)->GetByteArrayRegion(env, payee_pubkey, 0, 33, payee_pubkey_ref.compressed_form);
49027         LDKPaymentParameters ret_var = PaymentParameters_for_keysend(payee_pubkey_ref);
49028         int64_t ret_ref = 0;
49029         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49030         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49031         return ret_ref;
49032 }
49033
49034 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHint_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
49035         LDKRouteHint this_obj_conv;
49036         this_obj_conv.inner = untag_ptr(this_obj);
49037         this_obj_conv.is_owned = ptr_is_owned(this_obj);
49038         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
49039         RouteHint_free(this_obj_conv);
49040 }
49041
49042 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_RouteHint_1get_1a(JNIEnv *env, jclass clz, int64_t this_ptr) {
49043         LDKRouteHint this_ptr_conv;
49044         this_ptr_conv.inner = untag_ptr(this_ptr);
49045         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49046         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49047         this_ptr_conv.is_owned = false;
49048         LDKCVec_RouteHintHopZ ret_var = RouteHint_get_a(&this_ptr_conv);
49049         int64_tArray ret_arr = NULL;
49050         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
49051         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
49052         for (size_t o = 0; o < ret_var.datalen; o++) {
49053                 LDKRouteHintHop ret_conv_14_var = ret_var.data[o];
49054                 int64_t ret_conv_14_ref = 0;
49055                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_14_var);
49056                 ret_conv_14_ref = tag_ptr(ret_conv_14_var.inner, ret_conv_14_var.is_owned);
49057                 ret_arr_ptr[o] = ret_conv_14_ref;
49058         }
49059         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
49060         FREE(ret_var.data);
49061         return ret_arr;
49062 }
49063
49064 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHint_1set_1a(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
49065         LDKRouteHint this_ptr_conv;
49066         this_ptr_conv.inner = untag_ptr(this_ptr);
49067         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49068         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49069         this_ptr_conv.is_owned = false;
49070         LDKCVec_RouteHintHopZ val_constr;
49071         val_constr.datalen = (*env)->GetArrayLength(env, val);
49072         if (val_constr.datalen > 0)
49073                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKRouteHintHop), "LDKCVec_RouteHintHopZ Elements");
49074         else
49075                 val_constr.data = NULL;
49076         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
49077         for (size_t o = 0; o < val_constr.datalen; o++) {
49078                 int64_t val_conv_14 = val_vals[o];
49079                 LDKRouteHintHop val_conv_14_conv;
49080                 val_conv_14_conv.inner = untag_ptr(val_conv_14);
49081                 val_conv_14_conv.is_owned = ptr_is_owned(val_conv_14);
49082                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_14_conv);
49083                 val_conv_14_conv = RouteHintHop_clone(&val_conv_14_conv);
49084                 val_constr.data[o] = val_conv_14_conv;
49085         }
49086         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
49087         RouteHint_set_a(&this_ptr_conv, val_constr);
49088 }
49089
49090 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHint_1new(JNIEnv *env, jclass clz, int64_tArray a_arg) {
49091         LDKCVec_RouteHintHopZ a_arg_constr;
49092         a_arg_constr.datalen = (*env)->GetArrayLength(env, a_arg);
49093         if (a_arg_constr.datalen > 0)
49094                 a_arg_constr.data = MALLOC(a_arg_constr.datalen * sizeof(LDKRouteHintHop), "LDKCVec_RouteHintHopZ Elements");
49095         else
49096                 a_arg_constr.data = NULL;
49097         int64_t* a_arg_vals = (*env)->GetLongArrayElements (env, a_arg, NULL);
49098         for (size_t o = 0; o < a_arg_constr.datalen; o++) {
49099                 int64_t a_arg_conv_14 = a_arg_vals[o];
49100                 LDKRouteHintHop a_arg_conv_14_conv;
49101                 a_arg_conv_14_conv.inner = untag_ptr(a_arg_conv_14);
49102                 a_arg_conv_14_conv.is_owned = ptr_is_owned(a_arg_conv_14);
49103                 CHECK_INNER_FIELD_ACCESS_OR_NULL(a_arg_conv_14_conv);
49104                 a_arg_conv_14_conv = RouteHintHop_clone(&a_arg_conv_14_conv);
49105                 a_arg_constr.data[o] = a_arg_conv_14_conv;
49106         }
49107         (*env)->ReleaseLongArrayElements(env, a_arg, a_arg_vals, 0);
49108         LDKRouteHint ret_var = RouteHint_new(a_arg_constr);
49109         int64_t ret_ref = 0;
49110         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49111         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49112         return ret_ref;
49113 }
49114
49115 static inline uint64_t RouteHint_clone_ptr(LDKRouteHint *NONNULL_PTR arg) {
49116         LDKRouteHint ret_var = RouteHint_clone(arg);
49117         int64_t ret_ref = 0;
49118         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49119         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49120         return ret_ref;
49121 }
49122 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHint_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
49123         LDKRouteHint arg_conv;
49124         arg_conv.inner = untag_ptr(arg);
49125         arg_conv.is_owned = ptr_is_owned(arg);
49126         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
49127         arg_conv.is_owned = false;
49128         int64_t ret_conv = RouteHint_clone_ptr(&arg_conv);
49129         return ret_conv;
49130 }
49131
49132 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHint_1clone(JNIEnv *env, jclass clz, int64_t orig) {
49133         LDKRouteHint orig_conv;
49134         orig_conv.inner = untag_ptr(orig);
49135         orig_conv.is_owned = ptr_is_owned(orig);
49136         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
49137         orig_conv.is_owned = false;
49138         LDKRouteHint ret_var = RouteHint_clone(&orig_conv);
49139         int64_t ret_ref = 0;
49140         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49141         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49142         return ret_ref;
49143 }
49144
49145 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHint_1hash(JNIEnv *env, jclass clz, int64_t o) {
49146         LDKRouteHint o_conv;
49147         o_conv.inner = untag_ptr(o);
49148         o_conv.is_owned = ptr_is_owned(o);
49149         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
49150         o_conv.is_owned = false;
49151         int64_t ret_conv = RouteHint_hash(&o_conv);
49152         return ret_conv;
49153 }
49154
49155 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RouteHint_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
49156         LDKRouteHint a_conv;
49157         a_conv.inner = untag_ptr(a);
49158         a_conv.is_owned = ptr_is_owned(a);
49159         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
49160         a_conv.is_owned = false;
49161         LDKRouteHint b_conv;
49162         b_conv.inner = untag_ptr(b);
49163         b_conv.is_owned = ptr_is_owned(b);
49164         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
49165         b_conv.is_owned = false;
49166         jboolean ret_conv = RouteHint_eq(&a_conv, &b_conv);
49167         return ret_conv;
49168 }
49169
49170 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteHint_1write(JNIEnv *env, jclass clz, int64_t obj) {
49171         LDKRouteHint obj_conv;
49172         obj_conv.inner = untag_ptr(obj);
49173         obj_conv.is_owned = ptr_is_owned(obj);
49174         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
49175         obj_conv.is_owned = false;
49176         LDKCVec_u8Z ret_var = RouteHint_write(&obj_conv);
49177         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
49178         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
49179         CVec_u8Z_free(ret_var);
49180         return ret_arr;
49181 }
49182
49183 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHint_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
49184         LDKu8slice ser_ref;
49185         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
49186         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
49187         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
49188         *ret_conv = RouteHint_read(ser_ref);
49189         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
49190         return tag_ptr(ret_conv, true);
49191 }
49192
49193 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
49194         LDKRouteHintHop this_obj_conv;
49195         this_obj_conv.inner = untag_ptr(this_obj);
49196         this_obj_conv.is_owned = ptr_is_owned(this_obj);
49197         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
49198         RouteHintHop_free(this_obj_conv);
49199 }
49200
49201 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1src_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
49202         LDKRouteHintHop this_ptr_conv;
49203         this_ptr_conv.inner = untag_ptr(this_ptr);
49204         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49205         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49206         this_ptr_conv.is_owned = false;
49207         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
49208         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, RouteHintHop_get_src_node_id(&this_ptr_conv).compressed_form);
49209         return ret_arr;
49210 }
49211
49212 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1src_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
49213         LDKRouteHintHop this_ptr_conv;
49214         this_ptr_conv.inner = untag_ptr(this_ptr);
49215         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49216         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49217         this_ptr_conv.is_owned = false;
49218         LDKPublicKey val_ref;
49219         CHECK((*env)->GetArrayLength(env, val) == 33);
49220         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
49221         RouteHintHop_set_src_node_id(&this_ptr_conv, val_ref);
49222 }
49223
49224 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
49225         LDKRouteHintHop this_ptr_conv;
49226         this_ptr_conv.inner = untag_ptr(this_ptr);
49227         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49228         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49229         this_ptr_conv.is_owned = false;
49230         int64_t ret_conv = RouteHintHop_get_short_channel_id(&this_ptr_conv);
49231         return ret_conv;
49232 }
49233
49234 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
49235         LDKRouteHintHop this_ptr_conv;
49236         this_ptr_conv.inner = untag_ptr(this_ptr);
49237         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49238         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49239         this_ptr_conv.is_owned = false;
49240         RouteHintHop_set_short_channel_id(&this_ptr_conv, val);
49241 }
49242
49243 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1fees(JNIEnv *env, jclass clz, int64_t this_ptr) {
49244         LDKRouteHintHop this_ptr_conv;
49245         this_ptr_conv.inner = untag_ptr(this_ptr);
49246         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49247         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49248         this_ptr_conv.is_owned = false;
49249         LDKRoutingFees ret_var = RouteHintHop_get_fees(&this_ptr_conv);
49250         int64_t ret_ref = 0;
49251         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49252         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49253         return ret_ref;
49254 }
49255
49256 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1fees(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
49257         LDKRouteHintHop this_ptr_conv;
49258         this_ptr_conv.inner = untag_ptr(this_ptr);
49259         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49260         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49261         this_ptr_conv.is_owned = false;
49262         LDKRoutingFees val_conv;
49263         val_conv.inner = untag_ptr(val);
49264         val_conv.is_owned = ptr_is_owned(val);
49265         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
49266         val_conv = RoutingFees_clone(&val_conv);
49267         RouteHintHop_set_fees(&this_ptr_conv, val_conv);
49268 }
49269
49270 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
49271         LDKRouteHintHop this_ptr_conv;
49272         this_ptr_conv.inner = untag_ptr(this_ptr);
49273         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49274         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49275         this_ptr_conv.is_owned = false;
49276         int16_t ret_conv = RouteHintHop_get_cltv_expiry_delta(&this_ptr_conv);
49277         return ret_conv;
49278 }
49279
49280 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
49281         LDKRouteHintHop this_ptr_conv;
49282         this_ptr_conv.inner = untag_ptr(this_ptr);
49283         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49284         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49285         this_ptr_conv.is_owned = false;
49286         RouteHintHop_set_cltv_expiry_delta(&this_ptr_conv, val);
49287 }
49288
49289 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
49290         LDKRouteHintHop this_ptr_conv;
49291         this_ptr_conv.inner = untag_ptr(this_ptr);
49292         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49293         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49294         this_ptr_conv.is_owned = false;
49295         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
49296         *ret_copy = RouteHintHop_get_htlc_minimum_msat(&this_ptr_conv);
49297         int64_t ret_ref = tag_ptr(ret_copy, true);
49298         return ret_ref;
49299 }
49300
49301 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
49302         LDKRouteHintHop this_ptr_conv;
49303         this_ptr_conv.inner = untag_ptr(this_ptr);
49304         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49305         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49306         this_ptr_conv.is_owned = false;
49307         void* val_ptr = untag_ptr(val);
49308         CHECK_ACCESS(val_ptr);
49309         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
49310         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(val));
49311         RouteHintHop_set_htlc_minimum_msat(&this_ptr_conv, val_conv);
49312 }
49313
49314 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
49315         LDKRouteHintHop this_ptr_conv;
49316         this_ptr_conv.inner = untag_ptr(this_ptr);
49317         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49318         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49319         this_ptr_conv.is_owned = false;
49320         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
49321         *ret_copy = RouteHintHop_get_htlc_maximum_msat(&this_ptr_conv);
49322         int64_t ret_ref = tag_ptr(ret_copy, true);
49323         return ret_ref;
49324 }
49325
49326 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
49327         LDKRouteHintHop this_ptr_conv;
49328         this_ptr_conv.inner = untag_ptr(this_ptr);
49329         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49330         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49331         this_ptr_conv.is_owned = false;
49332         void* val_ptr = untag_ptr(val);
49333         CHECK_ACCESS(val_ptr);
49334         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
49335         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(val));
49336         RouteHintHop_set_htlc_maximum_msat(&this_ptr_conv, val_conv);
49337 }
49338
49339 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) {
49340         LDKPublicKey src_node_id_arg_ref;
49341         CHECK((*env)->GetArrayLength(env, src_node_id_arg) == 33);
49342         (*env)->GetByteArrayRegion(env, src_node_id_arg, 0, 33, src_node_id_arg_ref.compressed_form);
49343         LDKRoutingFees fees_arg_conv;
49344         fees_arg_conv.inner = untag_ptr(fees_arg);
49345         fees_arg_conv.is_owned = ptr_is_owned(fees_arg);
49346         CHECK_INNER_FIELD_ACCESS_OR_NULL(fees_arg_conv);
49347         fees_arg_conv = RoutingFees_clone(&fees_arg_conv);
49348         void* htlc_minimum_msat_arg_ptr = untag_ptr(htlc_minimum_msat_arg);
49349         CHECK_ACCESS(htlc_minimum_msat_arg_ptr);
49350         LDKCOption_u64Z htlc_minimum_msat_arg_conv = *(LDKCOption_u64Z*)(htlc_minimum_msat_arg_ptr);
49351         htlc_minimum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(htlc_minimum_msat_arg));
49352         void* htlc_maximum_msat_arg_ptr = untag_ptr(htlc_maximum_msat_arg);
49353         CHECK_ACCESS(htlc_maximum_msat_arg_ptr);
49354         LDKCOption_u64Z htlc_maximum_msat_arg_conv = *(LDKCOption_u64Z*)(htlc_maximum_msat_arg_ptr);
49355         htlc_maximum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(htlc_maximum_msat_arg));
49356         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);
49357         int64_t ret_ref = 0;
49358         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49359         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49360         return ret_ref;
49361 }
49362
49363 static inline uint64_t RouteHintHop_clone_ptr(LDKRouteHintHop *NONNULL_PTR arg) {
49364         LDKRouteHintHop ret_var = RouteHintHop_clone(arg);
49365         int64_t ret_ref = 0;
49366         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49367         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49368         return ret_ref;
49369 }
49370 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
49371         LDKRouteHintHop arg_conv;
49372         arg_conv.inner = untag_ptr(arg);
49373         arg_conv.is_owned = ptr_is_owned(arg);
49374         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
49375         arg_conv.is_owned = false;
49376         int64_t ret_conv = RouteHintHop_clone_ptr(&arg_conv);
49377         return ret_conv;
49378 }
49379
49380 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1clone(JNIEnv *env, jclass clz, int64_t orig) {
49381         LDKRouteHintHop orig_conv;
49382         orig_conv.inner = untag_ptr(orig);
49383         orig_conv.is_owned = ptr_is_owned(orig);
49384         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
49385         orig_conv.is_owned = false;
49386         LDKRouteHintHop ret_var = RouteHintHop_clone(&orig_conv);
49387         int64_t ret_ref = 0;
49388         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49389         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49390         return ret_ref;
49391 }
49392
49393 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1hash(JNIEnv *env, jclass clz, int64_t o) {
49394         LDKRouteHintHop o_conv;
49395         o_conv.inner = untag_ptr(o);
49396         o_conv.is_owned = ptr_is_owned(o);
49397         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
49398         o_conv.is_owned = false;
49399         int64_t ret_conv = RouteHintHop_hash(&o_conv);
49400         return ret_conv;
49401 }
49402
49403 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
49404         LDKRouteHintHop a_conv;
49405         a_conv.inner = untag_ptr(a);
49406         a_conv.is_owned = ptr_is_owned(a);
49407         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
49408         a_conv.is_owned = false;
49409         LDKRouteHintHop b_conv;
49410         b_conv.inner = untag_ptr(b);
49411         b_conv.is_owned = ptr_is_owned(b);
49412         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
49413         b_conv.is_owned = false;
49414         jboolean ret_conv = RouteHintHop_eq(&a_conv, &b_conv);
49415         return ret_conv;
49416 }
49417
49418 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1write(JNIEnv *env, jclass clz, int64_t obj) {
49419         LDKRouteHintHop obj_conv;
49420         obj_conv.inner = untag_ptr(obj);
49421         obj_conv.is_owned = ptr_is_owned(obj);
49422         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
49423         obj_conv.is_owned = false;
49424         LDKCVec_u8Z ret_var = RouteHintHop_write(&obj_conv);
49425         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
49426         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
49427         CVec_u8Z_free(ret_var);
49428         return ret_arr;
49429 }
49430
49431 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
49432         LDKu8slice ser_ref;
49433         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
49434         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
49435         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
49436         *ret_conv = RouteHintHop_read(ser_ref);
49437         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
49438         return tag_ptr(ret_conv, true);
49439 }
49440
49441 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) {
49442         LDKPublicKey our_node_pubkey_ref;
49443         CHECK((*env)->GetArrayLength(env, our_node_pubkey) == 33);
49444         (*env)->GetByteArrayRegion(env, our_node_pubkey, 0, 33, our_node_pubkey_ref.compressed_form);
49445         LDKRouteParameters route_params_conv;
49446         route_params_conv.inner = untag_ptr(route_params);
49447         route_params_conv.is_owned = ptr_is_owned(route_params);
49448         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_params_conv);
49449         route_params_conv.is_owned = false;
49450         LDKNetworkGraph network_graph_conv;
49451         network_graph_conv.inner = untag_ptr(network_graph);
49452         network_graph_conv.is_owned = ptr_is_owned(network_graph);
49453         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
49454         network_graph_conv.is_owned = false;
49455         LDKCVec_ChannelDetailsZ first_hops_constr;
49456         LDKCVec_ChannelDetailsZ *first_hops_ptr = NULL;
49457         if (first_hops != NULL) {
49458                 first_hops_constr.datalen = (*env)->GetArrayLength(env, first_hops);
49459                 if (first_hops_constr.datalen > 0)
49460                         first_hops_constr.data = MALLOC(first_hops_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
49461                 else
49462                         first_hops_constr.data = NULL;
49463                 int64_t* first_hops_vals = (*env)->GetLongArrayElements (env, first_hops, NULL);
49464                 for (size_t q = 0; q < first_hops_constr.datalen; q++) {
49465                         int64_t first_hops_conv_16 = first_hops_vals[q];
49466                         LDKChannelDetails first_hops_conv_16_conv;
49467                         first_hops_conv_16_conv.inner = untag_ptr(first_hops_conv_16);
49468                         first_hops_conv_16_conv.is_owned = ptr_is_owned(first_hops_conv_16);
49469                         CHECK_INNER_FIELD_ACCESS_OR_NULL(first_hops_conv_16_conv);
49470                         first_hops_conv_16_conv.is_owned = false;
49471                         first_hops_constr.data[q] = first_hops_conv_16_conv;
49472                 }
49473                 (*env)->ReleaseLongArrayElements(env, first_hops, first_hops_vals, 0);
49474                 first_hops_ptr = &first_hops_constr;
49475         }
49476         void* logger_ptr = untag_ptr(logger);
49477         CHECK_ACCESS(logger_ptr);
49478         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
49479         if (logger_conv.free == LDKLogger_JCalls_free) {
49480                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
49481                 LDKLogger_JCalls_cloned(&logger_conv);
49482         }
49483         void* scorer_ptr = untag_ptr(scorer);
49484         if (ptr_is_owned(scorer)) { CHECK_ACCESS(scorer_ptr); }
49485         LDKScore* scorer_conv = (LDKScore*)scorer_ptr;
49486         unsigned char random_seed_bytes_arr[32];
49487         CHECK((*env)->GetArrayLength(env, random_seed_bytes) == 32);
49488         (*env)->GetByteArrayRegion(env, random_seed_bytes, 0, 32, random_seed_bytes_arr);
49489         unsigned char (*random_seed_bytes_ref)[32] = &random_seed_bytes_arr;
49490         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
49491         *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);
49492         if (first_hops_ptr != NULL) { FREE(first_hops_constr.data); }
49493         return tag_ptr(ret_conv, true);
49494 }
49495
49496 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) {
49497         LDKPublicKey our_node_pubkey_ref;
49498         CHECK((*env)->GetArrayLength(env, our_node_pubkey) == 33);
49499         (*env)->GetByteArrayRegion(env, our_node_pubkey, 0, 33, our_node_pubkey_ref.compressed_form);
49500         LDKCVec_PublicKeyZ hops_constr;
49501         hops_constr.datalen = (*env)->GetArrayLength(env, hops);
49502         if (hops_constr.datalen > 0)
49503                 hops_constr.data = MALLOC(hops_constr.datalen * sizeof(LDKPublicKey), "LDKCVec_PublicKeyZ Elements");
49504         else
49505                 hops_constr.data = NULL;
49506         for (size_t i = 0; i < hops_constr.datalen; i++) {
49507                 int8_tArray hops_conv_8 = (*env)->GetObjectArrayElement(env, hops, i);
49508                 LDKPublicKey hops_conv_8_ref;
49509                 CHECK((*env)->GetArrayLength(env, hops_conv_8) == 33);
49510                 (*env)->GetByteArrayRegion(env, hops_conv_8, 0, 33, hops_conv_8_ref.compressed_form);
49511                 hops_constr.data[i] = hops_conv_8_ref;
49512         }
49513         LDKRouteParameters route_params_conv;
49514         route_params_conv.inner = untag_ptr(route_params);
49515         route_params_conv.is_owned = ptr_is_owned(route_params);
49516         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_params_conv);
49517         route_params_conv.is_owned = false;
49518         LDKNetworkGraph network_graph_conv;
49519         network_graph_conv.inner = untag_ptr(network_graph);
49520         network_graph_conv.is_owned = ptr_is_owned(network_graph);
49521         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
49522         network_graph_conv.is_owned = false;
49523         void* logger_ptr = untag_ptr(logger);
49524         CHECK_ACCESS(logger_ptr);
49525         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
49526         if (logger_conv.free == LDKLogger_JCalls_free) {
49527                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
49528                 LDKLogger_JCalls_cloned(&logger_conv);
49529         }
49530         unsigned char random_seed_bytes_arr[32];
49531         CHECK((*env)->GetArrayLength(env, random_seed_bytes) == 32);
49532         (*env)->GetByteArrayRegion(env, random_seed_bytes, 0, 32, random_seed_bytes_arr);
49533         unsigned char (*random_seed_bytes_ref)[32] = &random_seed_bytes_arr;
49534         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
49535         *ret_conv = build_route_from_hops(our_node_pubkey_ref, hops_constr, &route_params_conv, &network_graph_conv, logger_conv, random_seed_bytes_ref);
49536         return tag_ptr(ret_conv, true);
49537 }
49538
49539 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Score_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
49540         if (!ptr_is_owned(this_ptr)) return;
49541         void* this_ptr_ptr = untag_ptr(this_ptr);
49542         CHECK_ACCESS(this_ptr_ptr);
49543         LDKScore this_ptr_conv = *(LDKScore*)(this_ptr_ptr);
49544         FREE(untag_ptr(this_ptr));
49545         Score_free(this_ptr_conv);
49546 }
49547
49548 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LockableScore_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
49549         if (!ptr_is_owned(this_ptr)) return;
49550         void* this_ptr_ptr = untag_ptr(this_ptr);
49551         CHECK_ACCESS(this_ptr_ptr);
49552         LDKLockableScore this_ptr_conv = *(LDKLockableScore*)(this_ptr_ptr);
49553         FREE(untag_ptr(this_ptr));
49554         LockableScore_free(this_ptr_conv);
49555 }
49556
49557 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WriteableScore_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
49558         if (!ptr_is_owned(this_ptr)) return;
49559         void* this_ptr_ptr = untag_ptr(this_ptr);
49560         CHECK_ACCESS(this_ptr_ptr);
49561         LDKWriteableScore this_ptr_conv = *(LDKWriteableScore*)(this_ptr_ptr);
49562         FREE(untag_ptr(this_ptr));
49563         WriteableScore_free(this_ptr_conv);
49564 }
49565
49566 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MultiThreadedLockableScore_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
49567         LDKMultiThreadedLockableScore this_obj_conv;
49568         this_obj_conv.inner = untag_ptr(this_obj);
49569         this_obj_conv.is_owned = ptr_is_owned(this_obj);
49570         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
49571         MultiThreadedLockableScore_free(this_obj_conv);
49572 }
49573
49574 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MultiThreadedScoreLock_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
49575         LDKMultiThreadedScoreLock this_obj_conv;
49576         this_obj_conv.inner = untag_ptr(this_obj);
49577         this_obj_conv.is_owned = ptr_is_owned(this_obj);
49578         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
49579         MultiThreadedScoreLock_free(this_obj_conv);
49580 }
49581
49582 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MultiThreadedScoreLock_1as_1Score(JNIEnv *env, jclass clz, int64_t this_arg) {
49583         LDKMultiThreadedScoreLock this_arg_conv;
49584         this_arg_conv.inner = untag_ptr(this_arg);
49585         this_arg_conv.is_owned = ptr_is_owned(this_arg);
49586         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
49587         this_arg_conv.is_owned = false;
49588         LDKScore* ret_ret = MALLOC(sizeof(LDKScore), "LDKScore");
49589         *ret_ret = MultiThreadedScoreLock_as_Score(&this_arg_conv);
49590         return tag_ptr(ret_ret, true);
49591 }
49592
49593 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_MultiThreadedScoreLock_1write(JNIEnv *env, jclass clz, int64_t obj) {
49594         LDKMultiThreadedScoreLock obj_conv;
49595         obj_conv.inner = untag_ptr(obj);
49596         obj_conv.is_owned = ptr_is_owned(obj);
49597         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
49598         obj_conv.is_owned = false;
49599         LDKCVec_u8Z ret_var = MultiThreadedScoreLock_write(&obj_conv);
49600         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
49601         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
49602         CVec_u8Z_free(ret_var);
49603         return ret_arr;
49604 }
49605
49606 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MultiThreadedLockableScore_1as_1LockableScore(JNIEnv *env, jclass clz, int64_t this_arg) {
49607         LDKMultiThreadedLockableScore this_arg_conv;
49608         this_arg_conv.inner = untag_ptr(this_arg);
49609         this_arg_conv.is_owned = ptr_is_owned(this_arg);
49610         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
49611         this_arg_conv.is_owned = false;
49612         LDKLockableScore* ret_ret = MALLOC(sizeof(LDKLockableScore), "LDKLockableScore");
49613         *ret_ret = MultiThreadedLockableScore_as_LockableScore(&this_arg_conv);
49614         return tag_ptr(ret_ret, true);
49615 }
49616
49617 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_MultiThreadedLockableScore_1write(JNIEnv *env, jclass clz, int64_t obj) {
49618         LDKMultiThreadedLockableScore obj_conv;
49619         obj_conv.inner = untag_ptr(obj);
49620         obj_conv.is_owned = ptr_is_owned(obj);
49621         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
49622         obj_conv.is_owned = false;
49623         LDKCVec_u8Z ret_var = MultiThreadedLockableScore_write(&obj_conv);
49624         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
49625         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
49626         CVec_u8Z_free(ret_var);
49627         return ret_arr;
49628 }
49629
49630 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MultiThreadedLockableScore_1as_1WriteableScore(JNIEnv *env, jclass clz, int64_t this_arg) {
49631         LDKMultiThreadedLockableScore this_arg_conv;
49632         this_arg_conv.inner = untag_ptr(this_arg);
49633         this_arg_conv.is_owned = ptr_is_owned(this_arg);
49634         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
49635         this_arg_conv.is_owned = false;
49636         LDKWriteableScore* ret_ret = MALLOC(sizeof(LDKWriteableScore), "LDKWriteableScore");
49637         *ret_ret = MultiThreadedLockableScore_as_WriteableScore(&this_arg_conv);
49638         return tag_ptr(ret_ret, true);
49639 }
49640
49641 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MultiThreadedLockableScore_1new(JNIEnv *env, jclass clz, int64_t score) {
49642         void* score_ptr = untag_ptr(score);
49643         CHECK_ACCESS(score_ptr);
49644         LDKScore score_conv = *(LDKScore*)(score_ptr);
49645         if (score_conv.free == LDKScore_JCalls_free) {
49646                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
49647                 LDKScore_JCalls_cloned(&score_conv);
49648         }
49649         LDKMultiThreadedLockableScore ret_var = MultiThreadedLockableScore_new(score_conv);
49650         int64_t ret_ref = 0;
49651         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49652         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49653         return ret_ref;
49654 }
49655
49656 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUsage_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
49657         LDKChannelUsage this_obj_conv;
49658         this_obj_conv.inner = untag_ptr(this_obj);
49659         this_obj_conv.is_owned = ptr_is_owned(this_obj);
49660         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
49661         ChannelUsage_free(this_obj_conv);
49662 }
49663
49664 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUsage_1get_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
49665         LDKChannelUsage this_ptr_conv;
49666         this_ptr_conv.inner = untag_ptr(this_ptr);
49667         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49668         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49669         this_ptr_conv.is_owned = false;
49670         int64_t ret_conv = ChannelUsage_get_amount_msat(&this_ptr_conv);
49671         return ret_conv;
49672 }
49673
49674 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUsage_1set_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
49675         LDKChannelUsage this_ptr_conv;
49676         this_ptr_conv.inner = untag_ptr(this_ptr);
49677         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49678         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49679         this_ptr_conv.is_owned = false;
49680         ChannelUsage_set_amount_msat(&this_ptr_conv, val);
49681 }
49682
49683 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUsage_1get_1inflight_1htlc_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
49684         LDKChannelUsage this_ptr_conv;
49685         this_ptr_conv.inner = untag_ptr(this_ptr);
49686         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49687         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49688         this_ptr_conv.is_owned = false;
49689         int64_t ret_conv = ChannelUsage_get_inflight_htlc_msat(&this_ptr_conv);
49690         return ret_conv;
49691 }
49692
49693 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUsage_1set_1inflight_1htlc_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
49694         LDKChannelUsage this_ptr_conv;
49695         this_ptr_conv.inner = untag_ptr(this_ptr);
49696         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49697         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49698         this_ptr_conv.is_owned = false;
49699         ChannelUsage_set_inflight_htlc_msat(&this_ptr_conv, val);
49700 }
49701
49702 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUsage_1get_1effective_1capacity(JNIEnv *env, jclass clz, int64_t this_ptr) {
49703         LDKChannelUsage this_ptr_conv;
49704         this_ptr_conv.inner = untag_ptr(this_ptr);
49705         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49706         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49707         this_ptr_conv.is_owned = false;
49708         LDKEffectiveCapacity *ret_copy = MALLOC(sizeof(LDKEffectiveCapacity), "LDKEffectiveCapacity");
49709         *ret_copy = ChannelUsage_get_effective_capacity(&this_ptr_conv);
49710         int64_t ret_ref = tag_ptr(ret_copy, true);
49711         return ret_ref;
49712 }
49713
49714 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUsage_1set_1effective_1capacity(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
49715         LDKChannelUsage this_ptr_conv;
49716         this_ptr_conv.inner = untag_ptr(this_ptr);
49717         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49718         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49719         this_ptr_conv.is_owned = false;
49720         void* val_ptr = untag_ptr(val);
49721         CHECK_ACCESS(val_ptr);
49722         LDKEffectiveCapacity val_conv = *(LDKEffectiveCapacity*)(val_ptr);
49723         val_conv = EffectiveCapacity_clone((LDKEffectiveCapacity*)untag_ptr(val));
49724         ChannelUsage_set_effective_capacity(&this_ptr_conv, val_conv);
49725 }
49726
49727 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) {
49728         void* effective_capacity_arg_ptr = untag_ptr(effective_capacity_arg);
49729         CHECK_ACCESS(effective_capacity_arg_ptr);
49730         LDKEffectiveCapacity effective_capacity_arg_conv = *(LDKEffectiveCapacity*)(effective_capacity_arg_ptr);
49731         effective_capacity_arg_conv = EffectiveCapacity_clone((LDKEffectiveCapacity*)untag_ptr(effective_capacity_arg));
49732         LDKChannelUsage ret_var = ChannelUsage_new(amount_msat_arg, inflight_htlc_msat_arg, effective_capacity_arg_conv);
49733         int64_t ret_ref = 0;
49734         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49735         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49736         return ret_ref;
49737 }
49738
49739 static inline uint64_t ChannelUsage_clone_ptr(LDKChannelUsage *NONNULL_PTR arg) {
49740         LDKChannelUsage ret_var = ChannelUsage_clone(arg);
49741         int64_t ret_ref = 0;
49742         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49743         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49744         return ret_ref;
49745 }
49746 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUsage_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
49747         LDKChannelUsage arg_conv;
49748         arg_conv.inner = untag_ptr(arg);
49749         arg_conv.is_owned = ptr_is_owned(arg);
49750         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
49751         arg_conv.is_owned = false;
49752         int64_t ret_conv = ChannelUsage_clone_ptr(&arg_conv);
49753         return ret_conv;
49754 }
49755
49756 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUsage_1clone(JNIEnv *env, jclass clz, int64_t orig) {
49757         LDKChannelUsage orig_conv;
49758         orig_conv.inner = untag_ptr(orig);
49759         orig_conv.is_owned = ptr_is_owned(orig);
49760         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
49761         orig_conv.is_owned = false;
49762         LDKChannelUsage ret_var = ChannelUsage_clone(&orig_conv);
49763         int64_t ret_ref = 0;
49764         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49765         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49766         return ret_ref;
49767 }
49768
49769 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FixedPenaltyScorer_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
49770         LDKFixedPenaltyScorer this_obj_conv;
49771         this_obj_conv.inner = untag_ptr(this_obj);
49772         this_obj_conv.is_owned = ptr_is_owned(this_obj);
49773         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
49774         FixedPenaltyScorer_free(this_obj_conv);
49775 }
49776
49777 static inline uint64_t FixedPenaltyScorer_clone_ptr(LDKFixedPenaltyScorer *NONNULL_PTR arg) {
49778         LDKFixedPenaltyScorer ret_var = FixedPenaltyScorer_clone(arg);
49779         int64_t ret_ref = 0;
49780         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49781         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49782         return ret_ref;
49783 }
49784 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FixedPenaltyScorer_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
49785         LDKFixedPenaltyScorer arg_conv;
49786         arg_conv.inner = untag_ptr(arg);
49787         arg_conv.is_owned = ptr_is_owned(arg);
49788         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
49789         arg_conv.is_owned = false;
49790         int64_t ret_conv = FixedPenaltyScorer_clone_ptr(&arg_conv);
49791         return ret_conv;
49792 }
49793
49794 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FixedPenaltyScorer_1clone(JNIEnv *env, jclass clz, int64_t orig) {
49795         LDKFixedPenaltyScorer orig_conv;
49796         orig_conv.inner = untag_ptr(orig);
49797         orig_conv.is_owned = ptr_is_owned(orig);
49798         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
49799         orig_conv.is_owned = false;
49800         LDKFixedPenaltyScorer ret_var = FixedPenaltyScorer_clone(&orig_conv);
49801         int64_t ret_ref = 0;
49802         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49803         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49804         return ret_ref;
49805 }
49806
49807 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FixedPenaltyScorer_1with_1penalty(JNIEnv *env, jclass clz, int64_t penalty_msat) {
49808         LDKFixedPenaltyScorer ret_var = FixedPenaltyScorer_with_penalty(penalty_msat);
49809         int64_t ret_ref = 0;
49810         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
49811         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
49812         return ret_ref;
49813 }
49814
49815 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FixedPenaltyScorer_1as_1Score(JNIEnv *env, jclass clz, int64_t this_arg) {
49816         LDKFixedPenaltyScorer this_arg_conv;
49817         this_arg_conv.inner = untag_ptr(this_arg);
49818         this_arg_conv.is_owned = ptr_is_owned(this_arg);
49819         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
49820         this_arg_conv.is_owned = false;
49821         LDKScore* ret_ret = MALLOC(sizeof(LDKScore), "LDKScore");
49822         *ret_ret = FixedPenaltyScorer_as_Score(&this_arg_conv);
49823         return tag_ptr(ret_ret, true);
49824 }
49825
49826 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FixedPenaltyScorer_1write(JNIEnv *env, jclass clz, int64_t obj) {
49827         LDKFixedPenaltyScorer obj_conv;
49828         obj_conv.inner = untag_ptr(obj);
49829         obj_conv.is_owned = ptr_is_owned(obj);
49830         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
49831         obj_conv.is_owned = false;
49832         LDKCVec_u8Z ret_var = FixedPenaltyScorer_write(&obj_conv);
49833         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
49834         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
49835         CVec_u8Z_free(ret_var);
49836         return ret_arr;
49837 }
49838
49839 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FixedPenaltyScorer_1read(JNIEnv *env, jclass clz, int8_tArray ser, int64_t arg) {
49840         LDKu8slice ser_ref;
49841         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
49842         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
49843         LDKCResult_FixedPenaltyScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FixedPenaltyScorerDecodeErrorZ), "LDKCResult_FixedPenaltyScorerDecodeErrorZ");
49844         *ret_conv = FixedPenaltyScorer_read(ser_ref, arg);
49845         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
49846         return tag_ptr(ret_conv, true);
49847 }
49848
49849 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ProbabilisticScorer_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
49850         LDKProbabilisticScorer this_obj_conv;
49851         this_obj_conv.inner = untag_ptr(this_obj);
49852         this_obj_conv.is_owned = ptr_is_owned(this_obj);
49853         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
49854         ProbabilisticScorer_free(this_obj_conv);
49855 }
49856
49857 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
49858         LDKProbabilisticScoringParameters this_obj_conv;
49859         this_obj_conv.inner = untag_ptr(this_obj);
49860         this_obj_conv.is_owned = ptr_is_owned(this_obj);
49861         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
49862         ProbabilisticScoringParameters_free(this_obj_conv);
49863 }
49864
49865 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1get_1base_1penalty_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
49866         LDKProbabilisticScoringParameters this_ptr_conv;
49867         this_ptr_conv.inner = untag_ptr(this_ptr);
49868         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49869         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49870         this_ptr_conv.is_owned = false;
49871         int64_t ret_conv = ProbabilisticScoringParameters_get_base_penalty_msat(&this_ptr_conv);
49872         return ret_conv;
49873 }
49874
49875 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1set_1base_1penalty_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
49876         LDKProbabilisticScoringParameters this_ptr_conv;
49877         this_ptr_conv.inner = untag_ptr(this_ptr);
49878         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49879         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49880         this_ptr_conv.is_owned = false;
49881         ProbabilisticScoringParameters_set_base_penalty_msat(&this_ptr_conv, val);
49882 }
49883
49884 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1get_1base_1penalty_1amount_1multiplier_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
49885         LDKProbabilisticScoringParameters this_ptr_conv;
49886         this_ptr_conv.inner = untag_ptr(this_ptr);
49887         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49888         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49889         this_ptr_conv.is_owned = false;
49890         int64_t ret_conv = ProbabilisticScoringParameters_get_base_penalty_amount_multiplier_msat(&this_ptr_conv);
49891         return ret_conv;
49892 }
49893
49894 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) {
49895         LDKProbabilisticScoringParameters this_ptr_conv;
49896         this_ptr_conv.inner = untag_ptr(this_ptr);
49897         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49898         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49899         this_ptr_conv.is_owned = false;
49900         ProbabilisticScoringParameters_set_base_penalty_amount_multiplier_msat(&this_ptr_conv, val);
49901 }
49902
49903 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1get_1liquidity_1penalty_1multiplier_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
49904         LDKProbabilisticScoringParameters this_ptr_conv;
49905         this_ptr_conv.inner = untag_ptr(this_ptr);
49906         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49907         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49908         this_ptr_conv.is_owned = false;
49909         int64_t ret_conv = ProbabilisticScoringParameters_get_liquidity_penalty_multiplier_msat(&this_ptr_conv);
49910         return ret_conv;
49911 }
49912
49913 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) {
49914         LDKProbabilisticScoringParameters this_ptr_conv;
49915         this_ptr_conv.inner = untag_ptr(this_ptr);
49916         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49917         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49918         this_ptr_conv.is_owned = false;
49919         ProbabilisticScoringParameters_set_liquidity_penalty_multiplier_msat(&this_ptr_conv, val);
49920 }
49921
49922 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1get_1liquidity_1offset_1half_1life(JNIEnv *env, jclass clz, int64_t this_ptr) {
49923         LDKProbabilisticScoringParameters this_ptr_conv;
49924         this_ptr_conv.inner = untag_ptr(this_ptr);
49925         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49926         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49927         this_ptr_conv.is_owned = false;
49928         int64_t ret_conv = ProbabilisticScoringParameters_get_liquidity_offset_half_life(&this_ptr_conv);
49929         return ret_conv;
49930 }
49931
49932 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) {
49933         LDKProbabilisticScoringParameters this_ptr_conv;
49934         this_ptr_conv.inner = untag_ptr(this_ptr);
49935         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49936         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49937         this_ptr_conv.is_owned = false;
49938         ProbabilisticScoringParameters_set_liquidity_offset_half_life(&this_ptr_conv, val);
49939 }
49940
49941 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1get_1liquidity_1penalty_1amount_1multiplier_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
49942         LDKProbabilisticScoringParameters this_ptr_conv;
49943         this_ptr_conv.inner = untag_ptr(this_ptr);
49944         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49945         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49946         this_ptr_conv.is_owned = false;
49947         int64_t ret_conv = ProbabilisticScoringParameters_get_liquidity_penalty_amount_multiplier_msat(&this_ptr_conv);
49948         return ret_conv;
49949 }
49950
49951 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) {
49952         LDKProbabilisticScoringParameters this_ptr_conv;
49953         this_ptr_conv.inner = untag_ptr(this_ptr);
49954         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49955         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49956         this_ptr_conv.is_owned = false;
49957         ProbabilisticScoringParameters_set_liquidity_penalty_amount_multiplier_msat(&this_ptr_conv, val);
49958 }
49959
49960 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1get_1historical_1liquidity_1penalty_1multiplier_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
49961         LDKProbabilisticScoringParameters this_ptr_conv;
49962         this_ptr_conv.inner = untag_ptr(this_ptr);
49963         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49964         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49965         this_ptr_conv.is_owned = false;
49966         int64_t ret_conv = ProbabilisticScoringParameters_get_historical_liquidity_penalty_multiplier_msat(&this_ptr_conv);
49967         return ret_conv;
49968 }
49969
49970 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) {
49971         LDKProbabilisticScoringParameters this_ptr_conv;
49972         this_ptr_conv.inner = untag_ptr(this_ptr);
49973         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49974         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49975         this_ptr_conv.is_owned = false;
49976         ProbabilisticScoringParameters_set_historical_liquidity_penalty_multiplier_msat(&this_ptr_conv, val);
49977 }
49978
49979 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) {
49980         LDKProbabilisticScoringParameters this_ptr_conv;
49981         this_ptr_conv.inner = untag_ptr(this_ptr);
49982         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49983         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49984         this_ptr_conv.is_owned = false;
49985         int64_t ret_conv = ProbabilisticScoringParameters_get_historical_liquidity_penalty_amount_multiplier_msat(&this_ptr_conv);
49986         return ret_conv;
49987 }
49988
49989 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) {
49990         LDKProbabilisticScoringParameters this_ptr_conv;
49991         this_ptr_conv.inner = untag_ptr(this_ptr);
49992         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
49993         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
49994         this_ptr_conv.is_owned = false;
49995         ProbabilisticScoringParameters_set_historical_liquidity_penalty_amount_multiplier_msat(&this_ptr_conv, val);
49996 }
49997
49998 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1get_1historical_1no_1updates_1half_1life(JNIEnv *env, jclass clz, int64_t this_ptr) {
49999         LDKProbabilisticScoringParameters this_ptr_conv;
50000         this_ptr_conv.inner = untag_ptr(this_ptr);
50001         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
50002         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
50003         this_ptr_conv.is_owned = false;
50004         int64_t ret_conv = ProbabilisticScoringParameters_get_historical_no_updates_half_life(&this_ptr_conv);
50005         return ret_conv;
50006 }
50007
50008 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) {
50009         LDKProbabilisticScoringParameters this_ptr_conv;
50010         this_ptr_conv.inner = untag_ptr(this_ptr);
50011         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
50012         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
50013         this_ptr_conv.is_owned = false;
50014         ProbabilisticScoringParameters_set_historical_no_updates_half_life(&this_ptr_conv, val);
50015 }
50016
50017 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1get_1anti_1probing_1penalty_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
50018         LDKProbabilisticScoringParameters this_ptr_conv;
50019         this_ptr_conv.inner = untag_ptr(this_ptr);
50020         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
50021         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
50022         this_ptr_conv.is_owned = false;
50023         int64_t ret_conv = ProbabilisticScoringParameters_get_anti_probing_penalty_msat(&this_ptr_conv);
50024         return ret_conv;
50025 }
50026
50027 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) {
50028         LDKProbabilisticScoringParameters this_ptr_conv;
50029         this_ptr_conv.inner = untag_ptr(this_ptr);
50030         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
50031         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
50032         this_ptr_conv.is_owned = false;
50033         ProbabilisticScoringParameters_set_anti_probing_penalty_msat(&this_ptr_conv, val);
50034 }
50035
50036 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1get_1considered_1impossible_1penalty_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
50037         LDKProbabilisticScoringParameters this_ptr_conv;
50038         this_ptr_conv.inner = untag_ptr(this_ptr);
50039         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
50040         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
50041         this_ptr_conv.is_owned = false;
50042         int64_t ret_conv = ProbabilisticScoringParameters_get_considered_impossible_penalty_msat(&this_ptr_conv);
50043         return ret_conv;
50044 }
50045
50046 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) {
50047         LDKProbabilisticScoringParameters this_ptr_conv;
50048         this_ptr_conv.inner = untag_ptr(this_ptr);
50049         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
50050         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
50051         this_ptr_conv.is_owned = false;
50052         ProbabilisticScoringParameters_set_considered_impossible_penalty_msat(&this_ptr_conv, val);
50053 }
50054
50055 static inline uint64_t ProbabilisticScoringParameters_clone_ptr(LDKProbabilisticScoringParameters *NONNULL_PTR arg) {
50056         LDKProbabilisticScoringParameters ret_var = ProbabilisticScoringParameters_clone(arg);
50057         int64_t ret_ref = 0;
50058         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
50059         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
50060         return ret_ref;
50061 }
50062 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
50063         LDKProbabilisticScoringParameters arg_conv;
50064         arg_conv.inner = untag_ptr(arg);
50065         arg_conv.is_owned = ptr_is_owned(arg);
50066         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
50067         arg_conv.is_owned = false;
50068         int64_t ret_conv = ProbabilisticScoringParameters_clone_ptr(&arg_conv);
50069         return ret_conv;
50070 }
50071
50072 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1clone(JNIEnv *env, jclass clz, int64_t orig) {
50073         LDKProbabilisticScoringParameters orig_conv;
50074         orig_conv.inner = untag_ptr(orig);
50075         orig_conv.is_owned = ptr_is_owned(orig);
50076         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
50077         orig_conv.is_owned = false;
50078         LDKProbabilisticScoringParameters ret_var = ProbabilisticScoringParameters_clone(&orig_conv);
50079         int64_t ret_ref = 0;
50080         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
50081         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
50082         return ret_ref;
50083 }
50084
50085 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScorer_1new(JNIEnv *env, jclass clz, int64_t params, int64_t network_graph, int64_t logger) {
50086         LDKProbabilisticScoringParameters params_conv;
50087         params_conv.inner = untag_ptr(params);
50088         params_conv.is_owned = ptr_is_owned(params);
50089         CHECK_INNER_FIELD_ACCESS_OR_NULL(params_conv);
50090         params_conv = ProbabilisticScoringParameters_clone(&params_conv);
50091         LDKNetworkGraph network_graph_conv;
50092         network_graph_conv.inner = untag_ptr(network_graph);
50093         network_graph_conv.is_owned = ptr_is_owned(network_graph);
50094         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
50095         network_graph_conv.is_owned = false;
50096         void* logger_ptr = untag_ptr(logger);
50097         CHECK_ACCESS(logger_ptr);
50098         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
50099         if (logger_conv.free == LDKLogger_JCalls_free) {
50100                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
50101                 LDKLogger_JCalls_cloned(&logger_conv);
50102         }
50103         LDKProbabilisticScorer ret_var = ProbabilisticScorer_new(params_conv, &network_graph_conv, logger_conv);
50104         int64_t ret_ref = 0;
50105         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
50106         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
50107         return ret_ref;
50108 }
50109
50110 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ProbabilisticScorer_1debug_1log_1liquidity_1stats(JNIEnv *env, jclass clz, int64_t this_arg) {
50111         LDKProbabilisticScorer this_arg_conv;
50112         this_arg_conv.inner = untag_ptr(this_arg);
50113         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50114         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50115         this_arg_conv.is_owned = false;
50116         ProbabilisticScorer_debug_log_liquidity_stats(&this_arg_conv);
50117 }
50118
50119 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) {
50120         LDKProbabilisticScorer this_arg_conv;
50121         this_arg_conv.inner = untag_ptr(this_arg);
50122         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50123         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50124         this_arg_conv.is_owned = false;
50125         LDKNodeId target_conv;
50126         target_conv.inner = untag_ptr(target);
50127         target_conv.is_owned = ptr_is_owned(target);
50128         CHECK_INNER_FIELD_ACCESS_OR_NULL(target_conv);
50129         target_conv.is_owned = false;
50130         LDKCOption_C2Tuple_u64u64ZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_u64u64ZZ), "LDKCOption_C2Tuple_u64u64ZZ");
50131         *ret_copy = ProbabilisticScorer_estimated_channel_liquidity_range(&this_arg_conv, scid, &target_conv);
50132         int64_t ret_ref = tag_ptr(ret_copy, true);
50133         return ret_ref;
50134 }
50135
50136 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ProbabilisticScorer_1add_1banned(JNIEnv *env, jclass clz, int64_t this_arg, int64_t node_id) {
50137         LDKProbabilisticScorer this_arg_conv;
50138         this_arg_conv.inner = untag_ptr(this_arg);
50139         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50140         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50141         this_arg_conv.is_owned = false;
50142         LDKNodeId node_id_conv;
50143         node_id_conv.inner = untag_ptr(node_id);
50144         node_id_conv.is_owned = ptr_is_owned(node_id);
50145         CHECK_INNER_FIELD_ACCESS_OR_NULL(node_id_conv);
50146         node_id_conv.is_owned = false;
50147         ProbabilisticScorer_add_banned(&this_arg_conv, &node_id_conv);
50148 }
50149
50150 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ProbabilisticScorer_1remove_1banned(JNIEnv *env, jclass clz, int64_t this_arg, int64_t node_id) {
50151         LDKProbabilisticScorer this_arg_conv;
50152         this_arg_conv.inner = untag_ptr(this_arg);
50153         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50154         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50155         this_arg_conv.is_owned = false;
50156         LDKNodeId node_id_conv;
50157         node_id_conv.inner = untag_ptr(node_id);
50158         node_id_conv.is_owned = ptr_is_owned(node_id);
50159         CHECK_INNER_FIELD_ACCESS_OR_NULL(node_id_conv);
50160         node_id_conv.is_owned = false;
50161         ProbabilisticScorer_remove_banned(&this_arg_conv, &node_id_conv);
50162 }
50163
50164 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) {
50165         LDKProbabilisticScorer this_arg_conv;
50166         this_arg_conv.inner = untag_ptr(this_arg);
50167         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50168         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50169         this_arg_conv.is_owned = false;
50170         LDKNodeId node_id_conv;
50171         node_id_conv.inner = untag_ptr(node_id);
50172         node_id_conv.is_owned = ptr_is_owned(node_id);
50173         CHECK_INNER_FIELD_ACCESS_OR_NULL(node_id_conv);
50174         node_id_conv.is_owned = false;
50175         ProbabilisticScorer_set_manual_penalty(&this_arg_conv, &node_id_conv, penalty);
50176 }
50177
50178 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ProbabilisticScorer_1remove_1manual_1penalty(JNIEnv *env, jclass clz, int64_t this_arg, int64_t node_id) {
50179         LDKProbabilisticScorer this_arg_conv;
50180         this_arg_conv.inner = untag_ptr(this_arg);
50181         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50182         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50183         this_arg_conv.is_owned = false;
50184         LDKNodeId node_id_conv;
50185         node_id_conv.inner = untag_ptr(node_id);
50186         node_id_conv.is_owned = ptr_is_owned(node_id);
50187         CHECK_INNER_FIELD_ACCESS_OR_NULL(node_id_conv);
50188         node_id_conv.is_owned = false;
50189         ProbabilisticScorer_remove_manual_penalty(&this_arg_conv, &node_id_conv);
50190 }
50191
50192 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ProbabilisticScorer_1clear_1manual_1penalties(JNIEnv *env, jclass clz, int64_t this_arg) {
50193         LDKProbabilisticScorer this_arg_conv;
50194         this_arg_conv.inner = untag_ptr(this_arg);
50195         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50196         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50197         this_arg_conv.is_owned = false;
50198         ProbabilisticScorer_clear_manual_penalties(&this_arg_conv);
50199 }
50200
50201 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) {
50202         LDKProbabilisticScoringParameters this_arg_conv;
50203         this_arg_conv.inner = untag_ptr(this_arg);
50204         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50205         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50206         this_arg_conv.is_owned = false;
50207         LDKCVec_NodeIdZ node_ids_constr;
50208         node_ids_constr.datalen = (*env)->GetArrayLength(env, node_ids);
50209         if (node_ids_constr.datalen > 0)
50210                 node_ids_constr.data = MALLOC(node_ids_constr.datalen * sizeof(LDKNodeId), "LDKCVec_NodeIdZ Elements");
50211         else
50212                 node_ids_constr.data = NULL;
50213         int64_t* node_ids_vals = (*env)->GetLongArrayElements (env, node_ids, NULL);
50214         for (size_t i = 0; i < node_ids_constr.datalen; i++) {
50215                 int64_t node_ids_conv_8 = node_ids_vals[i];
50216                 LDKNodeId node_ids_conv_8_conv;
50217                 node_ids_conv_8_conv.inner = untag_ptr(node_ids_conv_8);
50218                 node_ids_conv_8_conv.is_owned = ptr_is_owned(node_ids_conv_8);
50219                 CHECK_INNER_FIELD_ACCESS_OR_NULL(node_ids_conv_8_conv);
50220                 node_ids_conv_8_conv = NodeId_clone(&node_ids_conv_8_conv);
50221                 node_ids_constr.data[i] = node_ids_conv_8_conv;
50222         }
50223         (*env)->ReleaseLongArrayElements(env, node_ids, node_ids_vals, 0);
50224         ProbabilisticScoringParameters_add_banned_from_list(&this_arg_conv, node_ids_constr);
50225 }
50226
50227 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScoringParameters_1default(JNIEnv *env, jclass clz) {
50228         LDKProbabilisticScoringParameters ret_var = ProbabilisticScoringParameters_default();
50229         int64_t ret_ref = 0;
50230         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
50231         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
50232         return ret_ref;
50233 }
50234
50235 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ProbabilisticScorer_1as_1Score(JNIEnv *env, jclass clz, int64_t this_arg) {
50236         LDKProbabilisticScorer this_arg_conv;
50237         this_arg_conv.inner = untag_ptr(this_arg);
50238         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50239         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50240         this_arg_conv.is_owned = false;
50241         LDKScore* ret_ret = MALLOC(sizeof(LDKScore), "LDKScore");
50242         *ret_ret = ProbabilisticScorer_as_Score(&this_arg_conv);
50243         return tag_ptr(ret_ret, true);
50244 }
50245
50246 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ProbabilisticScorer_1write(JNIEnv *env, jclass clz, int64_t obj) {
50247         LDKProbabilisticScorer obj_conv;
50248         obj_conv.inner = untag_ptr(obj);
50249         obj_conv.is_owned = ptr_is_owned(obj);
50250         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
50251         obj_conv.is_owned = false;
50252         LDKCVec_u8Z ret_var = ProbabilisticScorer_write(&obj_conv);
50253         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
50254         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
50255         CVec_u8Z_free(ret_var);
50256         return ret_arr;
50257 }
50258
50259 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) {
50260         LDKu8slice ser_ref;
50261         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
50262         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
50263         LDKProbabilisticScoringParameters arg_a_conv;
50264         arg_a_conv.inner = untag_ptr(arg_a);
50265         arg_a_conv.is_owned = ptr_is_owned(arg_a);
50266         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_a_conv);
50267         arg_a_conv = ProbabilisticScoringParameters_clone(&arg_a_conv);
50268         LDKNetworkGraph arg_b_conv;
50269         arg_b_conv.inner = untag_ptr(arg_b);
50270         arg_b_conv.is_owned = ptr_is_owned(arg_b);
50271         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_b_conv);
50272         arg_b_conv.is_owned = false;
50273         void* arg_c_ptr = untag_ptr(arg_c);
50274         CHECK_ACCESS(arg_c_ptr);
50275         LDKLogger arg_c_conv = *(LDKLogger*)(arg_c_ptr);
50276         if (arg_c_conv.free == LDKLogger_JCalls_free) {
50277                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
50278                 LDKLogger_JCalls_cloned(&arg_c_conv);
50279         }
50280         LDKCResult_ProbabilisticScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ProbabilisticScorerDecodeErrorZ), "LDKCResult_ProbabilisticScorerDecodeErrorZ");
50281         *ret_conv = ProbabilisticScorer_read(ser_ref, arg_a_conv, &arg_b_conv, arg_c_conv);
50282         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
50283         return tag_ptr(ret_conv, true);
50284 }
50285
50286 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BlindedPath_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
50287         LDKBlindedPath this_obj_conv;
50288         this_obj_conv.inner = untag_ptr(this_obj);
50289         this_obj_conv.is_owned = ptr_is_owned(this_obj);
50290         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
50291         BlindedPath_free(this_obj_conv);
50292 }
50293
50294 static inline uint64_t BlindedPath_clone_ptr(LDKBlindedPath *NONNULL_PTR arg) {
50295         LDKBlindedPath ret_var = BlindedPath_clone(arg);
50296         int64_t ret_ref = 0;
50297         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
50298         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
50299         return ret_ref;
50300 }
50301 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BlindedPath_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
50302         LDKBlindedPath arg_conv;
50303         arg_conv.inner = untag_ptr(arg);
50304         arg_conv.is_owned = ptr_is_owned(arg);
50305         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
50306         arg_conv.is_owned = false;
50307         int64_t ret_conv = BlindedPath_clone_ptr(&arg_conv);
50308         return ret_conv;
50309 }
50310
50311 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BlindedPath_1clone(JNIEnv *env, jclass clz, int64_t orig) {
50312         LDKBlindedPath orig_conv;
50313         orig_conv.inner = untag_ptr(orig);
50314         orig_conv.is_owned = ptr_is_owned(orig);
50315         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
50316         orig_conv.is_owned = false;
50317         LDKBlindedPath ret_var = BlindedPath_clone(&orig_conv);
50318         int64_t ret_ref = 0;
50319         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
50320         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
50321         return ret_ref;
50322 }
50323
50324 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BlindedHop_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
50325         LDKBlindedHop this_obj_conv;
50326         this_obj_conv.inner = untag_ptr(this_obj);
50327         this_obj_conv.is_owned = ptr_is_owned(this_obj);
50328         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
50329         BlindedHop_free(this_obj_conv);
50330 }
50331
50332 static inline uint64_t BlindedHop_clone_ptr(LDKBlindedHop *NONNULL_PTR arg) {
50333         LDKBlindedHop ret_var = BlindedHop_clone(arg);
50334         int64_t ret_ref = 0;
50335         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
50336         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
50337         return ret_ref;
50338 }
50339 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BlindedHop_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
50340         LDKBlindedHop arg_conv;
50341         arg_conv.inner = untag_ptr(arg);
50342         arg_conv.is_owned = ptr_is_owned(arg);
50343         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
50344         arg_conv.is_owned = false;
50345         int64_t ret_conv = BlindedHop_clone_ptr(&arg_conv);
50346         return ret_conv;
50347 }
50348
50349 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BlindedHop_1clone(JNIEnv *env, jclass clz, int64_t orig) {
50350         LDKBlindedHop orig_conv;
50351         orig_conv.inner = untag_ptr(orig);
50352         orig_conv.is_owned = ptr_is_owned(orig);
50353         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
50354         orig_conv.is_owned = false;
50355         LDKBlindedHop ret_var = BlindedHop_clone(&orig_conv);
50356         int64_t ret_ref = 0;
50357         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
50358         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
50359         return ret_ref;
50360 }
50361
50362 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BlindedPath_1new(JNIEnv *env, jclass clz, jobjectArray node_pks, int64_t keys_manager) {
50363         LDKCVec_PublicKeyZ node_pks_constr;
50364         node_pks_constr.datalen = (*env)->GetArrayLength(env, node_pks);
50365         if (node_pks_constr.datalen > 0)
50366                 node_pks_constr.data = MALLOC(node_pks_constr.datalen * sizeof(LDKPublicKey), "LDKCVec_PublicKeyZ Elements");
50367         else
50368                 node_pks_constr.data = NULL;
50369         for (size_t i = 0; i < node_pks_constr.datalen; i++) {
50370                 int8_tArray node_pks_conv_8 = (*env)->GetObjectArrayElement(env, node_pks, i);
50371                 LDKPublicKey node_pks_conv_8_ref;
50372                 CHECK((*env)->GetArrayLength(env, node_pks_conv_8) == 33);
50373                 (*env)->GetByteArrayRegion(env, node_pks_conv_8, 0, 33, node_pks_conv_8_ref.compressed_form);
50374                 node_pks_constr.data[i] = node_pks_conv_8_ref;
50375         }
50376         void* keys_manager_ptr = untag_ptr(keys_manager);
50377         if (ptr_is_owned(keys_manager)) { CHECK_ACCESS(keys_manager_ptr); }
50378         LDKKeysInterface* keys_manager_conv = (LDKKeysInterface*)keys_manager_ptr;
50379         LDKCResult_BlindedPathNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedPathNoneZ), "LDKCResult_BlindedPathNoneZ");
50380         *ret_conv = BlindedPath_new(node_pks_constr, keys_manager_conv);
50381         return tag_ptr(ret_conv, true);
50382 }
50383
50384 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BlindedPath_1write(JNIEnv *env, jclass clz, int64_t obj) {
50385         LDKBlindedPath obj_conv;
50386         obj_conv.inner = untag_ptr(obj);
50387         obj_conv.is_owned = ptr_is_owned(obj);
50388         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
50389         obj_conv.is_owned = false;
50390         LDKCVec_u8Z ret_var = BlindedPath_write(&obj_conv);
50391         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
50392         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
50393         CVec_u8Z_free(ret_var);
50394         return ret_arr;
50395 }
50396
50397 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BlindedPath_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
50398         LDKu8slice ser_ref;
50399         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
50400         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
50401         LDKCResult_BlindedPathDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedPathDecodeErrorZ), "LDKCResult_BlindedPathDecodeErrorZ");
50402         *ret_conv = BlindedPath_read(ser_ref);
50403         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
50404         return tag_ptr(ret_conv, true);
50405 }
50406
50407 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BlindedHop_1write(JNIEnv *env, jclass clz, int64_t obj) {
50408         LDKBlindedHop obj_conv;
50409         obj_conv.inner = untag_ptr(obj);
50410         obj_conv.is_owned = ptr_is_owned(obj);
50411         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
50412         obj_conv.is_owned = false;
50413         LDKCVec_u8Z ret_var = BlindedHop_write(&obj_conv);
50414         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
50415         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
50416         CVec_u8Z_free(ret_var);
50417         return ret_arr;
50418 }
50419
50420 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BlindedHop_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
50421         LDKu8slice ser_ref;
50422         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
50423         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
50424         LDKCResult_BlindedHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BlindedHopDecodeErrorZ), "LDKCResult_BlindedHopDecodeErrorZ");
50425         *ret_conv = BlindedHop_read(ser_ref);
50426         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
50427         return tag_ptr(ret_conv, true);
50428 }
50429
50430 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OnionMessenger_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
50431         LDKOnionMessenger this_obj_conv;
50432         this_obj_conv.inner = untag_ptr(this_obj);
50433         this_obj_conv.is_owned = ptr_is_owned(this_obj);
50434         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
50435         OnionMessenger_free(this_obj_conv);
50436 }
50437
50438 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Destination_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
50439         if (!ptr_is_owned(this_ptr)) return;
50440         void* this_ptr_ptr = untag_ptr(this_ptr);
50441         CHECK_ACCESS(this_ptr_ptr);
50442         LDKDestination this_ptr_conv = *(LDKDestination*)(this_ptr_ptr);
50443         FREE(untag_ptr(this_ptr));
50444         Destination_free(this_ptr_conv);
50445 }
50446
50447 static inline uint64_t Destination_clone_ptr(LDKDestination *NONNULL_PTR arg) {
50448         LDKDestination *ret_copy = MALLOC(sizeof(LDKDestination), "LDKDestination");
50449         *ret_copy = Destination_clone(arg);
50450         int64_t ret_ref = tag_ptr(ret_copy, true);
50451         return ret_ref;
50452 }
50453 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Destination_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
50454         LDKDestination* arg_conv = (LDKDestination*)untag_ptr(arg);
50455         int64_t ret_conv = Destination_clone_ptr(arg_conv);
50456         return ret_conv;
50457 }
50458
50459 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Destination_1clone(JNIEnv *env, jclass clz, int64_t orig) {
50460         LDKDestination* orig_conv = (LDKDestination*)untag_ptr(orig);
50461         LDKDestination *ret_copy = MALLOC(sizeof(LDKDestination), "LDKDestination");
50462         *ret_copy = Destination_clone(orig_conv);
50463         int64_t ret_ref = tag_ptr(ret_copy, true);
50464         return ret_ref;
50465 }
50466
50467 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Destination_1node(JNIEnv *env, jclass clz, int8_tArray a) {
50468         LDKPublicKey a_ref;
50469         CHECK((*env)->GetArrayLength(env, a) == 33);
50470         (*env)->GetByteArrayRegion(env, a, 0, 33, a_ref.compressed_form);
50471         LDKDestination *ret_copy = MALLOC(sizeof(LDKDestination), "LDKDestination");
50472         *ret_copy = Destination_node(a_ref);
50473         int64_t ret_ref = tag_ptr(ret_copy, true);
50474         return ret_ref;
50475 }
50476
50477 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Destination_1blinded_1path(JNIEnv *env, jclass clz, int64_t a) {
50478         LDKBlindedPath a_conv;
50479         a_conv.inner = untag_ptr(a);
50480         a_conv.is_owned = ptr_is_owned(a);
50481         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
50482         a_conv = BlindedPath_clone(&a_conv);
50483         LDKDestination *ret_copy = MALLOC(sizeof(LDKDestination), "LDKDestination");
50484         *ret_copy = Destination_blinded_path(a_conv);
50485         int64_t ret_ref = tag_ptr(ret_copy, true);
50486         return ret_ref;
50487 }
50488
50489 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SendError_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
50490         if (!ptr_is_owned(this_ptr)) return;
50491         void* this_ptr_ptr = untag_ptr(this_ptr);
50492         CHECK_ACCESS(this_ptr_ptr);
50493         LDKSendError this_ptr_conv = *(LDKSendError*)(this_ptr_ptr);
50494         FREE(untag_ptr(this_ptr));
50495         SendError_free(this_ptr_conv);
50496 }
50497
50498 static inline uint64_t SendError_clone_ptr(LDKSendError *NONNULL_PTR arg) {
50499         LDKSendError *ret_copy = MALLOC(sizeof(LDKSendError), "LDKSendError");
50500         *ret_copy = SendError_clone(arg);
50501         int64_t ret_ref = tag_ptr(ret_copy, true);
50502         return ret_ref;
50503 }
50504 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SendError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
50505         LDKSendError* arg_conv = (LDKSendError*)untag_ptr(arg);
50506         int64_t ret_conv = SendError_clone_ptr(arg_conv);
50507         return ret_conv;
50508 }
50509
50510 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SendError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
50511         LDKSendError* orig_conv = (LDKSendError*)untag_ptr(orig);
50512         LDKSendError *ret_copy = MALLOC(sizeof(LDKSendError), "LDKSendError");
50513         *ret_copy = SendError_clone(orig_conv);
50514         int64_t ret_ref = tag_ptr(ret_copy, true);
50515         return ret_ref;
50516 }
50517
50518 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SendError_1secp256k1(JNIEnv *env, jclass clz, jclass a) {
50519         LDKSecp256k1Error a_conv = LDKSecp256k1Error_from_java(env, a);
50520         LDKSendError *ret_copy = MALLOC(sizeof(LDKSendError), "LDKSendError");
50521         *ret_copy = SendError_secp256k1(a_conv);
50522         int64_t ret_ref = tag_ptr(ret_copy, true);
50523         return ret_ref;
50524 }
50525
50526 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SendError_1too_1big_1packet(JNIEnv *env, jclass clz) {
50527         LDKSendError *ret_copy = MALLOC(sizeof(LDKSendError), "LDKSendError");
50528         *ret_copy = SendError_too_big_packet();
50529         int64_t ret_ref = tag_ptr(ret_copy, true);
50530         return ret_ref;
50531 }
50532
50533 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SendError_1too_1few_1blinded_1hops(JNIEnv *env, jclass clz) {
50534         LDKSendError *ret_copy = MALLOC(sizeof(LDKSendError), "LDKSendError");
50535         *ret_copy = SendError_too_few_blinded_hops();
50536         int64_t ret_ref = tag_ptr(ret_copy, true);
50537         return ret_ref;
50538 }
50539
50540 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SendError_1invalid_1first_1hop(JNIEnv *env, jclass clz) {
50541         LDKSendError *ret_copy = MALLOC(sizeof(LDKSendError), "LDKSendError");
50542         *ret_copy = SendError_invalid_first_hop();
50543         int64_t ret_ref = tag_ptr(ret_copy, true);
50544         return ret_ref;
50545 }
50546
50547 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SendError_1invalid_1message(JNIEnv *env, jclass clz) {
50548         LDKSendError *ret_copy = MALLOC(sizeof(LDKSendError), "LDKSendError");
50549         *ret_copy = SendError_invalid_message();
50550         int64_t ret_ref = tag_ptr(ret_copy, true);
50551         return ret_ref;
50552 }
50553
50554 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SendError_1buffer_1full(JNIEnv *env, jclass clz) {
50555         LDKSendError *ret_copy = MALLOC(sizeof(LDKSendError), "LDKSendError");
50556         *ret_copy = SendError_buffer_full();
50557         int64_t ret_ref = tag_ptr(ret_copy, true);
50558         return ret_ref;
50559 }
50560
50561 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SendError_1get_1node_1id_1failed(JNIEnv *env, jclass clz) {
50562         LDKSendError *ret_copy = MALLOC(sizeof(LDKSendError), "LDKSendError");
50563         *ret_copy = SendError_get_node_id_failed();
50564         int64_t ret_ref = tag_ptr(ret_copy, true);
50565         return ret_ref;
50566 }
50567
50568 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SendError_1blinded_1path_1advance_1failed(JNIEnv *env, jclass clz) {
50569         LDKSendError *ret_copy = MALLOC(sizeof(LDKSendError), "LDKSendError");
50570         *ret_copy = SendError_blinded_path_advance_failed();
50571         int64_t ret_ref = tag_ptr(ret_copy, true);
50572         return ret_ref;
50573 }
50574
50575 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SendError_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
50576         LDKSendError* a_conv = (LDKSendError*)untag_ptr(a);
50577         LDKSendError* b_conv = (LDKSendError*)untag_ptr(b);
50578         jboolean ret_conv = SendError_eq(a_conv, b_conv);
50579         return ret_conv;
50580 }
50581
50582 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CustomOnionMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
50583         if (!ptr_is_owned(this_ptr)) return;
50584         void* this_ptr_ptr = untag_ptr(this_ptr);
50585         CHECK_ACCESS(this_ptr_ptr);
50586         LDKCustomOnionMessageHandler this_ptr_conv = *(LDKCustomOnionMessageHandler*)(this_ptr_ptr);
50587         FREE(untag_ptr(this_ptr));
50588         CustomOnionMessageHandler_free(this_ptr_conv);
50589 }
50590
50591 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) {
50592         void* keys_manager_ptr = untag_ptr(keys_manager);
50593         CHECK_ACCESS(keys_manager_ptr);
50594         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
50595         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
50596                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
50597                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
50598         }
50599         void* logger_ptr = untag_ptr(logger);
50600         CHECK_ACCESS(logger_ptr);
50601         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
50602         if (logger_conv.free == LDKLogger_JCalls_free) {
50603                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
50604                 LDKLogger_JCalls_cloned(&logger_conv);
50605         }
50606         void* custom_handler_ptr = untag_ptr(custom_handler);
50607         CHECK_ACCESS(custom_handler_ptr);
50608         LDKCustomOnionMessageHandler custom_handler_conv = *(LDKCustomOnionMessageHandler*)(custom_handler_ptr);
50609         if (custom_handler_conv.free == LDKCustomOnionMessageHandler_JCalls_free) {
50610                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
50611                 LDKCustomOnionMessageHandler_JCalls_cloned(&custom_handler_conv);
50612         }
50613         LDKOnionMessenger ret_var = OnionMessenger_new(keys_manager_conv, logger_conv, custom_handler_conv);
50614         int64_t ret_ref = 0;
50615         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
50616         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
50617         return ret_ref;
50618 }
50619
50620 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OnionMessenger_1send_1onion_1message(JNIEnv *env, jclass clz, int64_t this_arg, jobjectArray intermediate_nodes, int64_t destination, int64_t message, int64_t reply_path) {
50621         LDKOnionMessenger this_arg_conv;
50622         this_arg_conv.inner = untag_ptr(this_arg);
50623         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50624         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50625         this_arg_conv.is_owned = false;
50626         LDKCVec_PublicKeyZ intermediate_nodes_constr;
50627         intermediate_nodes_constr.datalen = (*env)->GetArrayLength(env, intermediate_nodes);
50628         if (intermediate_nodes_constr.datalen > 0)
50629                 intermediate_nodes_constr.data = MALLOC(intermediate_nodes_constr.datalen * sizeof(LDKPublicKey), "LDKCVec_PublicKeyZ Elements");
50630         else
50631                 intermediate_nodes_constr.data = NULL;
50632         for (size_t i = 0; i < intermediate_nodes_constr.datalen; i++) {
50633                 int8_tArray intermediate_nodes_conv_8 = (*env)->GetObjectArrayElement(env, intermediate_nodes, i);
50634                 LDKPublicKey intermediate_nodes_conv_8_ref;
50635                 CHECK((*env)->GetArrayLength(env, intermediate_nodes_conv_8) == 33);
50636                 (*env)->GetByteArrayRegion(env, intermediate_nodes_conv_8, 0, 33, intermediate_nodes_conv_8_ref.compressed_form);
50637                 intermediate_nodes_constr.data[i] = intermediate_nodes_conv_8_ref;
50638         }
50639         void* destination_ptr = untag_ptr(destination);
50640         CHECK_ACCESS(destination_ptr);
50641         LDKDestination destination_conv = *(LDKDestination*)(destination_ptr);
50642         destination_conv = Destination_clone((LDKDestination*)untag_ptr(destination));
50643         void* message_ptr = untag_ptr(message);
50644         CHECK_ACCESS(message_ptr);
50645         LDKOnionMessageContents message_conv = *(LDKOnionMessageContents*)(message_ptr);
50646         message_conv = OnionMessageContents_clone((LDKOnionMessageContents*)untag_ptr(message));
50647         LDKBlindedPath reply_path_conv;
50648         reply_path_conv.inner = untag_ptr(reply_path);
50649         reply_path_conv.is_owned = ptr_is_owned(reply_path);
50650         CHECK_INNER_FIELD_ACCESS_OR_NULL(reply_path_conv);
50651         reply_path_conv = BlindedPath_clone(&reply_path_conv);
50652         LDKCResult_NoneSendErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSendErrorZ), "LDKCResult_NoneSendErrorZ");
50653         *ret_conv = OnionMessenger_send_onion_message(&this_arg_conv, intermediate_nodes_constr, destination_conv, message_conv, reply_path_conv);
50654         return tag_ptr(ret_conv, true);
50655 }
50656
50657 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OnionMessenger_1as_1OnionMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
50658         LDKOnionMessenger this_arg_conv;
50659         this_arg_conv.inner = untag_ptr(this_arg);
50660         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50661         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50662         this_arg_conv.is_owned = false;
50663         LDKOnionMessageHandler* ret_ret = MALLOC(sizeof(LDKOnionMessageHandler), "LDKOnionMessageHandler");
50664         *ret_ret = OnionMessenger_as_OnionMessageHandler(&this_arg_conv);
50665         return tag_ptr(ret_ret, true);
50666 }
50667
50668 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OnionMessenger_1as_1OnionMessageProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
50669         LDKOnionMessenger this_arg_conv;
50670         this_arg_conv.inner = untag_ptr(this_arg);
50671         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50672         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50673         this_arg_conv.is_owned = false;
50674         LDKOnionMessageProvider* ret_ret = MALLOC(sizeof(LDKOnionMessageProvider), "LDKOnionMessageProvider");
50675         *ret_ret = OnionMessenger_as_OnionMessageProvider(&this_arg_conv);
50676         return tag_ptr(ret_ret, true);
50677 }
50678
50679 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OnionMessageContents_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
50680         if (!ptr_is_owned(this_ptr)) return;
50681         void* this_ptr_ptr = untag_ptr(this_ptr);
50682         CHECK_ACCESS(this_ptr_ptr);
50683         LDKOnionMessageContents this_ptr_conv = *(LDKOnionMessageContents*)(this_ptr_ptr);
50684         FREE(untag_ptr(this_ptr));
50685         OnionMessageContents_free(this_ptr_conv);
50686 }
50687
50688 static inline uint64_t OnionMessageContents_clone_ptr(LDKOnionMessageContents *NONNULL_PTR arg) {
50689         LDKOnionMessageContents *ret_copy = MALLOC(sizeof(LDKOnionMessageContents), "LDKOnionMessageContents");
50690         *ret_copy = OnionMessageContents_clone(arg);
50691         int64_t ret_ref = tag_ptr(ret_copy, true);
50692         return ret_ref;
50693 }
50694 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OnionMessageContents_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
50695         LDKOnionMessageContents* arg_conv = (LDKOnionMessageContents*)untag_ptr(arg);
50696         int64_t ret_conv = OnionMessageContents_clone_ptr(arg_conv);
50697         return ret_conv;
50698 }
50699
50700 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OnionMessageContents_1clone(JNIEnv *env, jclass clz, int64_t orig) {
50701         LDKOnionMessageContents* orig_conv = (LDKOnionMessageContents*)untag_ptr(orig);
50702         LDKOnionMessageContents *ret_copy = MALLOC(sizeof(LDKOnionMessageContents), "LDKOnionMessageContents");
50703         *ret_copy = OnionMessageContents_clone(orig_conv);
50704         int64_t ret_ref = tag_ptr(ret_copy, true);
50705         return ret_ref;
50706 }
50707
50708 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OnionMessageContents_1custom(JNIEnv *env, jclass clz, int64_t a) {
50709         void* a_ptr = untag_ptr(a);
50710         CHECK_ACCESS(a_ptr);
50711         LDKCustomOnionMessageContents a_conv = *(LDKCustomOnionMessageContents*)(a_ptr);
50712         if (a_conv.free == LDKCustomOnionMessageContents_JCalls_free) {
50713                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
50714                 LDKCustomOnionMessageContents_JCalls_cloned(&a_conv);
50715         }
50716         LDKOnionMessageContents *ret_copy = MALLOC(sizeof(LDKOnionMessageContents), "LDKOnionMessageContents");
50717         *ret_copy = OnionMessageContents_custom(a_conv);
50718         int64_t ret_ref = tag_ptr(ret_copy, true);
50719         return ret_ref;
50720 }
50721
50722 static inline uint64_t CustomOnionMessageContents_clone_ptr(LDKCustomOnionMessageContents *NONNULL_PTR arg) {
50723         LDKCustomOnionMessageContents* ret_ret = MALLOC(sizeof(LDKCustomOnionMessageContents), "LDKCustomOnionMessageContents");
50724         *ret_ret = CustomOnionMessageContents_clone(arg);
50725         return tag_ptr(ret_ret, true);
50726 }
50727 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CustomOnionMessageContents_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
50728         void* arg_ptr = untag_ptr(arg);
50729         if (ptr_is_owned(arg)) { CHECK_ACCESS(arg_ptr); }
50730         LDKCustomOnionMessageContents* arg_conv = (LDKCustomOnionMessageContents*)arg_ptr;
50731         int64_t ret_conv = CustomOnionMessageContents_clone_ptr(arg_conv);
50732         return ret_conv;
50733 }
50734
50735 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CustomOnionMessageContents_1clone(JNIEnv *env, jclass clz, int64_t orig) {
50736         void* orig_ptr = untag_ptr(orig);
50737         if (ptr_is_owned(orig)) { CHECK_ACCESS(orig_ptr); }
50738         LDKCustomOnionMessageContents* orig_conv = (LDKCustomOnionMessageContents*)orig_ptr;
50739         LDKCustomOnionMessageContents* ret_ret = MALLOC(sizeof(LDKCustomOnionMessageContents), "LDKCustomOnionMessageContents");
50740         *ret_ret = CustomOnionMessageContents_clone(orig_conv);
50741         return tag_ptr(ret_ret, true);
50742 }
50743
50744 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CustomOnionMessageContents_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
50745         if (!ptr_is_owned(this_ptr)) return;
50746         void* this_ptr_ptr = untag_ptr(this_ptr);
50747         CHECK_ACCESS(this_ptr_ptr);
50748         LDKCustomOnionMessageContents this_ptr_conv = *(LDKCustomOnionMessageContents*)(this_ptr_ptr);
50749         FREE(untag_ptr(this_ptr));
50750         CustomOnionMessageContents_free(this_ptr_conv);
50751 }
50752
50753 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
50754         LDKFilesystemPersister this_obj_conv;
50755         this_obj_conv.inner = untag_ptr(this_obj);
50756         this_obj_conv.is_owned = ptr_is_owned(this_obj);
50757         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
50758         FilesystemPersister_free(this_obj_conv);
50759 }
50760
50761 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1new(JNIEnv *env, jclass clz, jstring path_to_channel_data) {
50762         LDKStr path_to_channel_data_conv = java_to_owned_str(env, path_to_channel_data);
50763         LDKFilesystemPersister ret_var = FilesystemPersister_new(path_to_channel_data_conv);
50764         int64_t ret_ref = 0;
50765         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
50766         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
50767         return ret_ref;
50768 }
50769
50770 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1get_1data_1dir(JNIEnv *env, jclass clz, int64_t this_arg) {
50771         LDKFilesystemPersister this_arg_conv;
50772         this_arg_conv.inner = untag_ptr(this_arg);
50773         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50774         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50775         this_arg_conv.is_owned = false;
50776         LDKStr ret_str = FilesystemPersister_get_data_dir(&this_arg_conv);
50777         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
50778         Str_free(ret_str);
50779         return ret_conv;
50780 }
50781
50782 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1read_1channelmonitors(JNIEnv *env, jclass clz, int64_t this_arg, int64_t keys_manager) {
50783         LDKFilesystemPersister this_arg_conv;
50784         this_arg_conv.inner = untag_ptr(this_arg);
50785         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50786         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50787         this_arg_conv.is_owned = false;
50788         void* keys_manager_ptr = untag_ptr(keys_manager);
50789         CHECK_ACCESS(keys_manager_ptr);
50790         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
50791         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
50792                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
50793                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
50794         }
50795         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
50796         *ret_conv = FilesystemPersister_read_channelmonitors(&this_arg_conv, keys_manager_conv);
50797         return tag_ptr(ret_conv, true);
50798 }
50799
50800 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BackgroundProcessor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
50801         LDKBackgroundProcessor this_obj_conv;
50802         this_obj_conv.inner = untag_ptr(this_obj);
50803         this_obj_conv.is_owned = ptr_is_owned(this_obj);
50804         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
50805         BackgroundProcessor_free(this_obj_conv);
50806 }
50807
50808 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipSync_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
50809         if (!ptr_is_owned(this_ptr)) return;
50810         void* this_ptr_ptr = untag_ptr(this_ptr);
50811         CHECK_ACCESS(this_ptr_ptr);
50812         LDKGossipSync this_ptr_conv = *(LDKGossipSync*)(this_ptr_ptr);
50813         FREE(untag_ptr(this_ptr));
50814         GossipSync_free(this_ptr_conv);
50815 }
50816
50817 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GossipSync_1p2_1p(JNIEnv *env, jclass clz, int64_t a) {
50818         LDKP2PGossipSync a_conv;
50819         a_conv.inner = untag_ptr(a);
50820         a_conv.is_owned = ptr_is_owned(a);
50821         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
50822         a_conv.is_owned = false;
50823         LDKGossipSync *ret_copy = MALLOC(sizeof(LDKGossipSync), "LDKGossipSync");
50824         *ret_copy = GossipSync_p2_p(&a_conv);
50825         int64_t ret_ref = tag_ptr(ret_copy, true);
50826         return ret_ref;
50827 }
50828
50829 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GossipSync_1rapid(JNIEnv *env, jclass clz, int64_t a) {
50830         LDKRapidGossipSync a_conv;
50831         a_conv.inner = untag_ptr(a);
50832         a_conv.is_owned = ptr_is_owned(a);
50833         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
50834         a_conv.is_owned = false;
50835         LDKGossipSync *ret_copy = MALLOC(sizeof(LDKGossipSync), "LDKGossipSync");
50836         *ret_copy = GossipSync_rapid(&a_conv);
50837         int64_t ret_ref = tag_ptr(ret_copy, true);
50838         return ret_ref;
50839 }
50840
50841 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GossipSync_1none(JNIEnv *env, jclass clz) {
50842         LDKGossipSync *ret_copy = MALLOC(sizeof(LDKGossipSync), "LDKGossipSync");
50843         *ret_copy = GossipSync_none();
50844         int64_t ret_ref = tag_ptr(ret_copy, true);
50845         return ret_ref;
50846 }
50847
50848 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) {
50849         void* persister_ptr = untag_ptr(persister);
50850         CHECK_ACCESS(persister_ptr);
50851         LDKPersister persister_conv = *(LDKPersister*)(persister_ptr);
50852         if (persister_conv.free == LDKPersister_JCalls_free) {
50853                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
50854                 LDKPersister_JCalls_cloned(&persister_conv);
50855         }
50856         void* event_handler_ptr = untag_ptr(event_handler);
50857         CHECK_ACCESS(event_handler_ptr);
50858         LDKEventHandler event_handler_conv = *(LDKEventHandler*)(event_handler_ptr);
50859         if (event_handler_conv.free == LDKEventHandler_JCalls_free) {
50860                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
50861                 LDKEventHandler_JCalls_cloned(&event_handler_conv);
50862         }
50863         LDKChainMonitor chain_monitor_conv;
50864         chain_monitor_conv.inner = untag_ptr(chain_monitor);
50865         chain_monitor_conv.is_owned = ptr_is_owned(chain_monitor);
50866         CHECK_INNER_FIELD_ACCESS_OR_NULL(chain_monitor_conv);
50867         chain_monitor_conv.is_owned = false;
50868         LDKChannelManager channel_manager_conv;
50869         channel_manager_conv.inner = untag_ptr(channel_manager);
50870         channel_manager_conv.is_owned = ptr_is_owned(channel_manager);
50871         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_manager_conv);
50872         channel_manager_conv.is_owned = false;
50873         void* gossip_sync_ptr = untag_ptr(gossip_sync);
50874         CHECK_ACCESS(gossip_sync_ptr);
50875         LDKGossipSync gossip_sync_conv = *(LDKGossipSync*)(gossip_sync_ptr);
50876         // WARNING: we may need a move here but no clone is available for LDKGossipSync
50877         LDKPeerManager peer_manager_conv;
50878         peer_manager_conv.inner = untag_ptr(peer_manager);
50879         peer_manager_conv.is_owned = ptr_is_owned(peer_manager);
50880         CHECK_INNER_FIELD_ACCESS_OR_NULL(peer_manager_conv);
50881         peer_manager_conv.is_owned = false;
50882         void* logger_ptr = untag_ptr(logger);
50883         CHECK_ACCESS(logger_ptr);
50884         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
50885         if (logger_conv.free == LDKLogger_JCalls_free) {
50886                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
50887                 LDKLogger_JCalls_cloned(&logger_conv);
50888         }
50889         void* scorer_ptr = untag_ptr(scorer);
50890         CHECK_ACCESS(scorer_ptr);
50891         LDKCOption_WriteableScoreZ scorer_conv = *(LDKCOption_WriteableScoreZ*)(scorer_ptr);
50892         // WARNING: we may need a move here but no clone is available for LDKCOption_WriteableScoreZ
50893         if (scorer_conv.tag == LDKCOption_WriteableScoreZ_Some) {
50894                 // Manually implement clone for Java trait instances
50895                 if (scorer_conv.some.free == LDKWriteableScore_JCalls_free) {
50896                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
50897                         LDKWriteableScore_JCalls_cloned(&scorer_conv.some);
50898                 }
50899         }
50900         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);
50901         int64_t ret_ref = 0;
50902         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
50903         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
50904         return ret_ref;
50905 }
50906
50907 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BackgroundProcessor_1join(JNIEnv *env, jclass clz, int64_t this_arg) {
50908         LDKBackgroundProcessor this_arg_conv;
50909         this_arg_conv.inner = untag_ptr(this_arg);
50910         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50911         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50912         // WARNING: we need a move here but no clone is available for LDKBackgroundProcessor
50913         
50914         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
50915         *ret_conv = BackgroundProcessor_join(this_arg_conv);
50916         return tag_ptr(ret_conv, true);
50917 }
50918
50919 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BackgroundProcessor_1stop(JNIEnv *env, jclass clz, int64_t this_arg) {
50920         LDKBackgroundProcessor this_arg_conv;
50921         this_arg_conv.inner = untag_ptr(this_arg);
50922         this_arg_conv.is_owned = ptr_is_owned(this_arg);
50923         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
50924         // WARNING: we need a move here but no clone is available for LDKBackgroundProcessor
50925         
50926         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
50927         *ret_conv = BackgroundProcessor_stop(this_arg_conv);
50928         return tag_ptr(ret_conv, true);
50929 }
50930
50931 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ParseError_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
50932         if (!ptr_is_owned(this_ptr)) return;
50933         void* this_ptr_ptr = untag_ptr(this_ptr);
50934         CHECK_ACCESS(this_ptr_ptr);
50935         LDKParseError this_ptr_conv = *(LDKParseError*)(this_ptr_ptr);
50936         FREE(untag_ptr(this_ptr));
50937         ParseError_free(this_ptr_conv);
50938 }
50939
50940 static inline uint64_t ParseError_clone_ptr(LDKParseError *NONNULL_PTR arg) {
50941         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
50942         *ret_copy = ParseError_clone(arg);
50943         int64_t ret_ref = tag_ptr(ret_copy, true);
50944         return ret_ref;
50945 }
50946 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
50947         LDKParseError* arg_conv = (LDKParseError*)untag_ptr(arg);
50948         int64_t ret_conv = ParseError_clone_ptr(arg_conv);
50949         return ret_conv;
50950 }
50951
50952 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
50953         LDKParseError* orig_conv = (LDKParseError*)untag_ptr(orig);
50954         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
50955         *ret_copy = ParseError_clone(orig_conv);
50956         int64_t ret_ref = tag_ptr(ret_copy, true);
50957         return ret_ref;
50958 }
50959
50960 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1bech32_1error(JNIEnv *env, jclass clz, int64_t a) {
50961         void* a_ptr = untag_ptr(a);
50962         CHECK_ACCESS(a_ptr);
50963         LDKBech32Error a_conv = *(LDKBech32Error*)(a_ptr);
50964         a_conv = Bech32Error_clone((LDKBech32Error*)untag_ptr(a));
50965         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
50966         *ret_copy = ParseError_bech32_error(a_conv);
50967         int64_t ret_ref = tag_ptr(ret_copy, true);
50968         return ret_ref;
50969 }
50970
50971 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1parse_1amount_1error(JNIEnv *env, jclass clz, int32_t a) {
50972         
50973         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
50974         *ret_copy = ParseError_parse_amount_error((LDKError){ ._dummy = 0 });
50975         int64_t ret_ref = tag_ptr(ret_copy, true);
50976         return ret_ref;
50977 }
50978
50979 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1malformed_1signature(JNIEnv *env, jclass clz, jclass a) {
50980         LDKSecp256k1Error a_conv = LDKSecp256k1Error_from_java(env, a);
50981         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
50982         *ret_copy = ParseError_malformed_signature(a_conv);
50983         int64_t ret_ref = tag_ptr(ret_copy, true);
50984         return ret_ref;
50985 }
50986
50987 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1bad_1prefix(JNIEnv *env, jclass clz) {
50988         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
50989         *ret_copy = ParseError_bad_prefix();
50990         int64_t ret_ref = tag_ptr(ret_copy, true);
50991         return ret_ref;
50992 }
50993
50994 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1unknown_1currency(JNIEnv *env, jclass clz) {
50995         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
50996         *ret_copy = ParseError_unknown_currency();
50997         int64_t ret_ref = tag_ptr(ret_copy, true);
50998         return ret_ref;
50999 }
51000
51001 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1unknown_1si_1prefix(JNIEnv *env, jclass clz) {
51002         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
51003         *ret_copy = ParseError_unknown_si_prefix();
51004         int64_t ret_ref = tag_ptr(ret_copy, true);
51005         return ret_ref;
51006 }
51007
51008 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1malformed_1hrp(JNIEnv *env, jclass clz) {
51009         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
51010         *ret_copy = ParseError_malformed_hrp();
51011         int64_t ret_ref = tag_ptr(ret_copy, true);
51012         return ret_ref;
51013 }
51014
51015 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1too_1short_1data_1part(JNIEnv *env, jclass clz) {
51016         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
51017         *ret_copy = ParseError_too_short_data_part();
51018         int64_t ret_ref = tag_ptr(ret_copy, true);
51019         return ret_ref;
51020 }
51021
51022 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1unexpected_1end_1of_1tagged_1fields(JNIEnv *env, jclass clz) {
51023         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
51024         *ret_copy = ParseError_unexpected_end_of_tagged_fields();
51025         int64_t ret_ref = tag_ptr(ret_copy, true);
51026         return ret_ref;
51027 }
51028
51029 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1description_1decode_1error(JNIEnv *env, jclass clz, int32_t a) {
51030         
51031         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
51032         *ret_copy = ParseError_description_decode_error((LDKError){ ._dummy = 0 });
51033         int64_t ret_ref = tag_ptr(ret_copy, true);
51034         return ret_ref;
51035 }
51036
51037 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1padding_1error(JNIEnv *env, jclass clz) {
51038         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
51039         *ret_copy = ParseError_padding_error();
51040         int64_t ret_ref = tag_ptr(ret_copy, true);
51041         return ret_ref;
51042 }
51043
51044 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1integer_1overflow_1error(JNIEnv *env, jclass clz) {
51045         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
51046         *ret_copy = ParseError_integer_overflow_error();
51047         int64_t ret_ref = tag_ptr(ret_copy, true);
51048         return ret_ref;
51049 }
51050
51051 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1invalid_1seg_1wit_1program_1length(JNIEnv *env, jclass clz) {
51052         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
51053         *ret_copy = ParseError_invalid_seg_wit_program_length();
51054         int64_t ret_ref = tag_ptr(ret_copy, true);
51055         return ret_ref;
51056 }
51057
51058 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1invalid_1pub_1key_1hash_1length(JNIEnv *env, jclass clz) {
51059         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
51060         *ret_copy = ParseError_invalid_pub_key_hash_length();
51061         int64_t ret_ref = tag_ptr(ret_copy, true);
51062         return ret_ref;
51063 }
51064
51065 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1invalid_1script_1hash_1length(JNIEnv *env, jclass clz) {
51066         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
51067         *ret_copy = ParseError_invalid_script_hash_length();
51068         int64_t ret_ref = tag_ptr(ret_copy, true);
51069         return ret_ref;
51070 }
51071
51072 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1invalid_1recovery_1id(JNIEnv *env, jclass clz) {
51073         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
51074         *ret_copy = ParseError_invalid_recovery_id();
51075         int64_t ret_ref = tag_ptr(ret_copy, true);
51076         return ret_ref;
51077 }
51078
51079 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1invalid_1slice_1length(JNIEnv *env, jclass clz, jstring a) {
51080         LDKStr a_conv = java_to_owned_str(env, a);
51081         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
51082         *ret_copy = ParseError_invalid_slice_length(a_conv);
51083         int64_t ret_ref = tag_ptr(ret_copy, true);
51084         return ret_ref;
51085 }
51086
51087 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseError_1skip(JNIEnv *env, jclass clz) {
51088         LDKParseError *ret_copy = MALLOC(sizeof(LDKParseError), "LDKParseError");
51089         *ret_copy = ParseError_skip();
51090         int64_t ret_ref = tag_ptr(ret_copy, true);
51091         return ret_ref;
51092 }
51093
51094 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ParseError_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
51095         LDKParseError* a_conv = (LDKParseError*)untag_ptr(a);
51096         LDKParseError* b_conv = (LDKParseError*)untag_ptr(b);
51097         jboolean ret_conv = ParseError_eq(a_conv, b_conv);
51098         return ret_conv;
51099 }
51100
51101 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ParseOrSemanticError_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
51102         if (!ptr_is_owned(this_ptr)) return;
51103         void* this_ptr_ptr = untag_ptr(this_ptr);
51104         CHECK_ACCESS(this_ptr_ptr);
51105         LDKParseOrSemanticError this_ptr_conv = *(LDKParseOrSemanticError*)(this_ptr_ptr);
51106         FREE(untag_ptr(this_ptr));
51107         ParseOrSemanticError_free(this_ptr_conv);
51108 }
51109
51110 static inline uint64_t ParseOrSemanticError_clone_ptr(LDKParseOrSemanticError *NONNULL_PTR arg) {
51111         LDKParseOrSemanticError *ret_copy = MALLOC(sizeof(LDKParseOrSemanticError), "LDKParseOrSemanticError");
51112         *ret_copy = ParseOrSemanticError_clone(arg);
51113         int64_t ret_ref = tag_ptr(ret_copy, true);
51114         return ret_ref;
51115 }
51116 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseOrSemanticError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
51117         LDKParseOrSemanticError* arg_conv = (LDKParseOrSemanticError*)untag_ptr(arg);
51118         int64_t ret_conv = ParseOrSemanticError_clone_ptr(arg_conv);
51119         return ret_conv;
51120 }
51121
51122 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseOrSemanticError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
51123         LDKParseOrSemanticError* orig_conv = (LDKParseOrSemanticError*)untag_ptr(orig);
51124         LDKParseOrSemanticError *ret_copy = MALLOC(sizeof(LDKParseOrSemanticError), "LDKParseOrSemanticError");
51125         *ret_copy = ParseOrSemanticError_clone(orig_conv);
51126         int64_t ret_ref = tag_ptr(ret_copy, true);
51127         return ret_ref;
51128 }
51129
51130 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseOrSemanticError_1parse_1error(JNIEnv *env, jclass clz, int64_t a) {
51131         void* a_ptr = untag_ptr(a);
51132         CHECK_ACCESS(a_ptr);
51133         LDKParseError a_conv = *(LDKParseError*)(a_ptr);
51134         a_conv = ParseError_clone((LDKParseError*)untag_ptr(a));
51135         LDKParseOrSemanticError *ret_copy = MALLOC(sizeof(LDKParseOrSemanticError), "LDKParseOrSemanticError");
51136         *ret_copy = ParseOrSemanticError_parse_error(a_conv);
51137         int64_t ret_ref = tag_ptr(ret_copy, true);
51138         return ret_ref;
51139 }
51140
51141 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ParseOrSemanticError_1semantic_1error(JNIEnv *env, jclass clz, jclass a) {
51142         LDKSemanticError a_conv = LDKSemanticError_from_java(env, a);
51143         LDKParseOrSemanticError *ret_copy = MALLOC(sizeof(LDKParseOrSemanticError), "LDKParseOrSemanticError");
51144         *ret_copy = ParseOrSemanticError_semantic_error(a_conv);
51145         int64_t ret_ref = tag_ptr(ret_copy, true);
51146         return ret_ref;
51147 }
51148
51149 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ParseOrSemanticError_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
51150         LDKParseOrSemanticError* a_conv = (LDKParseOrSemanticError*)untag_ptr(a);
51151         LDKParseOrSemanticError* b_conv = (LDKParseOrSemanticError*)untag_ptr(b);
51152         jboolean ret_conv = ParseOrSemanticError_eq(a_conv, b_conv);
51153         return ret_conv;
51154 }
51155
51156 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Invoice_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
51157         LDKInvoice this_obj_conv;
51158         this_obj_conv.inner = untag_ptr(this_obj);
51159         this_obj_conv.is_owned = ptr_is_owned(this_obj);
51160         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
51161         Invoice_free(this_obj_conv);
51162 }
51163
51164 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Invoice_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
51165         LDKInvoice a_conv;
51166         a_conv.inner = untag_ptr(a);
51167         a_conv.is_owned = ptr_is_owned(a);
51168         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
51169         a_conv.is_owned = false;
51170         LDKInvoice b_conv;
51171         b_conv.inner = untag_ptr(b);
51172         b_conv.is_owned = ptr_is_owned(b);
51173         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
51174         b_conv.is_owned = false;
51175         jboolean ret_conv = Invoice_eq(&a_conv, &b_conv);
51176         return ret_conv;
51177 }
51178
51179 static inline uint64_t Invoice_clone_ptr(LDKInvoice *NONNULL_PTR arg) {
51180         LDKInvoice ret_var = Invoice_clone(arg);
51181         int64_t ret_ref = 0;
51182         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
51183         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
51184         return ret_ref;
51185 }
51186 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
51187         LDKInvoice arg_conv;
51188         arg_conv.inner = untag_ptr(arg);
51189         arg_conv.is_owned = ptr_is_owned(arg);
51190         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
51191         arg_conv.is_owned = false;
51192         int64_t ret_conv = Invoice_clone_ptr(&arg_conv);
51193         return ret_conv;
51194 }
51195
51196 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1clone(JNIEnv *env, jclass clz, int64_t orig) {
51197         LDKInvoice orig_conv;
51198         orig_conv.inner = untag_ptr(orig);
51199         orig_conv.is_owned = ptr_is_owned(orig);
51200         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
51201         orig_conv.is_owned = false;
51202         LDKInvoice ret_var = Invoice_clone(&orig_conv);
51203         int64_t ret_ref = 0;
51204         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
51205         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
51206         return ret_ref;
51207 }
51208
51209 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1hash(JNIEnv *env, jclass clz, int64_t o) {
51210         LDKInvoice o_conv;
51211         o_conv.inner = untag_ptr(o);
51212         o_conv.is_owned = ptr_is_owned(o);
51213         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
51214         o_conv.is_owned = false;
51215         int64_t ret_conv = Invoice_hash(&o_conv);
51216         return ret_conv;
51217 }
51218
51219 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
51220         LDKSignedRawInvoice this_obj_conv;
51221         this_obj_conv.inner = untag_ptr(this_obj);
51222         this_obj_conv.is_owned = ptr_is_owned(this_obj);
51223         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
51224         SignedRawInvoice_free(this_obj_conv);
51225 }
51226
51227 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
51228         LDKSignedRawInvoice a_conv;
51229         a_conv.inner = untag_ptr(a);
51230         a_conv.is_owned = ptr_is_owned(a);
51231         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
51232         a_conv.is_owned = false;
51233         LDKSignedRawInvoice b_conv;
51234         b_conv.inner = untag_ptr(b);
51235         b_conv.is_owned = ptr_is_owned(b);
51236         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
51237         b_conv.is_owned = false;
51238         jboolean ret_conv = SignedRawInvoice_eq(&a_conv, &b_conv);
51239         return ret_conv;
51240 }
51241
51242 static inline uint64_t SignedRawInvoice_clone_ptr(LDKSignedRawInvoice *NONNULL_PTR arg) {
51243         LDKSignedRawInvoice ret_var = SignedRawInvoice_clone(arg);
51244         int64_t ret_ref = 0;
51245         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
51246         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
51247         return ret_ref;
51248 }
51249 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
51250         LDKSignedRawInvoice arg_conv;
51251         arg_conv.inner = untag_ptr(arg);
51252         arg_conv.is_owned = ptr_is_owned(arg);
51253         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
51254         arg_conv.is_owned = false;
51255         int64_t ret_conv = SignedRawInvoice_clone_ptr(&arg_conv);
51256         return ret_conv;
51257 }
51258
51259 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1clone(JNIEnv *env, jclass clz, int64_t orig) {
51260         LDKSignedRawInvoice orig_conv;
51261         orig_conv.inner = untag_ptr(orig);
51262         orig_conv.is_owned = ptr_is_owned(orig);
51263         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
51264         orig_conv.is_owned = false;
51265         LDKSignedRawInvoice ret_var = SignedRawInvoice_clone(&orig_conv);
51266         int64_t ret_ref = 0;
51267         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
51268         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
51269         return ret_ref;
51270 }
51271
51272 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1hash(JNIEnv *env, jclass clz, int64_t o) {
51273         LDKSignedRawInvoice o_conv;
51274         o_conv.inner = untag_ptr(o);
51275         o_conv.is_owned = ptr_is_owned(o);
51276         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
51277         o_conv.is_owned = false;
51278         int64_t ret_conv = SignedRawInvoice_hash(&o_conv);
51279         return ret_conv;
51280 }
51281
51282 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RawInvoice_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
51283         LDKRawInvoice this_obj_conv;
51284         this_obj_conv.inner = untag_ptr(this_obj);
51285         this_obj_conv.is_owned = ptr_is_owned(this_obj);
51286         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
51287         RawInvoice_free(this_obj_conv);
51288 }
51289
51290 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1get_1data(JNIEnv *env, jclass clz, int64_t this_ptr) {
51291         LDKRawInvoice this_ptr_conv;
51292         this_ptr_conv.inner = untag_ptr(this_ptr);
51293         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
51294         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
51295         this_ptr_conv.is_owned = false;
51296         LDKRawDataPart ret_var = RawInvoice_get_data(&this_ptr_conv);
51297         int64_t ret_ref = 0;
51298         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
51299         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
51300         return ret_ref;
51301 }
51302
51303 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RawInvoice_1set_1data(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
51304         LDKRawInvoice this_ptr_conv;
51305         this_ptr_conv.inner = untag_ptr(this_ptr);
51306         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
51307         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
51308         this_ptr_conv.is_owned = false;
51309         LDKRawDataPart val_conv;
51310         val_conv.inner = untag_ptr(val);
51311         val_conv.is_owned = ptr_is_owned(val);
51312         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
51313         val_conv = RawDataPart_clone(&val_conv);
51314         RawInvoice_set_data(&this_ptr_conv, val_conv);
51315 }
51316
51317 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RawInvoice_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
51318         LDKRawInvoice a_conv;
51319         a_conv.inner = untag_ptr(a);
51320         a_conv.is_owned = ptr_is_owned(a);
51321         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
51322         a_conv.is_owned = false;
51323         LDKRawInvoice b_conv;
51324         b_conv.inner = untag_ptr(b);
51325         b_conv.is_owned = ptr_is_owned(b);
51326         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
51327         b_conv.is_owned = false;
51328         jboolean ret_conv = RawInvoice_eq(&a_conv, &b_conv);
51329         return ret_conv;
51330 }
51331
51332 static inline uint64_t RawInvoice_clone_ptr(LDKRawInvoice *NONNULL_PTR arg) {
51333         LDKRawInvoice ret_var = RawInvoice_clone(arg);
51334         int64_t ret_ref = 0;
51335         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
51336         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
51337         return ret_ref;
51338 }
51339 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
51340         LDKRawInvoice arg_conv;
51341         arg_conv.inner = untag_ptr(arg);
51342         arg_conv.is_owned = ptr_is_owned(arg);
51343         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
51344         arg_conv.is_owned = false;
51345         int64_t ret_conv = RawInvoice_clone_ptr(&arg_conv);
51346         return ret_conv;
51347 }
51348
51349 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1clone(JNIEnv *env, jclass clz, int64_t orig) {
51350         LDKRawInvoice orig_conv;
51351         orig_conv.inner = untag_ptr(orig);
51352         orig_conv.is_owned = ptr_is_owned(orig);
51353         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
51354         orig_conv.is_owned = false;
51355         LDKRawInvoice ret_var = RawInvoice_clone(&orig_conv);
51356         int64_t ret_ref = 0;
51357         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
51358         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
51359         return ret_ref;
51360 }
51361
51362 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1hash(JNIEnv *env, jclass clz, int64_t o) {
51363         LDKRawInvoice o_conv;
51364         o_conv.inner = untag_ptr(o);
51365         o_conv.is_owned = ptr_is_owned(o);
51366         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
51367         o_conv.is_owned = false;
51368         int64_t ret_conv = RawInvoice_hash(&o_conv);
51369         return ret_conv;
51370 }
51371
51372 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RawDataPart_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
51373         LDKRawDataPart this_obj_conv;
51374         this_obj_conv.inner = untag_ptr(this_obj);
51375         this_obj_conv.is_owned = ptr_is_owned(this_obj);
51376         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
51377         RawDataPart_free(this_obj_conv);
51378 }
51379
51380 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawDataPart_1get_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr) {
51381         LDKRawDataPart this_ptr_conv;
51382         this_ptr_conv.inner = untag_ptr(this_ptr);
51383         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
51384         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
51385         this_ptr_conv.is_owned = false;
51386         LDKPositiveTimestamp ret_var = RawDataPart_get_timestamp(&this_ptr_conv);
51387         int64_t ret_ref = 0;
51388         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
51389         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
51390         return ret_ref;
51391 }
51392
51393 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RawDataPart_1set_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
51394         LDKRawDataPart this_ptr_conv;
51395         this_ptr_conv.inner = untag_ptr(this_ptr);
51396         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
51397         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
51398         this_ptr_conv.is_owned = false;
51399         LDKPositiveTimestamp val_conv;
51400         val_conv.inner = untag_ptr(val);
51401         val_conv.is_owned = ptr_is_owned(val);
51402         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
51403         val_conv = PositiveTimestamp_clone(&val_conv);
51404         RawDataPart_set_timestamp(&this_ptr_conv, val_conv);
51405 }
51406
51407 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RawDataPart_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
51408         LDKRawDataPart a_conv;
51409         a_conv.inner = untag_ptr(a);
51410         a_conv.is_owned = ptr_is_owned(a);
51411         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
51412         a_conv.is_owned = false;
51413         LDKRawDataPart b_conv;
51414         b_conv.inner = untag_ptr(b);
51415         b_conv.is_owned = ptr_is_owned(b);
51416         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
51417         b_conv.is_owned = false;
51418         jboolean ret_conv = RawDataPart_eq(&a_conv, &b_conv);
51419         return ret_conv;
51420 }
51421
51422 static inline uint64_t RawDataPart_clone_ptr(LDKRawDataPart *NONNULL_PTR arg) {
51423         LDKRawDataPart ret_var = RawDataPart_clone(arg);
51424         int64_t ret_ref = 0;
51425         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
51426         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
51427         return ret_ref;
51428 }
51429 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawDataPart_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
51430         LDKRawDataPart arg_conv;
51431         arg_conv.inner = untag_ptr(arg);
51432         arg_conv.is_owned = ptr_is_owned(arg);
51433         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
51434         arg_conv.is_owned = false;
51435         int64_t ret_conv = RawDataPart_clone_ptr(&arg_conv);
51436         return ret_conv;
51437 }
51438
51439 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawDataPart_1clone(JNIEnv *env, jclass clz, int64_t orig) {
51440         LDKRawDataPart orig_conv;
51441         orig_conv.inner = untag_ptr(orig);
51442         orig_conv.is_owned = ptr_is_owned(orig);
51443         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
51444         orig_conv.is_owned = false;
51445         LDKRawDataPart ret_var = RawDataPart_clone(&orig_conv);
51446         int64_t ret_ref = 0;
51447         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
51448         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
51449         return ret_ref;
51450 }
51451
51452 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawDataPart_1hash(JNIEnv *env, jclass clz, int64_t o) {
51453         LDKRawDataPart o_conv;
51454         o_conv.inner = untag_ptr(o);
51455         o_conv.is_owned = ptr_is_owned(o);
51456         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
51457         o_conv.is_owned = false;
51458         int64_t ret_conv = RawDataPart_hash(&o_conv);
51459         return ret_conv;
51460 }
51461
51462 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
51463         LDKPositiveTimestamp this_obj_conv;
51464         this_obj_conv.inner = untag_ptr(this_obj);
51465         this_obj_conv.is_owned = ptr_is_owned(this_obj);
51466         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
51467         PositiveTimestamp_free(this_obj_conv);
51468 }
51469
51470 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
51471         LDKPositiveTimestamp a_conv;
51472         a_conv.inner = untag_ptr(a);
51473         a_conv.is_owned = ptr_is_owned(a);
51474         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
51475         a_conv.is_owned = false;
51476         LDKPositiveTimestamp b_conv;
51477         b_conv.inner = untag_ptr(b);
51478         b_conv.is_owned = ptr_is_owned(b);
51479         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
51480         b_conv.is_owned = false;
51481         jboolean ret_conv = PositiveTimestamp_eq(&a_conv, &b_conv);
51482         return ret_conv;
51483 }
51484
51485 static inline uint64_t PositiveTimestamp_clone_ptr(LDKPositiveTimestamp *NONNULL_PTR arg) {
51486         LDKPositiveTimestamp ret_var = PositiveTimestamp_clone(arg);
51487         int64_t ret_ref = 0;
51488         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
51489         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
51490         return ret_ref;
51491 }
51492 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
51493         LDKPositiveTimestamp arg_conv;
51494         arg_conv.inner = untag_ptr(arg);
51495         arg_conv.is_owned = ptr_is_owned(arg);
51496         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
51497         arg_conv.is_owned = false;
51498         int64_t ret_conv = PositiveTimestamp_clone_ptr(&arg_conv);
51499         return ret_conv;
51500 }
51501
51502 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1clone(JNIEnv *env, jclass clz, int64_t orig) {
51503         LDKPositiveTimestamp orig_conv;
51504         orig_conv.inner = untag_ptr(orig);
51505         orig_conv.is_owned = ptr_is_owned(orig);
51506         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
51507         orig_conv.is_owned = false;
51508         LDKPositiveTimestamp ret_var = PositiveTimestamp_clone(&orig_conv);
51509         int64_t ret_ref = 0;
51510         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
51511         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
51512         return ret_ref;
51513 }
51514
51515 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1hash(JNIEnv *env, jclass clz, int64_t o) {
51516         LDKPositiveTimestamp o_conv;
51517         o_conv.inner = untag_ptr(o);
51518         o_conv.is_owned = ptr_is_owned(o);
51519         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
51520         o_conv.is_owned = false;
51521         int64_t ret_conv = PositiveTimestamp_hash(&o_conv);
51522         return ret_conv;
51523 }
51524
51525 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SiPrefix_1clone(JNIEnv *env, jclass clz, int64_t orig) {
51526         LDKSiPrefix* orig_conv = (LDKSiPrefix*)untag_ptr(orig);
51527         jclass ret_conv = LDKSiPrefix_to_java(env, SiPrefix_clone(orig_conv));
51528         return ret_conv;
51529 }
51530
51531 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SiPrefix_1milli(JNIEnv *env, jclass clz) {
51532         jclass ret_conv = LDKSiPrefix_to_java(env, SiPrefix_milli());
51533         return ret_conv;
51534 }
51535
51536 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SiPrefix_1micro(JNIEnv *env, jclass clz) {
51537         jclass ret_conv = LDKSiPrefix_to_java(env, SiPrefix_micro());
51538         return ret_conv;
51539 }
51540
51541 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SiPrefix_1nano(JNIEnv *env, jclass clz) {
51542         jclass ret_conv = LDKSiPrefix_to_java(env, SiPrefix_nano());
51543         return ret_conv;
51544 }
51545
51546 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SiPrefix_1pico(JNIEnv *env, jclass clz) {
51547         jclass ret_conv = LDKSiPrefix_to_java(env, SiPrefix_pico());
51548         return ret_conv;
51549 }
51550
51551 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SiPrefix_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
51552         LDKSiPrefix* a_conv = (LDKSiPrefix*)untag_ptr(a);
51553         LDKSiPrefix* b_conv = (LDKSiPrefix*)untag_ptr(b);
51554         jboolean ret_conv = SiPrefix_eq(a_conv, b_conv);
51555         return ret_conv;
51556 }
51557
51558 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SiPrefix_1hash(JNIEnv *env, jclass clz, int64_t o) {
51559         LDKSiPrefix* o_conv = (LDKSiPrefix*)untag_ptr(o);
51560         int64_t ret_conv = SiPrefix_hash(o_conv);
51561         return ret_conv;
51562 }
51563
51564 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SiPrefix_1multiplier(JNIEnv *env, jclass clz, int64_t this_arg) {
51565         LDKSiPrefix* this_arg_conv = (LDKSiPrefix*)untag_ptr(this_arg);
51566         int64_t ret_conv = SiPrefix_multiplier(this_arg_conv);
51567         return ret_conv;
51568 }
51569
51570 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Currency_1clone(JNIEnv *env, jclass clz, int64_t orig) {
51571         LDKCurrency* orig_conv = (LDKCurrency*)untag_ptr(orig);
51572         jclass ret_conv = LDKCurrency_to_java(env, Currency_clone(orig_conv));
51573         return ret_conv;
51574 }
51575
51576 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Currency_1bitcoin(JNIEnv *env, jclass clz) {
51577         jclass ret_conv = LDKCurrency_to_java(env, Currency_bitcoin());
51578         return ret_conv;
51579 }
51580
51581 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Currency_1bitcoin_1testnet(JNIEnv *env, jclass clz) {
51582         jclass ret_conv = LDKCurrency_to_java(env, Currency_bitcoin_testnet());
51583         return ret_conv;
51584 }
51585
51586 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Currency_1regtest(JNIEnv *env, jclass clz) {
51587         jclass ret_conv = LDKCurrency_to_java(env, Currency_regtest());
51588         return ret_conv;
51589 }
51590
51591 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Currency_1simnet(JNIEnv *env, jclass clz) {
51592         jclass ret_conv = LDKCurrency_to_java(env, Currency_simnet());
51593         return ret_conv;
51594 }
51595
51596 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Currency_1signet(JNIEnv *env, jclass clz) {
51597         jclass ret_conv = LDKCurrency_to_java(env, Currency_signet());
51598         return ret_conv;
51599 }
51600
51601 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Currency_1hash(JNIEnv *env, jclass clz, int64_t o) {
51602         LDKCurrency* o_conv = (LDKCurrency*)untag_ptr(o);
51603         int64_t ret_conv = Currency_hash(o_conv);
51604         return ret_conv;
51605 }
51606
51607 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Currency_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
51608         LDKCurrency* a_conv = (LDKCurrency*)untag_ptr(a);
51609         LDKCurrency* b_conv = (LDKCurrency*)untag_ptr(b);
51610         jboolean ret_conv = Currency_eq(a_conv, b_conv);
51611         return ret_conv;
51612 }
51613
51614 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Sha256_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
51615         LDKSha256 this_obj_conv;
51616         this_obj_conv.inner = untag_ptr(this_obj);
51617         this_obj_conv.is_owned = ptr_is_owned(this_obj);
51618         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
51619         Sha256_free(this_obj_conv);
51620 }
51621
51622 static inline uint64_t Sha256_clone_ptr(LDKSha256 *NONNULL_PTR arg) {
51623         LDKSha256 ret_var = Sha256_clone(arg);
51624         int64_t ret_ref = 0;
51625         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
51626         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
51627         return ret_ref;
51628 }
51629 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Sha256_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
51630         LDKSha256 arg_conv;
51631         arg_conv.inner = untag_ptr(arg);
51632         arg_conv.is_owned = ptr_is_owned(arg);
51633         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
51634         arg_conv.is_owned = false;
51635         int64_t ret_conv = Sha256_clone_ptr(&arg_conv);
51636         return ret_conv;
51637 }
51638
51639 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Sha256_1clone(JNIEnv *env, jclass clz, int64_t orig) {
51640         LDKSha256 orig_conv;
51641         orig_conv.inner = untag_ptr(orig);
51642         orig_conv.is_owned = ptr_is_owned(orig);
51643         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
51644         orig_conv.is_owned = false;
51645         LDKSha256 ret_var = Sha256_clone(&orig_conv);
51646         int64_t ret_ref = 0;
51647         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
51648         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
51649         return ret_ref;
51650 }
51651
51652 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Sha256_1hash(JNIEnv *env, jclass clz, int64_t o) {
51653         LDKSha256 o_conv;
51654         o_conv.inner = untag_ptr(o);
51655         o_conv.is_owned = ptr_is_owned(o);
51656         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
51657         o_conv.is_owned = false;
51658         int64_t ret_conv = Sha256_hash(&o_conv);
51659         return ret_conv;
51660 }
51661
51662 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Sha256_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
51663         LDKSha256 a_conv;
51664         a_conv.inner = untag_ptr(a);
51665         a_conv.is_owned = ptr_is_owned(a);
51666         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
51667         a_conv.is_owned = false;
51668         LDKSha256 b_conv;
51669         b_conv.inner = untag_ptr(b);
51670         b_conv.is_owned = ptr_is_owned(b);
51671         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
51672         b_conv.is_owned = false;
51673         jboolean ret_conv = Sha256_eq(&a_conv, &b_conv);
51674         return ret_conv;
51675 }
51676
51677 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Description_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
51678         LDKDescription this_obj_conv;
51679         this_obj_conv.inner = untag_ptr(this_obj);
51680         this_obj_conv.is_owned = ptr_is_owned(this_obj);
51681         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
51682         Description_free(this_obj_conv);
51683 }
51684
51685 static inline uint64_t Description_clone_ptr(LDKDescription *NONNULL_PTR arg) {
51686         LDKDescription ret_var = Description_clone(arg);
51687         int64_t ret_ref = 0;
51688         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
51689         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
51690         return ret_ref;
51691 }
51692 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Description_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
51693         LDKDescription arg_conv;
51694         arg_conv.inner = untag_ptr(arg);
51695         arg_conv.is_owned = ptr_is_owned(arg);
51696         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
51697         arg_conv.is_owned = false;
51698         int64_t ret_conv = Description_clone_ptr(&arg_conv);
51699         return ret_conv;
51700 }
51701
51702 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Description_1clone(JNIEnv *env, jclass clz, int64_t orig) {
51703         LDKDescription orig_conv;
51704         orig_conv.inner = untag_ptr(orig);
51705         orig_conv.is_owned = ptr_is_owned(orig);
51706         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
51707         orig_conv.is_owned = false;
51708         LDKDescription ret_var = Description_clone(&orig_conv);
51709         int64_t ret_ref = 0;
51710         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
51711         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
51712         return ret_ref;
51713 }
51714
51715 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Description_1hash(JNIEnv *env, jclass clz, int64_t o) {
51716         LDKDescription o_conv;
51717         o_conv.inner = untag_ptr(o);
51718         o_conv.is_owned = ptr_is_owned(o);
51719         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
51720         o_conv.is_owned = false;
51721         int64_t ret_conv = Description_hash(&o_conv);
51722         return ret_conv;
51723 }
51724
51725 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Description_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
51726         LDKDescription a_conv;
51727         a_conv.inner = untag_ptr(a);
51728         a_conv.is_owned = ptr_is_owned(a);
51729         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
51730         a_conv.is_owned = false;
51731         LDKDescription b_conv;
51732         b_conv.inner = untag_ptr(b);
51733         b_conv.is_owned = ptr_is_owned(b);
51734         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
51735         b_conv.is_owned = false;
51736         jboolean ret_conv = Description_eq(&a_conv, &b_conv);
51737         return ret_conv;
51738 }
51739
51740 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
51741         LDKPayeePubKey this_obj_conv;
51742         this_obj_conv.inner = untag_ptr(this_obj);
51743         this_obj_conv.is_owned = ptr_is_owned(this_obj);
51744         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
51745         PayeePubKey_free(this_obj_conv);
51746 }
51747
51748 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1get_1a(JNIEnv *env, jclass clz, int64_t this_ptr) {
51749         LDKPayeePubKey this_ptr_conv;
51750         this_ptr_conv.inner = untag_ptr(this_ptr);
51751         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
51752         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
51753         this_ptr_conv.is_owned = false;
51754         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
51755         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, PayeePubKey_get_a(&this_ptr_conv).compressed_form);
51756         return ret_arr;
51757 }
51758
51759 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1set_1a(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
51760         LDKPayeePubKey this_ptr_conv;
51761         this_ptr_conv.inner = untag_ptr(this_ptr);
51762         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
51763         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
51764         this_ptr_conv.is_owned = false;
51765         LDKPublicKey val_ref;
51766         CHECK((*env)->GetArrayLength(env, val) == 33);
51767         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
51768         PayeePubKey_set_a(&this_ptr_conv, val_ref);
51769 }
51770
51771 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1new(JNIEnv *env, jclass clz, int8_tArray a_arg) {
51772         LDKPublicKey a_arg_ref;
51773         CHECK((*env)->GetArrayLength(env, a_arg) == 33);
51774         (*env)->GetByteArrayRegion(env, a_arg, 0, 33, a_arg_ref.compressed_form);
51775         LDKPayeePubKey ret_var = PayeePubKey_new(a_arg_ref);
51776         int64_t ret_ref = 0;
51777         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
51778         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
51779         return ret_ref;
51780 }
51781
51782 static inline uint64_t PayeePubKey_clone_ptr(LDKPayeePubKey *NONNULL_PTR arg) {
51783         LDKPayeePubKey ret_var = PayeePubKey_clone(arg);
51784         int64_t ret_ref = 0;
51785         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
51786         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
51787         return ret_ref;
51788 }
51789 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
51790         LDKPayeePubKey arg_conv;
51791         arg_conv.inner = untag_ptr(arg);
51792         arg_conv.is_owned = ptr_is_owned(arg);
51793         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
51794         arg_conv.is_owned = false;
51795         int64_t ret_conv = PayeePubKey_clone_ptr(&arg_conv);
51796         return ret_conv;
51797 }
51798
51799 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1clone(JNIEnv *env, jclass clz, int64_t orig) {
51800         LDKPayeePubKey orig_conv;
51801         orig_conv.inner = untag_ptr(orig);
51802         orig_conv.is_owned = ptr_is_owned(orig);
51803         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
51804         orig_conv.is_owned = false;
51805         LDKPayeePubKey ret_var = PayeePubKey_clone(&orig_conv);
51806         int64_t ret_ref = 0;
51807         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
51808         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
51809         return ret_ref;
51810 }
51811
51812 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1hash(JNIEnv *env, jclass clz, int64_t o) {
51813         LDKPayeePubKey o_conv;
51814         o_conv.inner = untag_ptr(o);
51815         o_conv.is_owned = ptr_is_owned(o);
51816         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
51817         o_conv.is_owned = false;
51818         int64_t ret_conv = PayeePubKey_hash(&o_conv);
51819         return ret_conv;
51820 }
51821
51822 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
51823         LDKPayeePubKey a_conv;
51824         a_conv.inner = untag_ptr(a);
51825         a_conv.is_owned = ptr_is_owned(a);
51826         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
51827         a_conv.is_owned = false;
51828         LDKPayeePubKey b_conv;
51829         b_conv.inner = untag_ptr(b);
51830         b_conv.is_owned = ptr_is_owned(b);
51831         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
51832         b_conv.is_owned = false;
51833         jboolean ret_conv = PayeePubKey_eq(&a_conv, &b_conv);
51834         return ret_conv;
51835 }
51836
51837 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
51838         LDKExpiryTime this_obj_conv;
51839         this_obj_conv.inner = untag_ptr(this_obj);
51840         this_obj_conv.is_owned = ptr_is_owned(this_obj);
51841         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
51842         ExpiryTime_free(this_obj_conv);
51843 }
51844
51845 static inline uint64_t ExpiryTime_clone_ptr(LDKExpiryTime *NONNULL_PTR arg) {
51846         LDKExpiryTime ret_var = ExpiryTime_clone(arg);
51847         int64_t ret_ref = 0;
51848         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
51849         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
51850         return ret_ref;
51851 }
51852 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
51853         LDKExpiryTime arg_conv;
51854         arg_conv.inner = untag_ptr(arg);
51855         arg_conv.is_owned = ptr_is_owned(arg);
51856         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
51857         arg_conv.is_owned = false;
51858         int64_t ret_conv = ExpiryTime_clone_ptr(&arg_conv);
51859         return ret_conv;
51860 }
51861
51862 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1clone(JNIEnv *env, jclass clz, int64_t orig) {
51863         LDKExpiryTime orig_conv;
51864         orig_conv.inner = untag_ptr(orig);
51865         orig_conv.is_owned = ptr_is_owned(orig);
51866         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
51867         orig_conv.is_owned = false;
51868         LDKExpiryTime ret_var = ExpiryTime_clone(&orig_conv);
51869         int64_t ret_ref = 0;
51870         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
51871         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
51872         return ret_ref;
51873 }
51874
51875 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1hash(JNIEnv *env, jclass clz, int64_t o) {
51876         LDKExpiryTime o_conv;
51877         o_conv.inner = untag_ptr(o);
51878         o_conv.is_owned = ptr_is_owned(o);
51879         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
51880         o_conv.is_owned = false;
51881         int64_t ret_conv = ExpiryTime_hash(&o_conv);
51882         return ret_conv;
51883 }
51884
51885 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
51886         LDKExpiryTime a_conv;
51887         a_conv.inner = untag_ptr(a);
51888         a_conv.is_owned = ptr_is_owned(a);
51889         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
51890         a_conv.is_owned = false;
51891         LDKExpiryTime b_conv;
51892         b_conv.inner = untag_ptr(b);
51893         b_conv.is_owned = ptr_is_owned(b);
51894         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
51895         b_conv.is_owned = false;
51896         jboolean ret_conv = ExpiryTime_eq(&a_conv, &b_conv);
51897         return ret_conv;
51898 }
51899
51900 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
51901         LDKMinFinalCltvExpiry this_obj_conv;
51902         this_obj_conv.inner = untag_ptr(this_obj);
51903         this_obj_conv.is_owned = ptr_is_owned(this_obj);
51904         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
51905         MinFinalCltvExpiry_free(this_obj_conv);
51906 }
51907
51908 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1get_1a(JNIEnv *env, jclass clz, int64_t this_ptr) {
51909         LDKMinFinalCltvExpiry this_ptr_conv;
51910         this_ptr_conv.inner = untag_ptr(this_ptr);
51911         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
51912         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
51913         this_ptr_conv.is_owned = false;
51914         int64_t ret_conv = MinFinalCltvExpiry_get_a(&this_ptr_conv);
51915         return ret_conv;
51916 }
51917
51918 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1set_1a(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
51919         LDKMinFinalCltvExpiry this_ptr_conv;
51920         this_ptr_conv.inner = untag_ptr(this_ptr);
51921         this_ptr_conv.is_owned = ptr_is_owned(this_ptr);
51922         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
51923         this_ptr_conv.is_owned = false;
51924         MinFinalCltvExpiry_set_a(&this_ptr_conv, val);
51925 }
51926
51927 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1new(JNIEnv *env, jclass clz, int64_t a_arg) {
51928         LDKMinFinalCltvExpiry ret_var = MinFinalCltvExpiry_new(a_arg);
51929         int64_t ret_ref = 0;
51930         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
51931         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
51932         return ret_ref;
51933 }
51934
51935 static inline uint64_t MinFinalCltvExpiry_clone_ptr(LDKMinFinalCltvExpiry *NONNULL_PTR arg) {
51936         LDKMinFinalCltvExpiry ret_var = MinFinalCltvExpiry_clone(arg);
51937         int64_t ret_ref = 0;
51938         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
51939         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
51940         return ret_ref;
51941 }
51942 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
51943         LDKMinFinalCltvExpiry arg_conv;
51944         arg_conv.inner = untag_ptr(arg);
51945         arg_conv.is_owned = ptr_is_owned(arg);
51946         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
51947         arg_conv.is_owned = false;
51948         int64_t ret_conv = MinFinalCltvExpiry_clone_ptr(&arg_conv);
51949         return ret_conv;
51950 }
51951
51952 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1clone(JNIEnv *env, jclass clz, int64_t orig) {
51953         LDKMinFinalCltvExpiry orig_conv;
51954         orig_conv.inner = untag_ptr(orig);
51955         orig_conv.is_owned = ptr_is_owned(orig);
51956         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
51957         orig_conv.is_owned = false;
51958         LDKMinFinalCltvExpiry ret_var = MinFinalCltvExpiry_clone(&orig_conv);
51959         int64_t ret_ref = 0;
51960         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
51961         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
51962         return ret_ref;
51963 }
51964
51965 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1hash(JNIEnv *env, jclass clz, int64_t o) {
51966         LDKMinFinalCltvExpiry o_conv;
51967         o_conv.inner = untag_ptr(o);
51968         o_conv.is_owned = ptr_is_owned(o);
51969         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
51970         o_conv.is_owned = false;
51971         int64_t ret_conv = MinFinalCltvExpiry_hash(&o_conv);
51972         return ret_conv;
51973 }
51974
51975 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
51976         LDKMinFinalCltvExpiry a_conv;
51977         a_conv.inner = untag_ptr(a);
51978         a_conv.is_owned = ptr_is_owned(a);
51979         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
51980         a_conv.is_owned = false;
51981         LDKMinFinalCltvExpiry b_conv;
51982         b_conv.inner = untag_ptr(b);
51983         b_conv.is_owned = ptr_is_owned(b);
51984         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
51985         b_conv.is_owned = false;
51986         jboolean ret_conv = MinFinalCltvExpiry_eq(&a_conv, &b_conv);
51987         return ret_conv;
51988 }
51989
51990 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Fallback_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
51991         if (!ptr_is_owned(this_ptr)) return;
51992         void* this_ptr_ptr = untag_ptr(this_ptr);
51993         CHECK_ACCESS(this_ptr_ptr);
51994         LDKFallback this_ptr_conv = *(LDKFallback*)(this_ptr_ptr);
51995         FREE(untag_ptr(this_ptr));
51996         Fallback_free(this_ptr_conv);
51997 }
51998
51999 static inline uint64_t Fallback_clone_ptr(LDKFallback *NONNULL_PTR arg) {
52000         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
52001         *ret_copy = Fallback_clone(arg);
52002         int64_t ret_ref = tag_ptr(ret_copy, true);
52003         return ret_ref;
52004 }
52005 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Fallback_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
52006         LDKFallback* arg_conv = (LDKFallback*)untag_ptr(arg);
52007         int64_t ret_conv = Fallback_clone_ptr(arg_conv);
52008         return ret_conv;
52009 }
52010
52011 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Fallback_1clone(JNIEnv *env, jclass clz, int64_t orig) {
52012         LDKFallback* orig_conv = (LDKFallback*)untag_ptr(orig);
52013         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
52014         *ret_copy = Fallback_clone(orig_conv);
52015         int64_t ret_ref = tag_ptr(ret_copy, true);
52016         return ret_ref;
52017 }
52018
52019 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Fallback_1seg_1wit_1program(JNIEnv *env, jclass clz, int8_t version, int8_tArray program) {
52020         
52021         LDKCVec_u8Z program_ref;
52022         program_ref.datalen = (*env)->GetArrayLength(env, program);
52023         program_ref.data = MALLOC(program_ref.datalen, "LDKCVec_u8Z Bytes");
52024         (*env)->GetByteArrayRegion(env, program, 0, program_ref.datalen, program_ref.data);
52025         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
52026         *ret_copy = Fallback_seg_wit_program((LDKU5){ ._0 = version }, program_ref);
52027         int64_t ret_ref = tag_ptr(ret_copy, true);
52028         return ret_ref;
52029 }
52030
52031 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Fallback_1pub_1key_1hash(JNIEnv *env, jclass clz, int8_tArray a) {
52032         LDKTwentyBytes a_ref;
52033         CHECK((*env)->GetArrayLength(env, a) == 20);
52034         (*env)->GetByteArrayRegion(env, a, 0, 20, a_ref.data);
52035         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
52036         *ret_copy = Fallback_pub_key_hash(a_ref);
52037         int64_t ret_ref = tag_ptr(ret_copy, true);
52038         return ret_ref;
52039 }
52040
52041 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Fallback_1script_1hash(JNIEnv *env, jclass clz, int8_tArray a) {
52042         LDKTwentyBytes a_ref;
52043         CHECK((*env)->GetArrayLength(env, a) == 20);
52044         (*env)->GetByteArrayRegion(env, a, 0, 20, a_ref.data);
52045         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
52046         *ret_copy = Fallback_script_hash(a_ref);
52047         int64_t ret_ref = tag_ptr(ret_copy, true);
52048         return ret_ref;
52049 }
52050
52051 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Fallback_1hash(JNIEnv *env, jclass clz, int64_t o) {
52052         LDKFallback* o_conv = (LDKFallback*)untag_ptr(o);
52053         int64_t ret_conv = Fallback_hash(o_conv);
52054         return ret_conv;
52055 }
52056
52057 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Fallback_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
52058         LDKFallback* a_conv = (LDKFallback*)untag_ptr(a);
52059         LDKFallback* b_conv = (LDKFallback*)untag_ptr(b);
52060         jboolean ret_conv = Fallback_eq(a_conv, b_conv);
52061         return ret_conv;
52062 }
52063
52064 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoiceSignature_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
52065         LDKInvoiceSignature this_obj_conv;
52066         this_obj_conv.inner = untag_ptr(this_obj);
52067         this_obj_conv.is_owned = ptr_is_owned(this_obj);
52068         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
52069         InvoiceSignature_free(this_obj_conv);
52070 }
52071
52072 static inline uint64_t InvoiceSignature_clone_ptr(LDKInvoiceSignature *NONNULL_PTR arg) {
52073         LDKInvoiceSignature ret_var = InvoiceSignature_clone(arg);
52074         int64_t ret_ref = 0;
52075         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
52076         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
52077         return ret_ref;
52078 }
52079 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceSignature_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
52080         LDKInvoiceSignature arg_conv;
52081         arg_conv.inner = untag_ptr(arg);
52082         arg_conv.is_owned = ptr_is_owned(arg);
52083         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
52084         arg_conv.is_owned = false;
52085         int64_t ret_conv = InvoiceSignature_clone_ptr(&arg_conv);
52086         return ret_conv;
52087 }
52088
52089 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceSignature_1clone(JNIEnv *env, jclass clz, int64_t orig) {
52090         LDKInvoiceSignature orig_conv;
52091         orig_conv.inner = untag_ptr(orig);
52092         orig_conv.is_owned = ptr_is_owned(orig);
52093         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
52094         orig_conv.is_owned = false;
52095         LDKInvoiceSignature ret_var = InvoiceSignature_clone(&orig_conv);
52096         int64_t ret_ref = 0;
52097         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
52098         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
52099         return ret_ref;
52100 }
52101
52102 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceSignature_1hash(JNIEnv *env, jclass clz, int64_t o) {
52103         LDKInvoiceSignature o_conv;
52104         o_conv.inner = untag_ptr(o);
52105         o_conv.is_owned = ptr_is_owned(o);
52106         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
52107         o_conv.is_owned = false;
52108         int64_t ret_conv = InvoiceSignature_hash(&o_conv);
52109         return ret_conv;
52110 }
52111
52112 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceSignature_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
52113         LDKInvoiceSignature a_conv;
52114         a_conv.inner = untag_ptr(a);
52115         a_conv.is_owned = ptr_is_owned(a);
52116         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
52117         a_conv.is_owned = false;
52118         LDKInvoiceSignature b_conv;
52119         b_conv.inner = untag_ptr(b);
52120         b_conv.is_owned = ptr_is_owned(b);
52121         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
52122         b_conv.is_owned = false;
52123         jboolean ret_conv = InvoiceSignature_eq(&a_conv, &b_conv);
52124         return ret_conv;
52125 }
52126
52127 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
52128         LDKPrivateRoute this_obj_conv;
52129         this_obj_conv.inner = untag_ptr(this_obj);
52130         this_obj_conv.is_owned = ptr_is_owned(this_obj);
52131         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
52132         PrivateRoute_free(this_obj_conv);
52133 }
52134
52135 static inline uint64_t PrivateRoute_clone_ptr(LDKPrivateRoute *NONNULL_PTR arg) {
52136         LDKPrivateRoute ret_var = PrivateRoute_clone(arg);
52137         int64_t ret_ref = 0;
52138         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
52139         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
52140         return ret_ref;
52141 }
52142 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
52143         LDKPrivateRoute arg_conv;
52144         arg_conv.inner = untag_ptr(arg);
52145         arg_conv.is_owned = ptr_is_owned(arg);
52146         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
52147         arg_conv.is_owned = false;
52148         int64_t ret_conv = PrivateRoute_clone_ptr(&arg_conv);
52149         return ret_conv;
52150 }
52151
52152 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1clone(JNIEnv *env, jclass clz, int64_t orig) {
52153         LDKPrivateRoute orig_conv;
52154         orig_conv.inner = untag_ptr(orig);
52155         orig_conv.is_owned = ptr_is_owned(orig);
52156         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
52157         orig_conv.is_owned = false;
52158         LDKPrivateRoute ret_var = PrivateRoute_clone(&orig_conv);
52159         int64_t ret_ref = 0;
52160         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
52161         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
52162         return ret_ref;
52163 }
52164
52165 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1hash(JNIEnv *env, jclass clz, int64_t o) {
52166         LDKPrivateRoute o_conv;
52167         o_conv.inner = untag_ptr(o);
52168         o_conv.is_owned = ptr_is_owned(o);
52169         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
52170         o_conv.is_owned = false;
52171         int64_t ret_conv = PrivateRoute_hash(&o_conv);
52172         return ret_conv;
52173 }
52174
52175 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
52176         LDKPrivateRoute a_conv;
52177         a_conv.inner = untag_ptr(a);
52178         a_conv.is_owned = ptr_is_owned(a);
52179         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
52180         a_conv.is_owned = false;
52181         LDKPrivateRoute b_conv;
52182         b_conv.inner = untag_ptr(b);
52183         b_conv.is_owned = ptr_is_owned(b);
52184         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
52185         b_conv.is_owned = false;
52186         jboolean ret_conv = PrivateRoute_eq(&a_conv, &b_conv);
52187         return ret_conv;
52188 }
52189
52190 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1into_1parts(JNIEnv *env, jclass clz, int64_t this_arg) {
52191         LDKSignedRawInvoice this_arg_conv;
52192         this_arg_conv.inner = untag_ptr(this_arg);
52193         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52194         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52195         this_arg_conv = SignedRawInvoice_clone(&this_arg_conv);
52196         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
52197         *ret_conv = SignedRawInvoice_into_parts(this_arg_conv);
52198         return tag_ptr(ret_conv, true);
52199 }
52200
52201 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1raw_1invoice(JNIEnv *env, jclass clz, int64_t this_arg) {
52202         LDKSignedRawInvoice this_arg_conv;
52203         this_arg_conv.inner = untag_ptr(this_arg);
52204         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52205         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52206         this_arg_conv.is_owned = false;
52207         LDKRawInvoice ret_var = SignedRawInvoice_raw_invoice(&this_arg_conv);
52208         int64_t ret_ref = 0;
52209         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
52210         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
52211         return ret_ref;
52212 }
52213
52214 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1signable_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
52215         LDKSignedRawInvoice this_arg_conv;
52216         this_arg_conv.inner = untag_ptr(this_arg);
52217         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52218         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52219         this_arg_conv.is_owned = false;
52220         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
52221         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *SignedRawInvoice_signable_hash(&this_arg_conv));
52222         return ret_arr;
52223 }
52224
52225 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1signature(JNIEnv *env, jclass clz, int64_t this_arg) {
52226         LDKSignedRawInvoice this_arg_conv;
52227         this_arg_conv.inner = untag_ptr(this_arg);
52228         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52229         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52230         this_arg_conv.is_owned = false;
52231         LDKInvoiceSignature ret_var = SignedRawInvoice_signature(&this_arg_conv);
52232         int64_t ret_ref = 0;
52233         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
52234         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
52235         return ret_ref;
52236 }
52237
52238 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1recover_1payee_1pub_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
52239         LDKSignedRawInvoice this_arg_conv;
52240         this_arg_conv.inner = untag_ptr(this_arg);
52241         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52242         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52243         this_arg_conv.is_owned = false;
52244         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
52245         *ret_conv = SignedRawInvoice_recover_payee_pub_key(&this_arg_conv);
52246         return tag_ptr(ret_conv, true);
52247 }
52248
52249 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1check_1signature(JNIEnv *env, jclass clz, int64_t this_arg) {
52250         LDKSignedRawInvoice this_arg_conv;
52251         this_arg_conv.inner = untag_ptr(this_arg);
52252         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52253         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52254         this_arg_conv.is_owned = false;
52255         jboolean ret_conv = SignedRawInvoice_check_signature(&this_arg_conv);
52256         return ret_conv;
52257 }
52258
52259 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RawInvoice_1signable_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
52260         LDKRawInvoice this_arg_conv;
52261         this_arg_conv.inner = untag_ptr(this_arg);
52262         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52263         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52264         this_arg_conv.is_owned = false;
52265         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
52266         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, RawInvoice_signable_hash(&this_arg_conv).data);
52267         return ret_arr;
52268 }
52269
52270 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
52271         LDKRawInvoice this_arg_conv;
52272         this_arg_conv.inner = untag_ptr(this_arg);
52273         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52274         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52275         this_arg_conv.is_owned = false;
52276         LDKSha256 ret_var = RawInvoice_payment_hash(&this_arg_conv);
52277         int64_t ret_ref = 0;
52278         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
52279         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
52280         return ret_ref;
52281 }
52282
52283 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1description(JNIEnv *env, jclass clz, int64_t this_arg) {
52284         LDKRawInvoice this_arg_conv;
52285         this_arg_conv.inner = untag_ptr(this_arg);
52286         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52287         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52288         this_arg_conv.is_owned = false;
52289         LDKDescription ret_var = RawInvoice_description(&this_arg_conv);
52290         int64_t ret_ref = 0;
52291         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
52292         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
52293         return ret_ref;
52294 }
52295
52296 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1payee_1pub_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
52297         LDKRawInvoice this_arg_conv;
52298         this_arg_conv.inner = untag_ptr(this_arg);
52299         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52300         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52301         this_arg_conv.is_owned = false;
52302         LDKPayeePubKey ret_var = RawInvoice_payee_pub_key(&this_arg_conv);
52303         int64_t ret_ref = 0;
52304         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
52305         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
52306         return ret_ref;
52307 }
52308
52309 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1description_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
52310         LDKRawInvoice this_arg_conv;
52311         this_arg_conv.inner = untag_ptr(this_arg);
52312         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52313         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52314         this_arg_conv.is_owned = false;
52315         LDKSha256 ret_var = RawInvoice_description_hash(&this_arg_conv);
52316         int64_t ret_ref = 0;
52317         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
52318         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
52319         return ret_ref;
52320 }
52321
52322 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1expiry_1time(JNIEnv *env, jclass clz, int64_t this_arg) {
52323         LDKRawInvoice this_arg_conv;
52324         this_arg_conv.inner = untag_ptr(this_arg);
52325         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52326         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52327         this_arg_conv.is_owned = false;
52328         LDKExpiryTime ret_var = RawInvoice_expiry_time(&this_arg_conv);
52329         int64_t ret_ref = 0;
52330         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
52331         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
52332         return ret_ref;
52333 }
52334
52335 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1min_1final_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_arg) {
52336         LDKRawInvoice this_arg_conv;
52337         this_arg_conv.inner = untag_ptr(this_arg);
52338         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52339         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52340         this_arg_conv.is_owned = false;
52341         LDKMinFinalCltvExpiry ret_var = RawInvoice_min_final_cltv_expiry(&this_arg_conv);
52342         int64_t ret_ref = 0;
52343         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
52344         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
52345         return ret_ref;
52346 }
52347
52348 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RawInvoice_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
52349         LDKRawInvoice this_arg_conv;
52350         this_arg_conv.inner = untag_ptr(this_arg);
52351         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52352         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52353         this_arg_conv.is_owned = false;
52354         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
52355         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, RawInvoice_payment_secret(&this_arg_conv).data);
52356         return ret_arr;
52357 }
52358
52359 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1features(JNIEnv *env, jclass clz, int64_t this_arg) {
52360         LDKRawInvoice this_arg_conv;
52361         this_arg_conv.inner = untag_ptr(this_arg);
52362         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52363         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52364         this_arg_conv.is_owned = false;
52365         LDKInvoiceFeatures ret_var = RawInvoice_features(&this_arg_conv);
52366         int64_t ret_ref = 0;
52367         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
52368         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
52369         return ret_ref;
52370 }
52371
52372 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_RawInvoice_1private_1routes(JNIEnv *env, jclass clz, int64_t this_arg) {
52373         LDKRawInvoice this_arg_conv;
52374         this_arg_conv.inner = untag_ptr(this_arg);
52375         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52376         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52377         this_arg_conv.is_owned = false;
52378         LDKCVec_PrivateRouteZ ret_var = RawInvoice_private_routes(&this_arg_conv);
52379         int64_tArray ret_arr = NULL;
52380         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
52381         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
52382         for (size_t o = 0; o < ret_var.datalen; o++) {
52383                 LDKPrivateRoute ret_conv_14_var = ret_var.data[o];
52384                 int64_t ret_conv_14_ref = 0;
52385                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_14_var);
52386                 ret_conv_14_ref = tag_ptr(ret_conv_14_var.inner, ret_conv_14_var.is_owned);
52387                 ret_arr_ptr[o] = ret_conv_14_ref;
52388         }
52389         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
52390         FREE(ret_var.data);
52391         return ret_arr;
52392 }
52393
52394 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1amount_1pico_1btc(JNIEnv *env, jclass clz, int64_t this_arg) {
52395         LDKRawInvoice this_arg_conv;
52396         this_arg_conv.inner = untag_ptr(this_arg);
52397         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52398         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52399         this_arg_conv.is_owned = false;
52400         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
52401         *ret_copy = RawInvoice_amount_pico_btc(&this_arg_conv);
52402         int64_t ret_ref = tag_ptr(ret_copy, true);
52403         return ret_ref;
52404 }
52405
52406 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_RawInvoice_1currency(JNIEnv *env, jclass clz, int64_t this_arg) {
52407         LDKRawInvoice this_arg_conv;
52408         this_arg_conv.inner = untag_ptr(this_arg);
52409         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52410         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52411         this_arg_conv.is_owned = false;
52412         jclass ret_conv = LDKCurrency_to_java(env, RawInvoice_currency(&this_arg_conv));
52413         return ret_conv;
52414 }
52415
52416 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1from_1unix_1timestamp(JNIEnv *env, jclass clz, int64_t unix_seconds) {
52417         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
52418         *ret_conv = PositiveTimestamp_from_unix_timestamp(unix_seconds);
52419         return tag_ptr(ret_conv, true);
52420 }
52421
52422 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1from_1system_1time(JNIEnv *env, jclass clz, int64_t time) {
52423         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
52424         *ret_conv = PositiveTimestamp_from_system_time(time);
52425         return tag_ptr(ret_conv, true);
52426 }
52427
52428 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1from_1duration_1since_1epoch(JNIEnv *env, jclass clz, int64_t duration) {
52429         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
52430         *ret_conv = PositiveTimestamp_from_duration_since_epoch(duration);
52431         return tag_ptr(ret_conv, true);
52432 }
52433
52434 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1as_1unix_1timestamp(JNIEnv *env, jclass clz, int64_t this_arg) {
52435         LDKPositiveTimestamp this_arg_conv;
52436         this_arg_conv.inner = untag_ptr(this_arg);
52437         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52438         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52439         this_arg_conv.is_owned = false;
52440         int64_t ret_conv = PositiveTimestamp_as_unix_timestamp(&this_arg_conv);
52441         return ret_conv;
52442 }
52443
52444 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1as_1duration_1since_1epoch(JNIEnv *env, jclass clz, int64_t this_arg) {
52445         LDKPositiveTimestamp this_arg_conv;
52446         this_arg_conv.inner = untag_ptr(this_arg);
52447         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52448         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52449         this_arg_conv.is_owned = false;
52450         int64_t ret_conv = PositiveTimestamp_as_duration_since_epoch(&this_arg_conv);
52451         return ret_conv;
52452 }
52453
52454 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1as_1time(JNIEnv *env, jclass clz, int64_t this_arg) {
52455         LDKPositiveTimestamp this_arg_conv;
52456         this_arg_conv.inner = untag_ptr(this_arg);
52457         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52458         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52459         this_arg_conv.is_owned = false;
52460         int64_t ret_conv = PositiveTimestamp_as_time(&this_arg_conv);
52461         return ret_conv;
52462 }
52463
52464 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1into_1signed_1raw(JNIEnv *env, jclass clz, int64_t this_arg) {
52465         LDKInvoice this_arg_conv;
52466         this_arg_conv.inner = untag_ptr(this_arg);
52467         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52468         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52469         this_arg_conv = Invoice_clone(&this_arg_conv);
52470         LDKSignedRawInvoice ret_var = Invoice_into_signed_raw(this_arg_conv);
52471         int64_t ret_ref = 0;
52472         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
52473         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
52474         return ret_ref;
52475 }
52476
52477 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1check_1signature(JNIEnv *env, jclass clz, int64_t this_arg) {
52478         LDKInvoice this_arg_conv;
52479         this_arg_conv.inner = untag_ptr(this_arg);
52480         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52481         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52482         this_arg_conv.is_owned = false;
52483         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
52484         *ret_conv = Invoice_check_signature(&this_arg_conv);
52485         return tag_ptr(ret_conv, true);
52486 }
52487
52488 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1from_1signed(JNIEnv *env, jclass clz, int64_t signed_invoice) {
52489         LDKSignedRawInvoice signed_invoice_conv;
52490         signed_invoice_conv.inner = untag_ptr(signed_invoice);
52491         signed_invoice_conv.is_owned = ptr_is_owned(signed_invoice);
52492         CHECK_INNER_FIELD_ACCESS_OR_NULL(signed_invoice_conv);
52493         signed_invoice_conv = SignedRawInvoice_clone(&signed_invoice_conv);
52494         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
52495         *ret_conv = Invoice_from_signed(signed_invoice_conv);
52496         return tag_ptr(ret_conv, true);
52497 }
52498
52499 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1timestamp(JNIEnv *env, jclass clz, int64_t this_arg) {
52500         LDKInvoice this_arg_conv;
52501         this_arg_conv.inner = untag_ptr(this_arg);
52502         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52503         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52504         this_arg_conv.is_owned = false;
52505         int64_t ret_conv = Invoice_timestamp(&this_arg_conv);
52506         return ret_conv;
52507 }
52508
52509 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1duration_1since_1epoch(JNIEnv *env, jclass clz, int64_t this_arg) {
52510         LDKInvoice this_arg_conv;
52511         this_arg_conv.inner = untag_ptr(this_arg);
52512         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52513         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52514         this_arg_conv.is_owned = false;
52515         int64_t ret_conv = Invoice_duration_since_epoch(&this_arg_conv);
52516         return ret_conv;
52517 }
52518
52519 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
52520         LDKInvoice this_arg_conv;
52521         this_arg_conv.inner = untag_ptr(this_arg);
52522         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52523         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52524         this_arg_conv.is_owned = false;
52525         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
52526         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *Invoice_payment_hash(&this_arg_conv));
52527         return ret_arr;
52528 }
52529
52530 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1payee_1pub_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
52531         LDKInvoice this_arg_conv;
52532         this_arg_conv.inner = untag_ptr(this_arg);
52533         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52534         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52535         this_arg_conv.is_owned = false;
52536         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
52537         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, Invoice_payee_pub_key(&this_arg_conv).compressed_form);
52538         return ret_arr;
52539 }
52540
52541 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
52542         LDKInvoice this_arg_conv;
52543         this_arg_conv.inner = untag_ptr(this_arg);
52544         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52545         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52546         this_arg_conv.is_owned = false;
52547         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
52548         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *Invoice_payment_secret(&this_arg_conv));
52549         return ret_arr;
52550 }
52551
52552 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1features(JNIEnv *env, jclass clz, int64_t this_arg) {
52553         LDKInvoice this_arg_conv;
52554         this_arg_conv.inner = untag_ptr(this_arg);
52555         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52556         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52557         this_arg_conv.is_owned = false;
52558         LDKInvoiceFeatures ret_var = Invoice_features(&this_arg_conv);
52559         int64_t ret_ref = 0;
52560         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
52561         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
52562         return ret_ref;
52563 }
52564
52565 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1recover_1payee_1pub_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
52566         LDKInvoice this_arg_conv;
52567         this_arg_conv.inner = untag_ptr(this_arg);
52568         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52569         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52570         this_arg_conv.is_owned = false;
52571         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
52572         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, Invoice_recover_payee_pub_key(&this_arg_conv).compressed_form);
52573         return ret_arr;
52574 }
52575
52576 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1expiry_1time(JNIEnv *env, jclass clz, int64_t this_arg) {
52577         LDKInvoice this_arg_conv;
52578         this_arg_conv.inner = untag_ptr(this_arg);
52579         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52580         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52581         this_arg_conv.is_owned = false;
52582         int64_t ret_conv = Invoice_expiry_time(&this_arg_conv);
52583         return ret_conv;
52584 }
52585
52586 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Invoice_1is_1expired(JNIEnv *env, jclass clz, int64_t this_arg) {
52587         LDKInvoice this_arg_conv;
52588         this_arg_conv.inner = untag_ptr(this_arg);
52589         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52590         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52591         this_arg_conv.is_owned = false;
52592         jboolean ret_conv = Invoice_is_expired(&this_arg_conv);
52593         return ret_conv;
52594 }
52595
52596 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Invoice_1would_1expire(JNIEnv *env, jclass clz, int64_t this_arg, int64_t at_time) {
52597         LDKInvoice this_arg_conv;
52598         this_arg_conv.inner = untag_ptr(this_arg);
52599         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52600         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52601         this_arg_conv.is_owned = false;
52602         jboolean ret_conv = Invoice_would_expire(&this_arg_conv, at_time);
52603         return ret_conv;
52604 }
52605
52606 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1min_1final_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_arg) {
52607         LDKInvoice this_arg_conv;
52608         this_arg_conv.inner = untag_ptr(this_arg);
52609         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52610         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52611         this_arg_conv.is_owned = false;
52612         int64_t ret_conv = Invoice_min_final_cltv_expiry(&this_arg_conv);
52613         return ret_conv;
52614 }
52615
52616 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1private_1routes(JNIEnv *env, jclass clz, int64_t this_arg) {
52617         LDKInvoice this_arg_conv;
52618         this_arg_conv.inner = untag_ptr(this_arg);
52619         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52620         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52621         this_arg_conv.is_owned = false;
52622         LDKCVec_PrivateRouteZ ret_var = Invoice_private_routes(&this_arg_conv);
52623         int64_tArray ret_arr = NULL;
52624         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
52625         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
52626         for (size_t o = 0; o < ret_var.datalen; o++) {
52627                 LDKPrivateRoute ret_conv_14_var = ret_var.data[o];
52628                 int64_t ret_conv_14_ref = 0;
52629                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_14_var);
52630                 ret_conv_14_ref = tag_ptr(ret_conv_14_var.inner, ret_conv_14_var.is_owned);
52631                 ret_arr_ptr[o] = ret_conv_14_ref;
52632         }
52633         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
52634         FREE(ret_var.data);
52635         return ret_arr;
52636 }
52637
52638 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1route_1hints(JNIEnv *env, jclass clz, int64_t this_arg) {
52639         LDKInvoice this_arg_conv;
52640         this_arg_conv.inner = untag_ptr(this_arg);
52641         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52642         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52643         this_arg_conv.is_owned = false;
52644         LDKCVec_RouteHintZ ret_var = Invoice_route_hints(&this_arg_conv);
52645         int64_tArray ret_arr = NULL;
52646         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
52647         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
52648         for (size_t l = 0; l < ret_var.datalen; l++) {
52649                 LDKRouteHint ret_conv_11_var = ret_var.data[l];
52650                 int64_t ret_conv_11_ref = 0;
52651                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_11_var);
52652                 ret_conv_11_ref = tag_ptr(ret_conv_11_var.inner, ret_conv_11_var.is_owned);
52653                 ret_arr_ptr[l] = ret_conv_11_ref;
52654         }
52655         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
52656         FREE(ret_var.data);
52657         return ret_arr;
52658 }
52659
52660 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Invoice_1currency(JNIEnv *env, jclass clz, int64_t this_arg) {
52661         LDKInvoice this_arg_conv;
52662         this_arg_conv.inner = untag_ptr(this_arg);
52663         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52664         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52665         this_arg_conv.is_owned = false;
52666         jclass ret_conv = LDKCurrency_to_java(env, Invoice_currency(&this_arg_conv));
52667         return ret_conv;
52668 }
52669
52670 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1amount_1milli_1satoshis(JNIEnv *env, jclass clz, int64_t this_arg) {
52671         LDKInvoice this_arg_conv;
52672         this_arg_conv.inner = untag_ptr(this_arg);
52673         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52674         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52675         this_arg_conv.is_owned = false;
52676         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
52677         *ret_copy = Invoice_amount_milli_satoshis(&this_arg_conv);
52678         int64_t ret_ref = tag_ptr(ret_copy, true);
52679         return ret_ref;
52680 }
52681
52682 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Description_1new(JNIEnv *env, jclass clz, jstring description) {
52683         LDKStr description_conv = java_to_owned_str(env, description);
52684         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
52685         *ret_conv = Description_new(description_conv);
52686         return tag_ptr(ret_conv, true);
52687 }
52688
52689 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Description_1into_1inner(JNIEnv *env, jclass clz, int64_t this_arg) {
52690         LDKDescription this_arg_conv;
52691         this_arg_conv.inner = untag_ptr(this_arg);
52692         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52693         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52694         this_arg_conv = Description_clone(&this_arg_conv);
52695         LDKStr ret_str = Description_into_inner(this_arg_conv);
52696         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
52697         Str_free(ret_str);
52698         return ret_conv;
52699 }
52700
52701 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1from_1seconds(JNIEnv *env, jclass clz, int64_t seconds) {
52702         LDKExpiryTime ret_var = ExpiryTime_from_seconds(seconds);
52703         int64_t ret_ref = 0;
52704         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
52705         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
52706         return ret_ref;
52707 }
52708
52709 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1from_1duration(JNIEnv *env, jclass clz, int64_t duration) {
52710         LDKExpiryTime ret_var = ExpiryTime_from_duration(duration);
52711         int64_t ret_ref = 0;
52712         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
52713         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
52714         return ret_ref;
52715 }
52716
52717 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1as_1seconds(JNIEnv *env, jclass clz, int64_t this_arg) {
52718         LDKExpiryTime this_arg_conv;
52719         this_arg_conv.inner = untag_ptr(this_arg);
52720         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52721         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52722         this_arg_conv.is_owned = false;
52723         int64_t ret_conv = ExpiryTime_as_seconds(&this_arg_conv);
52724         return ret_conv;
52725 }
52726
52727 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1as_1duration(JNIEnv *env, jclass clz, int64_t this_arg) {
52728         LDKExpiryTime this_arg_conv;
52729         this_arg_conv.inner = untag_ptr(this_arg);
52730         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52731         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52732         this_arg_conv.is_owned = false;
52733         int64_t ret_conv = ExpiryTime_as_duration(&this_arg_conv);
52734         return ret_conv;
52735 }
52736
52737 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1new(JNIEnv *env, jclass clz, int64_t hops) {
52738         LDKRouteHint hops_conv;
52739         hops_conv.inner = untag_ptr(hops);
52740         hops_conv.is_owned = ptr_is_owned(hops);
52741         CHECK_INNER_FIELD_ACCESS_OR_NULL(hops_conv);
52742         hops_conv = RouteHint_clone(&hops_conv);
52743         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
52744         *ret_conv = PrivateRoute_new(hops_conv);
52745         return tag_ptr(ret_conv, true);
52746 }
52747
52748 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1into_1inner(JNIEnv *env, jclass clz, int64_t this_arg) {
52749         LDKPrivateRoute this_arg_conv;
52750         this_arg_conv.inner = untag_ptr(this_arg);
52751         this_arg_conv.is_owned = ptr_is_owned(this_arg);
52752         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
52753         this_arg_conv = PrivateRoute_clone(&this_arg_conv);
52754         LDKRouteHint ret_var = PrivateRoute_into_inner(this_arg_conv);
52755         int64_t ret_ref = 0;
52756         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
52757         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
52758         return ret_ref;
52759 }
52760
52761 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CreationError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
52762         LDKCreationError* orig_conv = (LDKCreationError*)untag_ptr(orig);
52763         jclass ret_conv = LDKCreationError_to_java(env, CreationError_clone(orig_conv));
52764         return ret_conv;
52765 }
52766
52767 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CreationError_1description_1too_1long(JNIEnv *env, jclass clz) {
52768         jclass ret_conv = LDKCreationError_to_java(env, CreationError_description_too_long());
52769         return ret_conv;
52770 }
52771
52772 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CreationError_1route_1too_1long(JNIEnv *env, jclass clz) {
52773         jclass ret_conv = LDKCreationError_to_java(env, CreationError_route_too_long());
52774         return ret_conv;
52775 }
52776
52777 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CreationError_1timestamp_1out_1of_1bounds(JNIEnv *env, jclass clz) {
52778         jclass ret_conv = LDKCreationError_to_java(env, CreationError_timestamp_out_of_bounds());
52779         return ret_conv;
52780 }
52781
52782 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CreationError_1invalid_1amount(JNIEnv *env, jclass clz) {
52783         jclass ret_conv = LDKCreationError_to_java(env, CreationError_invalid_amount());
52784         return ret_conv;
52785 }
52786
52787 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CreationError_1missing_1route_1hints(JNIEnv *env, jclass clz) {
52788         jclass ret_conv = LDKCreationError_to_java(env, CreationError_missing_route_hints());
52789         return ret_conv;
52790 }
52791
52792 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CreationError_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
52793         LDKCreationError* a_conv = (LDKCreationError*)untag_ptr(a);
52794         LDKCreationError* b_conv = (LDKCreationError*)untag_ptr(b);
52795         jboolean ret_conv = CreationError_eq(a_conv, b_conv);
52796         return ret_conv;
52797 }
52798
52799 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_CreationError_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
52800         LDKCreationError* o_conv = (LDKCreationError*)untag_ptr(o);
52801         LDKStr ret_str = CreationError_to_str(o_conv);
52802         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
52803         Str_free(ret_str);
52804         return ret_conv;
52805 }
52806
52807 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
52808         LDKSemanticError* orig_conv = (LDKSemanticError*)untag_ptr(orig);
52809         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_clone(orig_conv));
52810         return ret_conv;
52811 }
52812
52813 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1no_1payment_1hash(JNIEnv *env, jclass clz) {
52814         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_no_payment_hash());
52815         return ret_conv;
52816 }
52817
52818 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1multiple_1payment_1hashes(JNIEnv *env, jclass clz) {
52819         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_multiple_payment_hashes());
52820         return ret_conv;
52821 }
52822
52823 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1no_1description(JNIEnv *env, jclass clz) {
52824         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_no_description());
52825         return ret_conv;
52826 }
52827
52828 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1multiple_1descriptions(JNIEnv *env, jclass clz) {
52829         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_multiple_descriptions());
52830         return ret_conv;
52831 }
52832
52833 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1no_1payment_1secret(JNIEnv *env, jclass clz) {
52834         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_no_payment_secret());
52835         return ret_conv;
52836 }
52837
52838 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1multiple_1payment_1secrets(JNIEnv *env, jclass clz) {
52839         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_multiple_payment_secrets());
52840         return ret_conv;
52841 }
52842
52843 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1invalid_1features(JNIEnv *env, jclass clz) {
52844         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_invalid_features());
52845         return ret_conv;
52846 }
52847
52848 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1invalid_1recovery_1id(JNIEnv *env, jclass clz) {
52849         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_invalid_recovery_id());
52850         return ret_conv;
52851 }
52852
52853 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1invalid_1signature(JNIEnv *env, jclass clz) {
52854         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_invalid_signature());
52855         return ret_conv;
52856 }
52857
52858 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1imprecise_1amount(JNIEnv *env, jclass clz) {
52859         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_imprecise_amount());
52860         return ret_conv;
52861 }
52862
52863 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SemanticError_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
52864         LDKSemanticError* a_conv = (LDKSemanticError*)untag_ptr(a);
52865         LDKSemanticError* b_conv = (LDKSemanticError*)untag_ptr(b);
52866         jboolean ret_conv = SemanticError_eq(a_conv, b_conv);
52867         return ret_conv;
52868 }
52869
52870 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_SemanticError_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
52871         LDKSemanticError* o_conv = (LDKSemanticError*)untag_ptr(o);
52872         LDKStr ret_str = SemanticError_to_str(o_conv);
52873         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
52874         Str_free(ret_str);
52875         return ret_conv;
52876 }
52877
52878 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
52879         if (!ptr_is_owned(this_ptr)) return;
52880         void* this_ptr_ptr = untag_ptr(this_ptr);
52881         CHECK_ACCESS(this_ptr_ptr);
52882         LDKSignOrCreationError this_ptr_conv = *(LDKSignOrCreationError*)(this_ptr_ptr);
52883         FREE(untag_ptr(this_ptr));
52884         SignOrCreationError_free(this_ptr_conv);
52885 }
52886
52887 static inline uint64_t SignOrCreationError_clone_ptr(LDKSignOrCreationError *NONNULL_PTR arg) {
52888         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
52889         *ret_copy = SignOrCreationError_clone(arg);
52890         int64_t ret_ref = tag_ptr(ret_copy, true);
52891         return ret_ref;
52892 }
52893 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
52894         LDKSignOrCreationError* arg_conv = (LDKSignOrCreationError*)untag_ptr(arg);
52895         int64_t ret_conv = SignOrCreationError_clone_ptr(arg_conv);
52896         return ret_conv;
52897 }
52898
52899 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
52900         LDKSignOrCreationError* orig_conv = (LDKSignOrCreationError*)untag_ptr(orig);
52901         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
52902         *ret_copy = SignOrCreationError_clone(orig_conv);
52903         int64_t ret_ref = tag_ptr(ret_copy, true);
52904         return ret_ref;
52905 }
52906
52907 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1sign_1error(JNIEnv *env, jclass clz) {
52908         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
52909         *ret_copy = SignOrCreationError_sign_error();
52910         int64_t ret_ref = tag_ptr(ret_copy, true);
52911         return ret_ref;
52912 }
52913
52914 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1creation_1error(JNIEnv *env, jclass clz, jclass a) {
52915         LDKCreationError a_conv = LDKCreationError_from_java(env, a);
52916         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
52917         *ret_copy = SignOrCreationError_creation_error(a_conv);
52918         int64_t ret_ref = tag_ptr(ret_copy, true);
52919         return ret_ref;
52920 }
52921
52922 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
52923         LDKSignOrCreationError* a_conv = (LDKSignOrCreationError*)untag_ptr(a);
52924         LDKSignOrCreationError* b_conv = (LDKSignOrCreationError*)untag_ptr(b);
52925         jboolean ret_conv = SignOrCreationError_eq(a_conv, b_conv);
52926         return ret_conv;
52927 }
52928
52929 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
52930         LDKSignOrCreationError* o_conv = (LDKSignOrCreationError*)untag_ptr(o);
52931         LDKStr ret_str = SignOrCreationError_to_str(o_conv);
52932         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
52933         Str_free(ret_str);
52934         return ret_conv;
52935 }
52936
52937 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoicePayer_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
52938         LDKInvoicePayer this_obj_conv;
52939         this_obj_conv.inner = untag_ptr(this_obj);
52940         this_obj_conv.is_owned = ptr_is_owned(this_obj);
52941         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
52942         InvoicePayer_free(this_obj_conv);
52943 }
52944
52945 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Payer_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
52946         if (!ptr_is_owned(this_ptr)) return;
52947         void* this_ptr_ptr = untag_ptr(this_ptr);
52948         CHECK_ACCESS(this_ptr_ptr);
52949         LDKPayer this_ptr_conv = *(LDKPayer*)(this_ptr_ptr);
52950         FREE(untag_ptr(this_ptr));
52951         Payer_free(this_ptr_conv);
52952 }
52953
52954 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Retry_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
52955         if (!ptr_is_owned(this_ptr)) return;
52956         void* this_ptr_ptr = untag_ptr(this_ptr);
52957         CHECK_ACCESS(this_ptr_ptr);
52958         LDKRetry this_ptr_conv = *(LDKRetry*)(this_ptr_ptr);
52959         FREE(untag_ptr(this_ptr));
52960         Retry_free(this_ptr_conv);
52961 }
52962
52963 static inline uint64_t Retry_clone_ptr(LDKRetry *NONNULL_PTR arg) {
52964         LDKRetry *ret_copy = MALLOC(sizeof(LDKRetry), "LDKRetry");
52965         *ret_copy = Retry_clone(arg);
52966         int64_t ret_ref = tag_ptr(ret_copy, true);
52967         return ret_ref;
52968 }
52969 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Retry_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
52970         LDKRetry* arg_conv = (LDKRetry*)untag_ptr(arg);
52971         int64_t ret_conv = Retry_clone_ptr(arg_conv);
52972         return ret_conv;
52973 }
52974
52975 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Retry_1clone(JNIEnv *env, jclass clz, int64_t orig) {
52976         LDKRetry* orig_conv = (LDKRetry*)untag_ptr(orig);
52977         LDKRetry *ret_copy = MALLOC(sizeof(LDKRetry), "LDKRetry");
52978         *ret_copy = Retry_clone(orig_conv);
52979         int64_t ret_ref = tag_ptr(ret_copy, true);
52980         return ret_ref;
52981 }
52982
52983 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Retry_1attempts(JNIEnv *env, jclass clz, int64_t a) {
52984         LDKRetry *ret_copy = MALLOC(sizeof(LDKRetry), "LDKRetry");
52985         *ret_copy = Retry_attempts(a);
52986         int64_t ret_ref = tag_ptr(ret_copy, true);
52987         return ret_ref;
52988 }
52989
52990 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Retry_1timeout(JNIEnv *env, jclass clz, int64_t a) {
52991         LDKRetry *ret_copy = MALLOC(sizeof(LDKRetry), "LDKRetry");
52992         *ret_copy = Retry_timeout(a);
52993         int64_t ret_ref = tag_ptr(ret_copy, true);
52994         return ret_ref;
52995 }
52996
52997 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Retry_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
52998         LDKRetry* a_conv = (LDKRetry*)untag_ptr(a);
52999         LDKRetry* b_conv = (LDKRetry*)untag_ptr(b);
53000         jboolean ret_conv = Retry_eq(a_conv, b_conv);
53001         return ret_conv;
53002 }
53003
53004 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Retry_1hash(JNIEnv *env, jclass clz, int64_t o) {
53005         LDKRetry* o_conv = (LDKRetry*)untag_ptr(o);
53006         int64_t ret_conv = Retry_hash(o_conv);
53007         return ret_conv;
53008 }
53009
53010 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentError_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
53011         if (!ptr_is_owned(this_ptr)) return;
53012         void* this_ptr_ptr = untag_ptr(this_ptr);
53013         CHECK_ACCESS(this_ptr_ptr);
53014         LDKPaymentError this_ptr_conv = *(LDKPaymentError*)(this_ptr_ptr);
53015         FREE(untag_ptr(this_ptr));
53016         PaymentError_free(this_ptr_conv);
53017 }
53018
53019 static inline uint64_t PaymentError_clone_ptr(LDKPaymentError *NONNULL_PTR arg) {
53020         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
53021         *ret_copy = PaymentError_clone(arg);
53022         int64_t ret_ref = tag_ptr(ret_copy, true);
53023         return ret_ref;
53024 }
53025 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
53026         LDKPaymentError* arg_conv = (LDKPaymentError*)untag_ptr(arg);
53027         int64_t ret_conv = PaymentError_clone_ptr(arg_conv);
53028         return ret_conv;
53029 }
53030
53031 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
53032         LDKPaymentError* orig_conv = (LDKPaymentError*)untag_ptr(orig);
53033         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
53034         *ret_copy = PaymentError_clone(orig_conv);
53035         int64_t ret_ref = tag_ptr(ret_copy, true);
53036         return ret_ref;
53037 }
53038
53039 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentError_1invoice(JNIEnv *env, jclass clz, jstring a) {
53040         LDKStr a_conv = java_to_owned_str(env, a);
53041         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
53042         *ret_copy = PaymentError_invoice(a_conv);
53043         int64_t ret_ref = tag_ptr(ret_copy, true);
53044         return ret_ref;
53045 }
53046
53047 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentError_1routing(JNIEnv *env, jclass clz, int64_t a) {
53048         LDKLightningError a_conv;
53049         a_conv.inner = untag_ptr(a);
53050         a_conv.is_owned = ptr_is_owned(a);
53051         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
53052         a_conv = LightningError_clone(&a_conv);
53053         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
53054         *ret_copy = PaymentError_routing(a_conv);
53055         int64_t ret_ref = tag_ptr(ret_copy, true);
53056         return ret_ref;
53057 }
53058
53059 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentError_1sending(JNIEnv *env, jclass clz, int64_t a) {
53060         void* a_ptr = untag_ptr(a);
53061         CHECK_ACCESS(a_ptr);
53062         LDKPaymentSendFailure a_conv = *(LDKPaymentSendFailure*)(a_ptr);
53063         a_conv = PaymentSendFailure_clone((LDKPaymentSendFailure*)untag_ptr(a));
53064         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
53065         *ret_copy = PaymentError_sending(a_conv);
53066         int64_t ret_ref = tag_ptr(ret_copy, true);
53067         return ret_ref;
53068 }
53069
53070 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) {
53071         void* payer_ptr = untag_ptr(payer);
53072         CHECK_ACCESS(payer_ptr);
53073         LDKPayer payer_conv = *(LDKPayer*)(payer_ptr);
53074         if (payer_conv.free == LDKPayer_JCalls_free) {
53075                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
53076                 LDKPayer_JCalls_cloned(&payer_conv);
53077         }
53078         void* router_ptr = untag_ptr(router);
53079         CHECK_ACCESS(router_ptr);
53080         LDKRouter router_conv = *(LDKRouter*)(router_ptr);
53081         if (router_conv.free == LDKRouter_JCalls_free) {
53082                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
53083                 LDKRouter_JCalls_cloned(&router_conv);
53084         }
53085         void* logger_ptr = untag_ptr(logger);
53086         CHECK_ACCESS(logger_ptr);
53087         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
53088         if (logger_conv.free == LDKLogger_JCalls_free) {
53089                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
53090                 LDKLogger_JCalls_cloned(&logger_conv);
53091         }
53092         void* event_handler_ptr = untag_ptr(event_handler);
53093         CHECK_ACCESS(event_handler_ptr);
53094         LDKEventHandler event_handler_conv = *(LDKEventHandler*)(event_handler_ptr);
53095         if (event_handler_conv.free == LDKEventHandler_JCalls_free) {
53096                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
53097                 LDKEventHandler_JCalls_cloned(&event_handler_conv);
53098         }
53099         void* retry_ptr = untag_ptr(retry);
53100         CHECK_ACCESS(retry_ptr);
53101         LDKRetry retry_conv = *(LDKRetry*)(retry_ptr);
53102         retry_conv = Retry_clone((LDKRetry*)untag_ptr(retry));
53103         LDKInvoicePayer ret_var = InvoicePayer_new(payer_conv, router_conv, logger_conv, event_handler_conv, retry_conv);
53104         int64_t ret_ref = 0;
53105         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
53106         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
53107         return ret_ref;
53108 }
53109
53110 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoicePayer_1pay_1invoice(JNIEnv *env, jclass clz, int64_t this_arg, int64_t invoice) {
53111         LDKInvoicePayer this_arg_conv;
53112         this_arg_conv.inner = untag_ptr(this_arg);
53113         this_arg_conv.is_owned = ptr_is_owned(this_arg);
53114         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
53115         this_arg_conv.is_owned = false;
53116         LDKInvoice invoice_conv;
53117         invoice_conv.inner = untag_ptr(invoice);
53118         invoice_conv.is_owned = ptr_is_owned(invoice);
53119         CHECK_INNER_FIELD_ACCESS_OR_NULL(invoice_conv);
53120         invoice_conv.is_owned = false;
53121         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
53122         *ret_conv = InvoicePayer_pay_invoice(&this_arg_conv, &invoice_conv);
53123         return tag_ptr(ret_conv, true);
53124 }
53125
53126 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoicePayer_1pay_1invoice_1with_1id(JNIEnv *env, jclass clz, int64_t this_arg, int64_t invoice, int8_tArray payment_id) {
53127         LDKInvoicePayer this_arg_conv;
53128         this_arg_conv.inner = untag_ptr(this_arg);
53129         this_arg_conv.is_owned = ptr_is_owned(this_arg);
53130         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
53131         this_arg_conv.is_owned = false;
53132         LDKInvoice invoice_conv;
53133         invoice_conv.inner = untag_ptr(invoice);
53134         invoice_conv.is_owned = ptr_is_owned(invoice);
53135         CHECK_INNER_FIELD_ACCESS_OR_NULL(invoice_conv);
53136         invoice_conv.is_owned = false;
53137         LDKThirtyTwoBytes payment_id_ref;
53138         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
53139         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
53140         LDKCResult_NonePaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentErrorZ), "LDKCResult_NonePaymentErrorZ");
53141         *ret_conv = InvoicePayer_pay_invoice_with_id(&this_arg_conv, &invoice_conv, payment_id_ref);
53142         return tag_ptr(ret_conv, true);
53143 }
53144
53145 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) {
53146         LDKInvoicePayer this_arg_conv;
53147         this_arg_conv.inner = untag_ptr(this_arg);
53148         this_arg_conv.is_owned = ptr_is_owned(this_arg);
53149         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
53150         this_arg_conv.is_owned = false;
53151         LDKInvoice invoice_conv;
53152         invoice_conv.inner = untag_ptr(invoice);
53153         invoice_conv.is_owned = ptr_is_owned(invoice);
53154         CHECK_INNER_FIELD_ACCESS_OR_NULL(invoice_conv);
53155         invoice_conv.is_owned = false;
53156         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
53157         *ret_conv = InvoicePayer_pay_zero_value_invoice(&this_arg_conv, &invoice_conv, amount_msats);
53158         return tag_ptr(ret_conv, true);
53159 }
53160
53161 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoicePayer_1pay_1zero_1value_1invoice_1with_1id(JNIEnv *env, jclass clz, int64_t this_arg, int64_t invoice, int64_t amount_msats, int8_tArray payment_id) {
53162         LDKInvoicePayer this_arg_conv;
53163         this_arg_conv.inner = untag_ptr(this_arg);
53164         this_arg_conv.is_owned = ptr_is_owned(this_arg);
53165         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
53166         this_arg_conv.is_owned = false;
53167         LDKInvoice invoice_conv;
53168         invoice_conv.inner = untag_ptr(invoice);
53169         invoice_conv.is_owned = ptr_is_owned(invoice);
53170         CHECK_INNER_FIELD_ACCESS_OR_NULL(invoice_conv);
53171         invoice_conv.is_owned = false;
53172         LDKThirtyTwoBytes payment_id_ref;
53173         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
53174         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
53175         LDKCResult_NonePaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentErrorZ), "LDKCResult_NonePaymentErrorZ");
53176         *ret_conv = InvoicePayer_pay_zero_value_invoice_with_id(&this_arg_conv, &invoice_conv, amount_msats, payment_id_ref);
53177         return tag_ptr(ret_conv, true);
53178 }
53179
53180 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) {
53181         LDKInvoicePayer this_arg_conv;
53182         this_arg_conv.inner = untag_ptr(this_arg);
53183         this_arg_conv.is_owned = ptr_is_owned(this_arg);
53184         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
53185         this_arg_conv.is_owned = false;
53186         LDKPublicKey pubkey_ref;
53187         CHECK((*env)->GetArrayLength(env, pubkey) == 33);
53188         (*env)->GetByteArrayRegion(env, pubkey, 0, 33, pubkey_ref.compressed_form);
53189         LDKThirtyTwoBytes payment_preimage_ref;
53190         CHECK((*env)->GetArrayLength(env, payment_preimage) == 32);
53191         (*env)->GetByteArrayRegion(env, payment_preimage, 0, 32, payment_preimage_ref.data);
53192         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
53193         *ret_conv = InvoicePayer_pay_pubkey(&this_arg_conv, pubkey_ref, payment_preimage_ref, amount_msats, final_cltv_expiry_delta);
53194         return tag_ptr(ret_conv, true);
53195 }
53196
53197 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoicePayer_1pay_1pubkey_1with_1id(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray pubkey, int8_tArray payment_preimage, int8_tArray payment_id, int64_t amount_msats, int32_t final_cltv_expiry_delta) {
53198         LDKInvoicePayer this_arg_conv;
53199         this_arg_conv.inner = untag_ptr(this_arg);
53200         this_arg_conv.is_owned = ptr_is_owned(this_arg);
53201         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
53202         this_arg_conv.is_owned = false;
53203         LDKPublicKey pubkey_ref;
53204         CHECK((*env)->GetArrayLength(env, pubkey) == 33);
53205         (*env)->GetByteArrayRegion(env, pubkey, 0, 33, pubkey_ref.compressed_form);
53206         LDKThirtyTwoBytes payment_preimage_ref;
53207         CHECK((*env)->GetArrayLength(env, payment_preimage) == 32);
53208         (*env)->GetByteArrayRegion(env, payment_preimage, 0, 32, payment_preimage_ref.data);
53209         LDKThirtyTwoBytes payment_id_ref;
53210         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
53211         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
53212         LDKCResult_NonePaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentErrorZ), "LDKCResult_NonePaymentErrorZ");
53213         *ret_conv = InvoicePayer_pay_pubkey_with_id(&this_arg_conv, pubkey_ref, payment_preimage_ref, payment_id_ref, amount_msats, final_cltv_expiry_delta);
53214         return tag_ptr(ret_conv, true);
53215 }
53216
53217 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoicePayer_1remove_1cached_1payment(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray payment_hash) {
53218         LDKInvoicePayer this_arg_conv;
53219         this_arg_conv.inner = untag_ptr(this_arg);
53220         this_arg_conv.is_owned = ptr_is_owned(this_arg);
53221         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
53222         this_arg_conv.is_owned = false;
53223         unsigned char payment_hash_arr[32];
53224         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
53225         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_arr);
53226         unsigned char (*payment_hash_ref)[32] = &payment_hash_arr;
53227         InvoicePayer_remove_cached_payment(&this_arg_conv, payment_hash_ref);
53228 }
53229
53230 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoicePayer_1as_1EventHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
53231         LDKInvoicePayer this_arg_conv;
53232         this_arg_conv.inner = untag_ptr(this_arg);
53233         this_arg_conv.is_owned = ptr_is_owned(this_arg);
53234         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
53235         this_arg_conv.is_owned = false;
53236         LDKEventHandler* ret_ret = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
53237         *ret_ret = InvoicePayer_as_EventHandler(&this_arg_conv);
53238         return tag_ptr(ret_ret, true);
53239 }
53240
53241 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) {
53242         void* amt_msat_ptr = untag_ptr(amt_msat);
53243         CHECK_ACCESS(amt_msat_ptr);
53244         LDKCOption_u64Z amt_msat_conv = *(LDKCOption_u64Z*)(amt_msat_ptr);
53245         amt_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(amt_msat));
53246         LDKThirtyTwoBytes payment_hash_ref;
53247         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
53248         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
53249         LDKStr description_conv = java_to_owned_str(env, description);
53250         LDKCVec_PhantomRouteHintsZ phantom_route_hints_constr;
53251         phantom_route_hints_constr.datalen = (*env)->GetArrayLength(env, phantom_route_hints);
53252         if (phantom_route_hints_constr.datalen > 0)
53253                 phantom_route_hints_constr.data = MALLOC(phantom_route_hints_constr.datalen * sizeof(LDKPhantomRouteHints), "LDKCVec_PhantomRouteHintsZ Elements");
53254         else
53255                 phantom_route_hints_constr.data = NULL;
53256         int64_t* phantom_route_hints_vals = (*env)->GetLongArrayElements (env, phantom_route_hints, NULL);
53257         for (size_t t = 0; t < phantom_route_hints_constr.datalen; t++) {
53258                 int64_t phantom_route_hints_conv_19 = phantom_route_hints_vals[t];
53259                 LDKPhantomRouteHints phantom_route_hints_conv_19_conv;
53260                 phantom_route_hints_conv_19_conv.inner = untag_ptr(phantom_route_hints_conv_19);
53261                 phantom_route_hints_conv_19_conv.is_owned = ptr_is_owned(phantom_route_hints_conv_19);
53262                 CHECK_INNER_FIELD_ACCESS_OR_NULL(phantom_route_hints_conv_19_conv);
53263                 phantom_route_hints_conv_19_conv = PhantomRouteHints_clone(&phantom_route_hints_conv_19_conv);
53264                 phantom_route_hints_constr.data[t] = phantom_route_hints_conv_19_conv;
53265         }
53266         (*env)->ReleaseLongArrayElements(env, phantom_route_hints, phantom_route_hints_vals, 0);
53267         void* keys_manager_ptr = untag_ptr(keys_manager);
53268         CHECK_ACCESS(keys_manager_ptr);
53269         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
53270         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
53271                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
53272                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
53273         }
53274         void* logger_ptr = untag_ptr(logger);
53275         CHECK_ACCESS(logger_ptr);
53276         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
53277         if (logger_conv.free == LDKLogger_JCalls_free) {
53278                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
53279                 LDKLogger_JCalls_cloned(&logger_conv);
53280         }
53281         LDKCurrency network_conv = LDKCurrency_from_java(env, network);
53282         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
53283         *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);
53284         return tag_ptr(ret_conv, true);
53285 }
53286
53287 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) {
53288         void* amt_msat_ptr = untag_ptr(amt_msat);
53289         CHECK_ACCESS(amt_msat_ptr);
53290         LDKCOption_u64Z amt_msat_conv = *(LDKCOption_u64Z*)(amt_msat_ptr);
53291         amt_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(amt_msat));
53292         LDKThirtyTwoBytes payment_hash_ref;
53293         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
53294         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
53295         LDKSha256 description_hash_conv;
53296         description_hash_conv.inner = untag_ptr(description_hash);
53297         description_hash_conv.is_owned = ptr_is_owned(description_hash);
53298         CHECK_INNER_FIELD_ACCESS_OR_NULL(description_hash_conv);
53299         description_hash_conv = Sha256_clone(&description_hash_conv);
53300         LDKCVec_PhantomRouteHintsZ phantom_route_hints_constr;
53301         phantom_route_hints_constr.datalen = (*env)->GetArrayLength(env, phantom_route_hints);
53302         if (phantom_route_hints_constr.datalen > 0)
53303                 phantom_route_hints_constr.data = MALLOC(phantom_route_hints_constr.datalen * sizeof(LDKPhantomRouteHints), "LDKCVec_PhantomRouteHintsZ Elements");
53304         else
53305                 phantom_route_hints_constr.data = NULL;
53306         int64_t* phantom_route_hints_vals = (*env)->GetLongArrayElements (env, phantom_route_hints, NULL);
53307         for (size_t t = 0; t < phantom_route_hints_constr.datalen; t++) {
53308                 int64_t phantom_route_hints_conv_19 = phantom_route_hints_vals[t];
53309                 LDKPhantomRouteHints phantom_route_hints_conv_19_conv;
53310                 phantom_route_hints_conv_19_conv.inner = untag_ptr(phantom_route_hints_conv_19);
53311                 phantom_route_hints_conv_19_conv.is_owned = ptr_is_owned(phantom_route_hints_conv_19);
53312                 CHECK_INNER_FIELD_ACCESS_OR_NULL(phantom_route_hints_conv_19_conv);
53313                 phantom_route_hints_conv_19_conv = PhantomRouteHints_clone(&phantom_route_hints_conv_19_conv);
53314                 phantom_route_hints_constr.data[t] = phantom_route_hints_conv_19_conv;
53315         }
53316         (*env)->ReleaseLongArrayElements(env, phantom_route_hints, phantom_route_hints_vals, 0);
53317         void* keys_manager_ptr = untag_ptr(keys_manager);
53318         CHECK_ACCESS(keys_manager_ptr);
53319         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
53320         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
53321                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
53322                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
53323         }
53324         void* logger_ptr = untag_ptr(logger);
53325         CHECK_ACCESS(logger_ptr);
53326         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
53327         if (logger_conv.free == LDKLogger_JCalls_free) {
53328                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
53329                 LDKLogger_JCalls_cloned(&logger_conv);
53330         }
53331         LDKCurrency network_conv = LDKCurrency_from_java(env, network);
53332         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
53333         *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);
53334         return tag_ptr(ret_conv, true);
53335 }
53336
53337 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) {
53338         LDKChannelManager channelmanager_conv;
53339         channelmanager_conv.inner = untag_ptr(channelmanager);
53340         channelmanager_conv.is_owned = ptr_is_owned(channelmanager);
53341         CHECK_INNER_FIELD_ACCESS_OR_NULL(channelmanager_conv);
53342         channelmanager_conv.is_owned = false;
53343         void* keys_manager_ptr = untag_ptr(keys_manager);
53344         CHECK_ACCESS(keys_manager_ptr);
53345         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
53346         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
53347                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
53348                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
53349         }
53350         void* logger_ptr = untag_ptr(logger);
53351         CHECK_ACCESS(logger_ptr);
53352         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
53353         if (logger_conv.free == LDKLogger_JCalls_free) {
53354                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
53355                 LDKLogger_JCalls_cloned(&logger_conv);
53356         }
53357         LDKCurrency network_conv = LDKCurrency_from_java(env, network);
53358         void* amt_msat_ptr = untag_ptr(amt_msat);
53359         CHECK_ACCESS(amt_msat_ptr);
53360         LDKCOption_u64Z amt_msat_conv = *(LDKCOption_u64Z*)(amt_msat_ptr);
53361         amt_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(amt_msat));
53362         LDKStr description_conv = java_to_owned_str(env, description);
53363         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
53364         *ret_conv = create_invoice_from_channelmanager(&channelmanager_conv, keys_manager_conv, logger_conv, network_conv, amt_msat_conv, description_conv, invoice_expiry_delta_secs);
53365         return tag_ptr(ret_conv, true);
53366 }
53367
53368 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) {
53369         LDKChannelManager channelmanager_conv;
53370         channelmanager_conv.inner = untag_ptr(channelmanager);
53371         channelmanager_conv.is_owned = ptr_is_owned(channelmanager);
53372         CHECK_INNER_FIELD_ACCESS_OR_NULL(channelmanager_conv);
53373         channelmanager_conv.is_owned = false;
53374         void* keys_manager_ptr = untag_ptr(keys_manager);
53375         CHECK_ACCESS(keys_manager_ptr);
53376         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
53377         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
53378                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
53379                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
53380         }
53381         void* logger_ptr = untag_ptr(logger);
53382         CHECK_ACCESS(logger_ptr);
53383         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
53384         if (logger_conv.free == LDKLogger_JCalls_free) {
53385                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
53386                 LDKLogger_JCalls_cloned(&logger_conv);
53387         }
53388         LDKCurrency network_conv = LDKCurrency_from_java(env, network);
53389         void* amt_msat_ptr = untag_ptr(amt_msat);
53390         CHECK_ACCESS(amt_msat_ptr);
53391         LDKCOption_u64Z amt_msat_conv = *(LDKCOption_u64Z*)(amt_msat_ptr);
53392         amt_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(amt_msat));
53393         LDKSha256 description_hash_conv;
53394         description_hash_conv.inner = untag_ptr(description_hash);
53395         description_hash_conv.is_owned = ptr_is_owned(description_hash);
53396         CHECK_INNER_FIELD_ACCESS_OR_NULL(description_hash_conv);
53397         description_hash_conv = Sha256_clone(&description_hash_conv);
53398         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
53399         *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);
53400         return tag_ptr(ret_conv, true);
53401 }
53402
53403 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) {
53404         LDKChannelManager channelmanager_conv;
53405         channelmanager_conv.inner = untag_ptr(channelmanager);
53406         channelmanager_conv.is_owned = ptr_is_owned(channelmanager);
53407         CHECK_INNER_FIELD_ACCESS_OR_NULL(channelmanager_conv);
53408         channelmanager_conv.is_owned = false;
53409         void* keys_manager_ptr = untag_ptr(keys_manager);
53410         CHECK_ACCESS(keys_manager_ptr);
53411         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
53412         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
53413                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
53414                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
53415         }
53416         void* logger_ptr = untag_ptr(logger);
53417         CHECK_ACCESS(logger_ptr);
53418         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
53419         if (logger_conv.free == LDKLogger_JCalls_free) {
53420                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
53421                 LDKLogger_JCalls_cloned(&logger_conv);
53422         }
53423         LDKCurrency network_conv = LDKCurrency_from_java(env, network);
53424         void* amt_msat_ptr = untag_ptr(amt_msat);
53425         CHECK_ACCESS(amt_msat_ptr);
53426         LDKCOption_u64Z amt_msat_conv = *(LDKCOption_u64Z*)(amt_msat_ptr);
53427         amt_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(amt_msat));
53428         LDKSha256 description_hash_conv;
53429         description_hash_conv.inner = untag_ptr(description_hash);
53430         description_hash_conv.is_owned = ptr_is_owned(description_hash);
53431         CHECK_INNER_FIELD_ACCESS_OR_NULL(description_hash_conv);
53432         description_hash_conv = Sha256_clone(&description_hash_conv);
53433         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
53434         *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);
53435         return tag_ptr(ret_conv, true);
53436 }
53437
53438 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) {
53439         LDKChannelManager channelmanager_conv;
53440         channelmanager_conv.inner = untag_ptr(channelmanager);
53441         channelmanager_conv.is_owned = ptr_is_owned(channelmanager);
53442         CHECK_INNER_FIELD_ACCESS_OR_NULL(channelmanager_conv);
53443         channelmanager_conv.is_owned = false;
53444         void* keys_manager_ptr = untag_ptr(keys_manager);
53445         CHECK_ACCESS(keys_manager_ptr);
53446         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
53447         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
53448                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
53449                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
53450         }
53451         void* logger_ptr = untag_ptr(logger);
53452         CHECK_ACCESS(logger_ptr);
53453         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
53454         if (logger_conv.free == LDKLogger_JCalls_free) {
53455                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
53456                 LDKLogger_JCalls_cloned(&logger_conv);
53457         }
53458         LDKCurrency network_conv = LDKCurrency_from_java(env, network);
53459         void* amt_msat_ptr = untag_ptr(amt_msat);
53460         CHECK_ACCESS(amt_msat_ptr);
53461         LDKCOption_u64Z amt_msat_conv = *(LDKCOption_u64Z*)(amt_msat_ptr);
53462         amt_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(amt_msat));
53463         LDKStr description_conv = java_to_owned_str(env, description);
53464         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
53465         *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);
53466         return tag_ptr(ret_conv, true);
53467 }
53468
53469 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_create_1invoice_1from_1channelmanager_1and_1duration_1since_1epoch_1with_1payment_1hash(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, int8_tArray payment_hash) {
53470         LDKChannelManager channelmanager_conv;
53471         channelmanager_conv.inner = untag_ptr(channelmanager);
53472         channelmanager_conv.is_owned = ptr_is_owned(channelmanager);
53473         CHECK_INNER_FIELD_ACCESS_OR_NULL(channelmanager_conv);
53474         channelmanager_conv.is_owned = false;
53475         void* keys_manager_ptr = untag_ptr(keys_manager);
53476         CHECK_ACCESS(keys_manager_ptr);
53477         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
53478         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
53479                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
53480                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
53481         }
53482         void* logger_ptr = untag_ptr(logger);
53483         CHECK_ACCESS(logger_ptr);
53484         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
53485         if (logger_conv.free == LDKLogger_JCalls_free) {
53486                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
53487                 LDKLogger_JCalls_cloned(&logger_conv);
53488         }
53489         LDKCurrency network_conv = LDKCurrency_from_java(env, network);
53490         void* amt_msat_ptr = untag_ptr(amt_msat);
53491         CHECK_ACCESS(amt_msat_ptr);
53492         LDKCOption_u64Z amt_msat_conv = *(LDKCOption_u64Z*)(amt_msat_ptr);
53493         amt_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)untag_ptr(amt_msat));
53494         LDKStr description_conv = java_to_owned_str(env, description);
53495         LDKThirtyTwoBytes payment_hash_ref;
53496         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
53497         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
53498         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
53499         *ret_conv = create_invoice_from_channelmanager_and_duration_since_epoch_with_payment_hash(&channelmanager_conv, keys_manager_conv, logger_conv, network_conv, amt_msat_conv, description_conv, duration_since_epoch, invoice_expiry_delta_secs, payment_hash_ref);
53500         return tag_ptr(ret_conv, true);
53501 }
53502
53503 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1Payer(JNIEnv *env, jclass clz, int64_t this_arg) {
53504         LDKChannelManager this_arg_conv;
53505         this_arg_conv.inner = untag_ptr(this_arg);
53506         this_arg_conv.is_owned = ptr_is_owned(this_arg);
53507         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
53508         this_arg_conv.is_owned = false;
53509         LDKPayer* ret_ret = MALLOC(sizeof(LDKPayer), "LDKPayer");
53510         *ret_ret = ChannelManager_as_Payer(&this_arg_conv);
53511         return tag_ptr(ret_ret, true);
53512 }
53513
53514 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SiPrefix_1from_1str(JNIEnv *env, jclass clz, jstring s) {
53515         LDKStr s_conv = java_to_owned_str(env, s);
53516         LDKCResult_SiPrefixParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixParseErrorZ), "LDKCResult_SiPrefixParseErrorZ");
53517         *ret_conv = SiPrefix_from_str(s_conv);
53518         return tag_ptr(ret_conv, true);
53519 }
53520
53521 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1from_1str(JNIEnv *env, jclass clz, jstring s) {
53522         LDKStr s_conv = java_to_owned_str(env, s);
53523         LDKCResult_InvoiceParseOrSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceParseOrSemanticErrorZ), "LDKCResult_InvoiceParseOrSemanticErrorZ");
53524         *ret_conv = Invoice_from_str(s_conv);
53525         return tag_ptr(ret_conv, true);
53526 }
53527
53528 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1from_1str(JNIEnv *env, jclass clz, jstring s) {
53529         LDKStr s_conv = java_to_owned_str(env, s);
53530         LDKCResult_SignedRawInvoiceParseErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceParseErrorZ), "LDKCResult_SignedRawInvoiceParseErrorZ");
53531         *ret_conv = SignedRawInvoice_from_str(s_conv);
53532         return tag_ptr(ret_conv, true);
53533 }
53534
53535 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_ParseError_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
53536         LDKParseError* o_conv = (LDKParseError*)untag_ptr(o);
53537         LDKStr ret_str = ParseError_to_str(o_conv);
53538         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
53539         Str_free(ret_str);
53540         return ret_conv;
53541 }
53542
53543 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_ParseOrSemanticError_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
53544         LDKParseOrSemanticError* o_conv = (LDKParseOrSemanticError*)untag_ptr(o);
53545         LDKStr ret_str = ParseOrSemanticError_to_str(o_conv);
53546         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
53547         Str_free(ret_str);
53548         return ret_conv;
53549 }
53550
53551 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Invoice_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
53552         LDKInvoice o_conv;
53553         o_conv.inner = untag_ptr(o);
53554         o_conv.is_owned = ptr_is_owned(o);
53555         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
53556         o_conv.is_owned = false;
53557         LDKStr ret_str = Invoice_to_str(&o_conv);
53558         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
53559         Str_free(ret_str);
53560         return ret_conv;
53561 }
53562
53563 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
53564         LDKSignedRawInvoice o_conv;
53565         o_conv.inner = untag_ptr(o);
53566         o_conv.is_owned = ptr_is_owned(o);
53567         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
53568         o_conv.is_owned = false;
53569         LDKStr ret_str = SignedRawInvoice_to_str(&o_conv);
53570         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
53571         Str_free(ret_str);
53572         return ret_conv;
53573 }
53574
53575 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Currency_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
53576         LDKCurrency* o_conv = (LDKCurrency*)untag_ptr(o);
53577         LDKStr ret_str = Currency_to_str(o_conv);
53578         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
53579         Str_free(ret_str);
53580         return ret_conv;
53581 }
53582
53583 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_SiPrefix_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
53584         LDKSiPrefix* o_conv = (LDKSiPrefix*)untag_ptr(o);
53585         LDKStr ret_str = SiPrefix_to_str(o_conv);
53586         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
53587         Str_free(ret_str);
53588         return ret_conv;
53589 }
53590
53591 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RapidGossipSync_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
53592         LDKRapidGossipSync this_obj_conv;
53593         this_obj_conv.inner = untag_ptr(this_obj);
53594         this_obj_conv.is_owned = ptr_is_owned(this_obj);
53595         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
53596         RapidGossipSync_free(this_obj_conv);
53597 }
53598
53599 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RapidGossipSync_1new(JNIEnv *env, jclass clz, int64_t network_graph) {
53600         LDKNetworkGraph network_graph_conv;
53601         network_graph_conv.inner = untag_ptr(network_graph);
53602         network_graph_conv.is_owned = ptr_is_owned(network_graph);
53603         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
53604         network_graph_conv.is_owned = false;
53605         LDKRapidGossipSync ret_var = RapidGossipSync_new(&network_graph_conv);
53606         int64_t ret_ref = 0;
53607         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
53608         ret_ref = tag_ptr(ret_var.inner, ret_var.is_owned);
53609         return ret_ref;
53610 }
53611
53612 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) {
53613         LDKRapidGossipSync this_arg_conv;
53614         this_arg_conv.inner = untag_ptr(this_arg);
53615         this_arg_conv.is_owned = ptr_is_owned(this_arg);
53616         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
53617         this_arg_conv.is_owned = false;
53618         LDKu8slice update_data_ref;
53619         update_data_ref.datalen = (*env)->GetArrayLength(env, update_data);
53620         update_data_ref.data = (*env)->GetByteArrayElements (env, update_data, NULL);
53621         LDKCResult_u32GraphSyncErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_u32GraphSyncErrorZ), "LDKCResult_u32GraphSyncErrorZ");
53622         *ret_conv = RapidGossipSync_update_network_graph(&this_arg_conv, update_data_ref);
53623         (*env)->ReleaseByteArrayElements(env, update_data, (int8_t*)update_data_ref.data, 0);
53624         return tag_ptr(ret_conv, true);
53625 }
53626
53627 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RapidGossipSync_1is_1initial_1sync_1complete(JNIEnv *env, jclass clz, int64_t this_arg) {
53628         LDKRapidGossipSync this_arg_conv;
53629         this_arg_conv.inner = untag_ptr(this_arg);
53630         this_arg_conv.is_owned = ptr_is_owned(this_arg);
53631         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
53632         this_arg_conv.is_owned = false;
53633         jboolean ret_conv = RapidGossipSync_is_initial_sync_complete(&this_arg_conv);
53634         return ret_conv;
53635 }
53636
53637 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GraphSyncError_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
53638         if (!ptr_is_owned(this_ptr)) return;
53639         void* this_ptr_ptr = untag_ptr(this_ptr);
53640         CHECK_ACCESS(this_ptr_ptr);
53641         LDKGraphSyncError this_ptr_conv = *(LDKGraphSyncError*)(this_ptr_ptr);
53642         FREE(untag_ptr(this_ptr));
53643         GraphSyncError_free(this_ptr_conv);
53644 }
53645
53646 static inline uint64_t GraphSyncError_clone_ptr(LDKGraphSyncError *NONNULL_PTR arg) {
53647         LDKGraphSyncError *ret_copy = MALLOC(sizeof(LDKGraphSyncError), "LDKGraphSyncError");
53648         *ret_copy = GraphSyncError_clone(arg);
53649         int64_t ret_ref = tag_ptr(ret_copy, true);
53650         return ret_ref;
53651 }
53652 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GraphSyncError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
53653         LDKGraphSyncError* arg_conv = (LDKGraphSyncError*)untag_ptr(arg);
53654         int64_t ret_conv = GraphSyncError_clone_ptr(arg_conv);
53655         return ret_conv;
53656 }
53657
53658 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GraphSyncError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
53659         LDKGraphSyncError* orig_conv = (LDKGraphSyncError*)untag_ptr(orig);
53660         LDKGraphSyncError *ret_copy = MALLOC(sizeof(LDKGraphSyncError), "LDKGraphSyncError");
53661         *ret_copy = GraphSyncError_clone(orig_conv);
53662         int64_t ret_ref = tag_ptr(ret_copy, true);
53663         return ret_ref;
53664 }
53665
53666 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GraphSyncError_1decode_1error(JNIEnv *env, jclass clz, int64_t a) {
53667         void* a_ptr = untag_ptr(a);
53668         CHECK_ACCESS(a_ptr);
53669         LDKDecodeError a_conv = *(LDKDecodeError*)(a_ptr);
53670         a_conv = DecodeError_clone((LDKDecodeError*)untag_ptr(a));
53671         LDKGraphSyncError *ret_copy = MALLOC(sizeof(LDKGraphSyncError), "LDKGraphSyncError");
53672         *ret_copy = GraphSyncError_decode_error(a_conv);
53673         int64_t ret_ref = tag_ptr(ret_copy, true);
53674         return ret_ref;
53675 }
53676
53677 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GraphSyncError_1lightning_1error(JNIEnv *env, jclass clz, int64_t a) {
53678         LDKLightningError a_conv;
53679         a_conv.inner = untag_ptr(a);
53680         a_conv.is_owned = ptr_is_owned(a);
53681         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
53682         a_conv = LightningError_clone(&a_conv);
53683         LDKGraphSyncError *ret_copy = MALLOC(sizeof(LDKGraphSyncError), "LDKGraphSyncError");
53684         *ret_copy = GraphSyncError_lightning_error(a_conv);
53685         int64_t ret_ref = tag_ptr(ret_copy, true);
53686         return ret_ref;
53687 }
53688